# hetpatel112390/docsentry architecture

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

- Interactive diagram: https://gitdiagram.com/hetpatel112390/docsentry
- Repository: https://github.com/hetpatel112390/docsentry

## Overview

DocSentry is a document-fraud intelligence application: an operator submits an identity document, the API scans it, looks up similar cases, stores the scan, and returns a verdict and risk score. A separate report endpoint asks the reflection agent for fraud-ring groupings. The Streamlit interface exposes scanning and ring-map views; synthetic-document generation and seeding initialize example cases. The sampled scanner shows DPI, compression-artifact, and metadata checks. README claims about 32×32 cloning and Groq-backed reflection are not confirmed by the sampled implementation, which uses a mock in-memory Hindsight client.

Main entry points: [`api/main.py`](https://github.com/hetpatel112390/docsentry/blob/main/api/main.py) (DocSentry API), [`memory/hindsight_client.py`](https://github.com/hetpatel112390/docsentry/blob/main/memory/hindsight_client.py) (Hindsight client), [`data/seed_data.py`](https://github.com/hetpatel112390/docsentry/blob/main/data/seed_data.py) (Memory seeding), [`agents/ingest_agent.py`](https://github.com/hetpatel112390/docsentry/blob/main/agents/ingest_agent.py) (Case ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_streamlit["Streamlit app<br/>[app.py]"]
  node_scan_page["Scan page<br/>[1_Scan_Document.py]"]
  node_ring_page["Fraud-ring map"]
end

subgraph group_api["API workflow"]
  node_api["DocSentry API<br/>[main.py]"]
  node_result_model["Scan response<br/>[models.py]"]
end

subgraph group_analysis["Forensic analysis"]
  node_scanner["Document scanner<br/>[scanner_agent.py]"]
  node_recall["Prior-case recall<br/>[recall_agent.py]"]
  node_ingest["Case ingestion<br/>[ingest_agent.py]"]
  node_reflect["Fraud-ring reflection<br/>[reflect_agent.py]"]
  node_doc_generator["Synthetic documents<br/>[generate_docs.py]"]
  node_seeder["Memory seeding<br/>[seed_data.py]"]
end

subgraph group_memory["Case memory"]
  node_memory_client["Hindsight client"]
  node_memory_store[("In-memory records")]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_streamlit
node_operator -->|"submits document"| node_scan_page
node_scan_page -->|"posts scan"| node_api
node_api -->|"scans document"| node_scanner
node_api -->|"finds prior cases"| node_recall
node_api -->|"retains case"| node_ingest
node_api -->|"returns response"| node_result_model
node_api -->|"requests rings"| node_reflect
node_ingest -->|"retains record"| node_memory_client
node_recall -->|"recalls records"| node_memory_client
node_reflect -->|"reflects records"| node_memory_client
node_memory_client -->|"writes and reads"| node_memory_store
node_seeder -->|"generates samples"| node_doc_generator
node_seeder -->|"scans samples"| node_scanner
node_seeder -->|"seeds cases"| node_ingest
node_ring_page -.->|"views ring report"| node_api

click node_streamlit "https://github.com/hetpatel112390/docsentry/blob/main/ui/app.py"
click node_scan_page "https://github.com/hetpatel112390/docsentry/blob/main/ui/pages/1_Scan_Document.py"
click node_ring_page "https://github.com/hetpatel112390/docsentry/blob/main/ui/pages/3_Fraud_Ring_Map.py"
click node_api "https://github.com/hetpatel112390/docsentry/blob/main/api/main.py"
click node_result_model "https://github.com/hetpatel112390/docsentry/blob/main/api/models.py"
click node_scanner "https://github.com/hetpatel112390/docsentry/blob/main/agents/scanner_agent.py"
click node_recall "https://github.com/hetpatel112390/docsentry/blob/main/agents/recall_agent.py"
click node_ingest "https://github.com/hetpatel112390/docsentry/blob/main/agents/ingest_agent.py"
click node_reflect "https://github.com/hetpatel112390/docsentry/blob/main/agents/reflect_agent.py"
click node_memory_client "https://github.com/hetpatel112390/docsentry/blob/main/memory/hindsight_client.py"
click node_memory_store "https://github.com/hetpatel112390/docsentry/blob/main/memory/hindsight_client.py"
click node_doc_generator "https://github.com/hetpatel112390/docsentry/blob/main/data/generate_docs.py"
click node_seeder "https://github.com/hetpatel112390/docsentry/blob/main/data/seed_data.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_streamlit,node_scan_page,node_ring_page toneBlue
class node_api,node_result_model toneAmber
class node_scanner,node_recall,node_ingest,node_reflect,node_doc_generator,node_seeder toneMint
class node_memory_client,node_memory_store toneRose
class node_operator toneIndigo
```

## Components

### User interface

- [Streamlit app](https://github.com/hetpatel112390/docsentry/blob/main/ui/app.py): `ui/app.py`
- [Scan page](https://github.com/hetpatel112390/docsentry/blob/main/ui/pages/1_Scan_Document.py): `ui/pages/1_Scan_Document.py`
- [Fraud-ring map](https://github.com/hetpatel112390/docsentry/blob/main/ui/pages/3_Fraud_Ring_Map.py): `ui/pages/3_Fraud_Ring_Map.py`

### API workflow

- [DocSentry API](https://github.com/hetpatel112390/docsentry/blob/main/api/main.py): `api/main.py`
- [Scan response](https://github.com/hetpatel112390/docsentry/blob/main/api/models.py): `api/models.py`

### Forensic analysis

- [Document scanner](https://github.com/hetpatel112390/docsentry/blob/main/agents/scanner_agent.py): `agents/scanner_agent.py`
- [Prior-case recall](https://github.com/hetpatel112390/docsentry/blob/main/agents/recall_agent.py): `agents/recall_agent.py`
- [Case ingestion](https://github.com/hetpatel112390/docsentry/blob/main/agents/ingest_agent.py): `agents/ingest_agent.py`
- [Fraud-ring reflection](https://github.com/hetpatel112390/docsentry/blob/main/agents/reflect_agent.py): `agents/reflect_agent.py`
- [Synthetic documents](https://github.com/hetpatel112390/docsentry/blob/main/data/generate_docs.py): `data/generate_docs.py`
- [Memory seeding](https://github.com/hetpatel112390/docsentry/blob/main/data/seed_data.py): `data/seed_data.py`

### Case memory

- [Hindsight client](https://github.com/hetpatel112390/docsentry/blob/main/memory/hindsight_client.py): `memory/hindsight_client.py`
- [In-memory records](https://github.com/hetpatel112390/docsentry/blob/main/memory/hindsight_client.py): `memory/hindsight_client.py`

### Other components

- **Operator**

## Connections

- Operator → Streamlit app: uses (evidence: `ui/app.py`)
- Operator → Scan page: submits document (evidence: `ui/pages/1_Scan_Document.py`)
- Scan page → DocSentry API: posts scan (evidence: `ui/pages/1_Scan_Document.py`)
- DocSentry API → Document scanner: scans document (evidence: `api/main.py`)
- DocSentry API → Prior-case recall: finds prior cases (evidence: `api/main.py`)
- DocSentry API → Case ingestion: retains case (evidence: `api/main.py`)
- DocSentry API → Scan response: returns response (evidence: `api/main.py`)
- DocSentry API → Fraud-ring reflection: requests rings (evidence: `api/main.py`)
- Case ingestion → Hindsight client: retains record (evidence: `agents/ingest_agent.py`)
- Prior-case recall → Hindsight client: recalls records (evidence: `agents/recall_agent.py`)
- Fraud-ring reflection → Hindsight client: reflects records (evidence: `agents/reflect_agent.py`)
- Hindsight client → In-memory records: writes and reads (evidence: `memory/hindsight_client.py`)
- Memory seeding → Synthetic documents: generates samples (evidence: `data/seed_data.py`)
- Memory seeding → Document scanner: scans samples (evidence: `data/seed_data.py`)
- Memory seeding → Case ingestion: seeds cases (evidence: `data/seed_data.py`)
- Fraud-ring map → DocSentry API: views ring report
