AI-Enabled Secure Digital Document Management System for Legal & Investigation Records
Built for Smart India Hackathon (SIH) 2026
Legal and investigation agencies handle highly sensitive documents — FIRs, forensic reports, witness statements, bail applications — that are vulnerable to unauthorized access, tampering, and leakage. Traditional file systems offer no AI-powered classification, no tamper detection, and no audit trail.
SecureDoc-LI solves this with a unified platform combining AES-256 encryption, AI document intelligence, blockchain-style audit chains, and semantic search.
| Feature | Description |
|---|---|
| 🔐 AES-256-GCM Encryption | Every document encrypted at rest with authenticated encryption |
| 🧠 AI Document Classification | Auto-classifies documents (FIR, Forensic Report, Witness Statement, etc.) using trained ML model |
| 🔍 Semantic Search | Find documents by meaning using all-MiniLM-L6-v2 sentence embeddings |
| 🕵️ Sensitive Entity Detection | Extracts names, phone numbers, Aadhaar, IPs, case IDs using spaCy NLP |
| 📊 Risk Scoring | Dynamic risk score per document based on sensitivity and access patterns |
| 🧾 Hash-Chained Audit Trail | SHA-256 chained audit log — tamper-evident chain of custody |
| 🚨 Unauthorized Access Alerts | Auto-detects cross-user document access, sends AI-analysed HTML email alert |
| 🔐 TOTP MFA | Two-factor authentication with Google Authenticator / Authy |
| 📈 AI Classifier Evaluation | Live precision, recall, F1, confusion matrix dashboard |
| 👥 Role-Based Access Control | Administrator, Investigator, Forensic Officer, Lawyer, Case Supervisor, Auditor |
securedoc_v2/
├── backend/
│ └── app/
│ ├── main.py # FastAPI app entry point
│ ├── models.py # SQLAlchemy DB models
│ ├── auth.py # JWT authentication
│ ├── crypto_utils.py # AES-256-GCM encrypt/decrypt
│ ├── audit.py # Hash-chained audit log
│ ├── alert_manager.py # Unauthorized access email alerts
│ ├── ollama_agent.py # AI agent for alert analysis
│ ├── risk.py # Risk scoring engine
│ ├── text_extract.py # PDF/TXT text extraction
│ ├── ai/
│ │ ├── classify.py # Document classifier (scikit-learn)
│ │ ├── sensitive_detect.py # NLP entity extraction (spaCy)
│ │ └── train_classifier.py # Model training script
│ └── routes/
│ ├── auth_routes.py # Login, register, MFA
│ ├── document_routes.py # Upload, download, semantic search
│ ├── audit_routes.py # Audit log + chain verification
│ ├── dashboard_routes.py # Stats
│ ├── eval_routes.py # AI metrics endpoint
│ └── mfa_routes.py # TOTP MFA setup/verify
└── frontend/
├── index.html # Single-page app
├── app.js # All frontend logic
└── style.css # Styling
- Python 3.11+
- pip
# Clone the repo
git clone https://github.com/shrridharshan27/SecureDoc-LI.git
cd SecureDoc-LI/securedoc_v2/backend
# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac
# Install dependencies
pip install -r requirements.txt
# Start the server
uvicorn app.main:app --reloadOpen your browser at http://127.0.0.1:8000
First run:
sentence-transformerswill download theall-MiniLM-L6-v2model (~80MB). This is a one-time download.
| Role | Permissions |
|---|---|
administrator |
Full access + tamper simulation + alert emails |
investigator |
Upload, download, search |
forensic_officer |
Upload, download, verify integrity |
lawyer |
Read + download only |
case_supervisor |
Read + audit trail |
auditor |
Read-only, no downloads |
- Document Classifier — scikit-learn TF-IDF + Logistic Regression (trained on legal document corpus)
- Semantic Search —
sentence-transformers/all-MiniLM-L6-v2(384-dim embeddings, cosine similarity) - Entity Extraction — spaCy
en_core_web_sm+ regex patterns for Aadhaar, phone, IP, case IDs - Risk Scoring — Composite score: sensitivity weight + category risk + recent access frequency
- AES-256-GCM authenticated encryption for all stored files
- SHA-256 hash chaining on audit log (blockchain-style tamper evidence)
- TOTP MFA (RFC 6238) with QR code provisioning
- JWT Bearer tokens for all API endpoints
- Role-based route guards on both frontend and backend
- Integrity verification on every download — detects byte-level tampering
Real-time stats: total documents, users, audit records, high-risk count, tampered documents.
Search documents by meaning — "murder case Hyderabad" finds the FIR, not just keyword matches.
Live confusion matrix, per-category precision/recall/F1, training vs test sample count.
Hash-chained audit trail with one-click full chain integrity verification.
Built for Smart India Hackathon 2026
MIT License