# mehulmathodia/compliance-sentinel-pro architecture

> Architecture diagram of the GitHub repository mehulmathodia/compliance-sentinel-pro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mehulmathodia/compliance-sentinel-pro
- Repository: https://github.com/mehulmathodia/compliance-sentinel-pro

## Overview

Compliance-Sentinel Pro is a local-first contract auditing application. A user uploads a PDF through the Streamlit dashboard; the backend extracts and chunks its text, indexes it, retrieves relevant contract passages for a policy-based audit, and returns findings and evidence. The dashboard can request a PDF report and compare two contract versions. The README documents local Ollama inference and ChromaDB storage; the sampled backend shows their use, but does not establish session isolation. Components share the two source files because the implementation is concentrated there.

Main entry points: [`frontend/app.py`](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/frontend/app.py) (Streamlit dashboard), [`backend/main.py`](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py) (Ingest endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_dashboard["Streamlit dashboard<br/>[app.py]"]
end

subgraph group_documents["Document processing"]
  node_ingest_api["Ingest endpoint<br/>[main.py]"]
  node_pdf_loader["PDF extraction<br/>[main.py]"]
  node_chunker["Text chunking<br/>[main.py]"]
  node_embedding["Ollama embeddings"]
  node_vector_store[("Chroma index<br/>[main.py]")]
end

subgraph group_analysis["Audit and reporting"]
  node_audit_api["Audit endpoint<br/>[main.py]"]
  node_audit_retrieval["Passage retrieval<br/>[main.py]"]
  node_policy_llm["Ollama language model"]
  node_comparison_api["Compare endpoint<br/>[main.py]"]
  node_comparison_context["Version contexts<br/>[main.py]"]
  node_report_api["PDF endpoint<br/>[main.py]"]
  node_pdf_renderer["Report renderer<br/>[main.py]"]
end

node_user(("Contract reviewer"))

node_user -->|"uses"| node_dashboard
node_dashboard -->|"uploads PDF"| node_ingest_api
node_ingest_api -->|"loads PDF"| node_pdf_loader
node_ingest_api -->|"splits text"| node_chunker
node_ingest_api -->|"indexes chunks"| node_vector_store
node_ingest_api -->|"provides embeddings"| node_embedding
node_dashboard -->|"submits audit"| node_audit_api
node_audit_api -->|"retrieves passages"| node_audit_retrieval
node_audit_retrieval -->|"searches"| node_vector_store
node_audit_api -->|"requests findings"| node_policy_llm
node_dashboard -->|"requests report"| node_report_api
node_report_api -->|"renders report"| node_pdf_renderer
node_dashboard -->|"submits versions"| node_comparison_api
node_comparison_api -->|"builds contexts"| node_comparison_context
node_comparison_context -->|"loads PDFs"| node_pdf_loader
node_comparison_context -->|"splits text"| node_chunker
node_comparison_context -->|"requests embeddings"| node_embedding
node_comparison_context -->|"retrieves passages"| node_policy_llm
node_comparison_api -->|"analyzes changes"| node_policy_llm

click node_dashboard "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/frontend/app.py"
click node_ingest_api "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_pdf_loader "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_chunker "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_vector_store "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_audit_api "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_audit_retrieval "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_comparison_api "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_comparison_context "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_report_api "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"
click node_pdf_renderer "https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_user toneBlue
class node_ingest_api,node_pdf_loader,node_chunker,node_embedding,node_vector_store toneAmber
class node_audit_api,node_audit_retrieval,node_policy_llm,node_comparison_api,node_comparison_context,node_report_api,node_pdf_renderer toneMint
```

## Components

### User interface

- [Streamlit dashboard](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/frontend/app.py): `frontend/app.py`

### Document processing

- [Ingest endpoint](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`
- [PDF extraction](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`
- [Text chunking](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`
- **Ollama embeddings**
- [Chroma index](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`

### Audit and reporting

- [Audit endpoint](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`
- [Passage retrieval](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`
- **Ollama language model**
- [Compare endpoint](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`
- [Version contexts](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`
- [PDF endpoint](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`
- [Report renderer](https://github.com/mehulmathodia/compliance-sentinel-pro/blob/main/backend/main.py): `backend/main.py`

### Other components

- **Contract reviewer**

## Connections

- Contract reviewer → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Ingest endpoint: uploads PDF (evidence: `frontend/app.py`)
- Ingest endpoint → PDF extraction: loads PDF (evidence: `backend/main.py`)
- Ingest endpoint → Text chunking: splits text (evidence: `backend/main.py`)
- Ingest endpoint → Chroma index: indexes chunks (evidence: `backend/main.py`)
- Ingest endpoint → Ollama embeddings: provides embeddings (evidence: `backend/main.py`)
- Streamlit dashboard → Audit endpoint: submits audit (evidence: `frontend/app.py`)
- Audit endpoint → Passage retrieval: retrieves passages (evidence: `backend/main.py`)
- Passage retrieval → Chroma index: searches (evidence: `backend/main.py`)
- Audit endpoint → Ollama language model: requests findings (evidence: `backend/main.py`)
- Streamlit dashboard → PDF endpoint: requests report (evidence: `frontend/app.py`)
- PDF endpoint → Report renderer: renders report (evidence: `backend/main.py`)
- Streamlit dashboard → Compare endpoint: submits versions (evidence: `frontend/app.py`)
- Compare endpoint → Version contexts: builds contexts (evidence: `backend/main.py`)
- Version contexts → PDF extraction: loads PDFs (evidence: `backend/main.py`)
- Version contexts → Text chunking: splits text (evidence: `backend/main.py`)
- Version contexts → Ollama embeddings: requests embeddings (evidence: `backend/main.py`)
- Version contexts → Ollama language model: retrieves passages (evidence: `backend/main.py`)
- Compare endpoint → Ollama language model: analyzes changes (evidence: `backend/main.py`)
