Generated: 2026-07-09 Phase 0 of migration from experimental PDF analyzer to production Legal AI desktop app.
| # | File | Inferred Purpose | Verdict | Action |
|---|---|---|---|---|
| 1 | pdf_analyzer.py |
Main Streamlit app: PDF extract, chunk, embed, query via Ollama | REFACTOR | Split into app/core/ingestion/, app/core/embeddings/, app/core/rag/ |
| 2 | cli.py |
Thin CLI wrapper around PDFAnalyzer |
DELETE | Logic duplicated in pdf_analyzer.py; no unique value |
| 3 | simple_cli.py |
Simpler CLI, nearly identical to cli.py |
DELETE | Redundant third variant of same logic |
| 4 | ultra_simple.py |
Minimal flat-script variant of the same pipeline | DELETE | Duplicate; no classes, no reusability |
| 5 | enhanced_legal_rag_fixed.py |
Enhanced RAG with semantic chunking, hybrid search, advanced prompts | KEEP | Core algorithmic asset; refactor into app/core/rag/ |
| 6 | fastapi_app.py |
FastAPI REST wrapper importing enhanced_legal_rag (missing module) |
REFACTOR | Dead import; refactor into app/api/ with proper DI |
| 7 | config.py |
Plain Python constants for Ollama model, chunk sizes, etc. | REFACTOR | Convert to pydantic-settings in app/infra/config.py |
| 8 | requirements.txt |
16 pinned deps (torch, fastapi, streamlit, ollama, etc.) | DELETE | Consolidate into pyproject.toml (Poetry) |
| 9 | test_api.py |
HTTP test script for FastAPI endpoints | REFACTOR | Move to tests/test_api/ with pytest fixtures |
| 10 | run_fastapi.bat |
Batch launcher for FastAPI server | MERGE | Content → scripts/ directory |
| 11 | test_api.bat |
Batch launcher for test script | MERGE | Content → scripts/ directory |
| 12 | README.md |
Project README (outdated — references Streamlit, Ollama-only) | REWRITE | New README for production app |
| 13 | ENHANCED_FEATURES.md |
Feature description for enhanced RAG | DELETE | Content absorbed into docs/ |
| 14 | FASTAPI_DOCS.md |
API documentation for FastAPI wrapper | DELETE | Content absorbed into docs/ |
| 15 | SETUP_GUIDE.md |
Setup instructions (hardcoded d:\INTERNSHIP\ paths) |
DELETE | Contains absolute local paths; replaced by docs/BUILD.md |
| 16 | __pycache__/ |
Python bytecode cache | DELETE | *.pyc must not be committed |
| 17 | CLEANUP_REPORT.md |
This file | KEEP | Permanent record of audit |
-
fastapi_app.py:19—from enhanced_legal_rag import EnhancedLegalRAG
→ Moduleenhanced_legal_rag.pywas deleted in commit1818f03. The fileenhanced_legal_rag_fixed.pyexists but is not imported. This is a dead import that will raiseModuleNotFoundErrorat runtime. -
enhanced_legal_rag_fixed.py:6-13— importspdfplumber,numpy,faiss,sentence_transformers,ollama
→ These are the core libraries, but the file has a duplicatedmain()that mixes CLI concerns with library code. -
pdf_analyzer.py:9—import streamlit as st
→ Ties the core logic to Streamlit, making it non-reusable outside the web context. Must be separated.
| Action | Details |
|---|---|
Deleted cli.py |
Redundant CLI; all logic in pdf_analyzer.py |
Deleted simple_cli.py |
Three-way duplicate of the same pipeline |
Deleted ultra_simple.py |
Unmaintainable flat script variant |
Deleted ENHANCED_FEATURES.md |
Absorbed into future docs/ |
Deleted FASTAPI_DOCS.md |
Absorbed into future docs/ |
Deleted SETUP_GUIDE.md |
Contained hardcoded d:\INTERNSHIP\ local path |
Deleted __pycache__/ |
Compiled bytecode (2 .pyc files) |
Created .gitignore |
Python + Windows + IDE patterns |
Created pyproject.toml |
Poetry-managed dependencies (replaces requirements.txt) |
Created scripts/ |
For build/package tools |
requirements.txt (16 deps) → pyproject.toml (Poetry)
Removed (not needed for target architecture):
streamlit— replaced by PyQt6 desktop UIollama— replaced byllama-cpp-python(embedded local LLM)pdfplumber— replaced byPyMuPDF(fitz) for broader format supporttorch— not directly needed; SentenceTransformers bundles it
Added for target architecture:
PyMuPDF— PDF & image handlingpython-docx— DOCX supportebooklib— EPUB supportpython-pptx— PPTX slidespillow— image processingpytesseract/paddleocr— OCR fallbackllama-cpp-python— local LLM inference (no Ollama dependency)chromadb— local vector store (alternative to FAISS)sentence-transformers— embeddingsfastapi+uvicorn— internal APIPyQt6— desktop UIpydantic-settings— configuration managementdependency-injector— DI containercryptography— AES-256 encryptionpytest+pytest-cov— testingruff+mypy+black— linting/formatting
1818f03 Delete enhanced_legal_rag.py
9278643 Changes done
32ff046 Fixed some bugs
17107ce Completed the task
- Create target directory structure (
app/,tests/,scripts/,docs/,data/) - Implement
app/infra/config.pywithpydantic-settings - Implement
app/domain/legal entities - Implement
app/core/ingestion/document loaders - Implement
app/core/embeddings/local embedding - Implement
app/core/retrieval/vector DB - Implement
app/core/llm/local LLM runner - Implement
app/core/rag/RAG orchestration - Implement
app/ui/PyQt6 desktop app - Implement
app/api/local FastAPI service - Implement
scripts/build_knowledge_base.py - Package as
.exewith PyInstaller + Inno Setup