A production-grade, domain-specialized Retrieval-Augmented Generation (RAG) platform engineered for enterprise contract review, quarterly financial analysis, and corporate compliance due diligence. Combines local vector embeddings and a pure-Python vector index for data privacy with Groq Cloud API for serverless, zero-GPU token streaming.
Generic "Chat with your PDF" apps are toy demonstrations: they lack business domain expertise, hallucinate without verifiable citations, lose page numbers, and pose massive corporate privacy risks.
DocuMind AI solves real enterprise diligence bottlenecks:
- Contract Review & Legal Risk (M&A / Procurement): Instantly audits Master Services Agreements (MSAs) and vendor contracts for liability caps, consequential damage waivers, indemnification traps, and termination penalties.
- Financial & Earnings Intelligence (Equity Research / Corporate Finance): Analyzes 10-K/10-Q SEC filings and earnings releases, extracting revenue, ARR, gross/operating margins, EPS guidance, and macroeconomic risk factors.
- Cybersecurity & Regulatory Compliance (CISO / Audit Committees): Audits enterprise SOPs against SOC 2, ISO 27001, and GDPR Article 33 requirements, checking MFA mandates, Zero Trust controls, and 72-hour breach notification SLAs.
Generate an audit-grade report synthesizing:
- Executive Briefing & Metadata: Parties, governing law, and core transaction purpose.
- Critical Risk Heatmap Matrix: Formatted audit table classifying issues by severity (π΄ High Risk, π‘ Moderate Warning, π’ Compliant).
- Financial & Operational Liabilities: Explicit dollar amounts, payment terms, and delivery milestones.
- Regulatory Assessment: SOC 2, ISO 27001, and GDPR compliance validation.
- Auditor Recommendations: Strategic takeaways for corporate decision-makers before signing or investing.
- Export to Markdown: Instant
.mdreport download for stakeholders.
Real business decisions require audit trails. Every answer produced by DocuMind includes an interactive Audit Citations & Exhibits drawer displaying:
- Exact Page Number (1-indexed)
- Chunk ID and character count
- Cosine Relevance Match %
- Verifiable document excerpt block
Naive paragraph splitting (\n) frequently generates chunks exceeding the 512-token limit of MiniLM, resulting in silent truncation and lost clauses.
- DocuMind uses a sliding window chunker (~1,100 characters per chunk with 180-character overlap) that respects sentence boundaries.
- Preserves exact page attribution and rich metadata across the entire document.
- 100% Local Vectorization: Text extraction, sliding chunking, and embedding generation happen strictly on local CPU/GPU using
sentence-transformers/all-MiniLM-L6-v2. - Pure-Python Vector Store: In-memory vector index with zero external databases (no Pinecone, Milvus, or external vectors exposed).
- ZDR Cloud Inference: Prompts transmitted via TLS 1.3 to Groq Cloud are processed strictly in volatile memory. Data is never logged, stored, or used for model retraining.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DocuMind AI β Modern Executive Dark SaaS UI β
β [Domain Selector] [Enterprise Samples / Custom Upload] [Risk Matrix/Chat]β
ββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββββ
β Page-Aware PDF Parser β
β (pypdf + Sliding Chunk) β
β Tracks Page Numbers & β
β Sanitizes Injection Tokensβ
βββββββββββββββ¬ββββββββββββββ
β
βββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββ
β β
ββββββββββΌββββββββββββββββββ ββββββββββΌββββββββββββββββββ
β Local Embedding Engine β β Pure-Python Vector β
β all-MiniLM-L6-v2 β β In-Memory Index β
β (384-dim L2 Normalised) β ββ Batch Vector Embeddings ββ> β Cosine Distance Scan β
β Runs 100% Locally β β Zero External DBs β
ββββββββββββββββββββββββββββ ββββββββββββββ¬ββββββββββββββ
β
Top-k Cited Exhibits
β
ββββββββββββββΌββββββββββββββ
β Enterprise LLM Client β
β (Domain System Prompts)β
ββββββββββββββ¬ββββββββββββββ
β
ββββββββββββββΌββββββββββββββ
β Groq Cloud API β
β Qwen 3.8-27B β
β Zero Data Retention β
β (Tokens Streamed Live) β
ββββββββββββββββββββββββββββ
RAG-system/
βββ main.py # Streamlit Executive Dark SaaS Application
βββ llm_client.py # Domain prompts, Groq LLM client & Executive Audit generator
βββ local_embedding.py # Local MiniLM model, batch embedding & citation engine
βββ vector_index.py # Pure Python stdlib in-memory cosine/Euclidean vector store
βββ pdf_reader.py # Page-aware PDF parser, sliding window chunker & sanitizer
βββ sample_documents/ # Pre-packaged enterprise test documents
β βββ saas_master_services_agreement.pdf # B2B SaaS MSA (Legal & Contracts)
β βββ q1_corporate_earnings_report.pdf # Q1 10-Q Earnings Release (Financials)
β βββ corporate_cybersecurity_policy.pdf # Security & AI Governance SOP (Compliance)
βββ scripts/
β βββ create_sample_pdfs.py # Script to regenerate sample PDFs
βββ tests/
β βββ test_rag_pipeline.py # Pytest test suite (8 unit tests)
βββ audit_notes/
β βββ project_improvements.md # Engineering audit & resolved architectural items
βββ requirements.txt # Python dependencies
βββ .env.example # Template for API keys
- Python 3.10+
- Free Groq Cloud API key from console.groq.com/keys
# Clone the repository
git clone https://github.com/PrinceBadru/RAG-system.git
cd RAG-system
# Create and activate a virtual environment
python -m venv .venv
# On Windows (PowerShell):
.\.venv\Scripts\Activate.ps1
# On macOS / Linux:
# source .venv/bin/activate
# Install dependencies
pip install -r requirements.txtCreate a .env file in the project root:
GROQ_API_KEY=gsk_your_groq_api_key_hereChoose whichever method best fits your workflow:
- Command Prompt / Windows Explorer: Double-click or run
run_app.batrun_app.bat
- PowerShell: Run
run_app.ps1.\run_app.ps1
Bypasses Windows PATH issues completely by invoking the virtual environment directly:
- Windows (PowerShell / CMD):
.\.venv\Scripts\python.exe -m streamlit run main.py
- macOS / Linux:
./.venv/bin/python -m streamlit run main.py
- Windows (PowerShell):
.\.venv\Scripts\Activate.ps1 streamlit run main.py
- Windows (Command Prompt):
.\.venv\Scripts\activate.bat streamlit run main.py
- macOS / Linux:
source .venv/bin/activate streamlit run main.py
Once launched, Streamlit will automatically open or display your local URL at:
http://localhost:8501
Tip
Troubleshooting 'streamlit' is not recognized:
If you see 'streamlit' is not recognized as an internal or external command, it means your virtual environment is not currently activated in your shell or global Python scripts are not on your Windows PATH. Use Method 1 (run_app.bat / .\run_app.ps1) or Method 2 (.\.venv\Scripts\python.exe -m streamlit run main.py) to run without needing to touch Windows environment variables.
Run the test suite using either the direct venv Python:
.\.venv\Scripts\python.exe -m pytest tests/test_rag_pipeline.py -vOr after activating your virtual environment:
pytest tests/test_rag_pipeline.py -vAll 8 unit tests validate:
- In-memory vector distance metrics and dimension mismatch guards
- Page-aware extraction and sliding-window overlap
- Disallowed LLM control token sanitization (
<|end|>,<|system|>) - Local MiniLM embedding generation and metadata preservation
- Grounded prompt construction and exhibit citations
MIT License. Created by Prince Badru.