Production-Ready PDF Manager β Upload a PDF, extract data with triple OCR engines + AI/RAG, edit fields interactively, and export.
- π€ PDF Upload β drag-and-drop or browse; up to 50 MB
- π Triple OCR Engine β Tesseract + EasyOCR + PaddleOCR with ensemble confidence scoring
- π€ AI Field Extraction β NER (spaCy) + rule-based + RAG (LangChain + HuggingFace embeddings)
- π₯ Confidence Heatmaps β pixel-wise Green/Yellow/Red visualisation per word
- π Performance Dashboard β document quality score, regional scores, word confidence breakdown
- ποΈ Inline Editing β split layout: PDF viewer on left, editable fields on right
- β¬οΈ Export β JSON or CSV with full metadata and confidence scores
- π Edit History β all field edits are versioned and audited
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Browser (React) β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββ β
β β PDFViewer β β FieldsEditor β β Heatmap / β β
β β (react-pdf) β β (inline β β Dashboard β β
β β zoom/scroll β β edit) β β β β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββ β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β REST /api/v1
ββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ
β Flask Backend (Python) β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β API v1 Blueprint β β
β β POST /upload POST /extract/ocr POST /extract/aiβ β
β β GET /fields PUT /fields/:id GET /heatmap β β
β ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββΌβββββββββββββββββββββββββββββββ β
β β OCR Layer β β
β β Tesseract ββ β β
β β EasyOCR ββΌβ Ensemble Merge β WordResult[] β β
β β PaddleOCR ββ β β
β ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββΌβββββββββββββββββββββββββββββββ β
β β Extraction Layer β β
β β FieldDetector (NER + rules) β β
β β RAGSystem (LangChain + sentence-transformers) β β
β β ConfidenceCalculator β DocumentQuality β β
β β HeatmapGenerator β JSON + PNG β β
β ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββΌβββββββββββββββββββββββββββββββ β
β β SQLAlchemy (SQLite / PostgreSQL) β β
β β documents Β· extracted_fields Β· field_edit_historyβ β
β β ocr_character_data Β· rag_embeddings Β· audit_logsβ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
PDF-Manager/
βββ backend/
β βββ __init__.py
β βββ config.py
β βββ database.py
β βββ models.py (Pydantic API models)
β βββ requirements.txt
β βββ app.py (entry point)
β βββ ocr/
β β βββ __init__.py
β β βββ ocr_engine.py (Tesseract + EasyOCR + PaddleOCR)
β β βββ confidence_calculator.py
β β βββ heatmap_generator.py
β βββ extraction/
β β βββ __init__.py
β β βββ extractor.py (orchestrator)
β β βββ rag_system.py (LangChain + HuggingFace)
β β βββ field_detector.py (NER + rules)
β βββ api/
β β βββ __init__.py
β β βββ routes.py (REST API v1 blueprint)
β βββ services/
β βββ pdf_service.py
β βββ ai_extraction_service.py
β βββ ml_service.py
βββ frontend/
β βββ public/index.html
β βββ src/
β β βββ App.js
β β βββ components/
β β β βββ PDFViewer.js (react-pdf)
β β β βββ FieldsEditor.js (editable fields table)
β β β βββ OCRConfidenceHeatmap.js
β β β βββ PerformanceDashboard.js
β β β βββ ExtractionPage.js (split layout orchestrator)
β β βββ services/api.js
β β βββ styles/extraction.css
β βββ package.json
βββ models.py (SQLAlchemy models)
βββ blueprints/ (Flask web-UI blueprints)
βββ templates/ (Jinja2 HTML templates)
βββ static/ (CSS, JS for server-rendered UI)
βββ database/ (SQL init scripts)
βββ docs/
β βββ API.md
β βββ ARCHITECTURE.md
β βββ SETUP.md
βββ docker-compose.yml
βββ README.md
git clone https://github.com/rahulmisra2010-ctrl/PDF-Manager.git
cd PDF-Manager
docker compose up --build| Service | URL |
|---|---|
| Frontend (React) | http://localhost:3000 |
| Backend (Flask + UI/API) | http://localhost:5000 |
| Dashboard login | http://localhost:5000/auth/login |
If you prefer not to use Docker:
git clone https://github.com/rahulmisra2010-ctrl/PDF-Manager.git
cd PDF-Manager
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r backend/requirements.txt
cp .env.example .env # optional; adjust values as needed
python app.py # opens http://localhost:5000See docs/SETUP.md for more details.
The .env file must be created in the project root (the same directory that contains app.py):
PDF-Manager/ β repository root
βββ .env β place it here
βββ .env.example β template to copy from
βββ app.py
βββ ...
app.pyalso checks for abackend/.envfile for backwards compatibility, but the project root is the canonical location.
Copy the bundled template and edit it with your values:
cp .env.example .envThen open .env in your editor and set at least the two critical keys described below.
Used by Flask to sign session cookies and CSRF tokens. Every restart with a new key invalidates all active sessions.
Generate a strong value:
python -c "import secrets; print(secrets.token_hex(32))"Then set it in .env:
SECRET_KEY=<paste-the-generated-value-here>
β οΈ Duplicate-key warning β Your.envfile must contain exactly oneSECRET_KEYline. If the key appears more than once,python-dotenvuses the first occurrence and silently ignores the rest, which can cause confusing behaviour. Search the file before saving:grep -n "SECRET_KEY" .env # should print exactly one line
Password for the auto-created admin account on first run. Leave it blank to
have the app generate and print a random password at startup, but always set
an explicit password in production:
ADMIN_PASSWORD=<your-strong-password>| Setting | Development | Production |
|---|---|---|
DEBUG |
true |
false |
SECRET_KEY |
Any non-empty string | Cryptographically random value (β₯ 32 hex chars) |
ADMIN_PASSWORD |
Convenient test value | Strong, unique password |
DATABASE_URL |
sqlite:///instance/pdf_manager.db |
PostgreSQL connection string |
ALLOWED_ORIGINS |
http://localhost:3000 |
Your real frontend domain(s) |
A minimal development .env:
DEBUG=true
SECRET_KEY=dev-change-me
ADMIN_PASSWORD=dev-admin-please-change
DATABASE_URL=sqlite:///instance/pdf_manager.dbA minimal production .env:
DEBUG=false
SECRET_KEY=<output-of-secrets.token_hex(32)>
ADMIN_PASSWORD=<strong-unique-password>
DATABASE_URL=postgresql://pdfmanager:<password>@db-host:5432/pdfmanager
ALLOWED_ORIGINS=["https://your-frontend-domain.com"]If you run into any problems locating, creating, or editing your .env β for
either production or development β open an issue in this repository and include
the error message you are seeing (but never paste the actual secret values).
Let me know if you need any more details about this setup or help correcting your .env for production or development.
PDF-Manager/
βββ app.py # Flask application factory (root)
βββ pdf_manager_app.py # Convenience entry point / demo runner
βββ backend/
β βββ app.py # Wrapper that loads the root app.py
β βββ models.py # SQLAlchemy models
β βββ config.py # Environment-based configuration
β βββ routes/
β β βββ pdf_routes.py # REST endpoints (legacy)
β βββ services/
β β βββ pdf_service.py # PDF extraction & export (PyMuPDF + OpenCV)
β β βββ ml_service.py # ML field classification (PyTorch)
β βββ requirements.txt
βββ frontend/
β βββ src/
β β βββ App.js
β β βββ components/
β β β βββ UploadPDF.js
β β β βββ DataDisplay.js
β β β βββ EditData.js
β β βββ services/
β β βββ api.js
β βββ package.json
βββ database/
β βββ schema.sql # PostgreSQL table definitions
β βββ init.sql # Role creation & seed data
βββ docs/
β βββ PHASE_1.md # Week 1-2 development guide
β βββ ARCHITECTURE.md # System design
β βββ API_DOCS.md # REST API reference
β βββ SETUP.md # Local development setup
βββ docker-compose.yml
βββ requirements.txt # Root-level (delegates to backend/)
βββ .gitignore
A note on entry points: the root-level app.py is the primary Flask application.
backend/app.py is a thin compatibility wrapper so the app can also be started
from inside the backend/ directory, but python app.py from the repository
root is the recommended command.
| Document | Description |
|---|---|
| docs/PHASE_1.md | Week 1-2 task checklist and acceptance criteria |
| docs/ARCHITECTURE.md | System design and component diagram |
| docs/API_DOCS.md | Full REST API reference |
| docs/SETUP.md | Local development setup guide |
| Layer | Technology |
|---|---|
| Frontend | React 18 |
| Backend | Flask (Python 3.11) |
| PDF parsing | PyMuPDF |
| Image processing | OpenCV |
| ML | PyTorch |
| Database | SQLite (default) / PostgreSQL (optional) |
| Containerisation | Docker Compose |
MIT