# nextgenspark1/agentic-doc-intelligence architecture

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

- Interactive diagram: https://gitdiagram.com/nextgenspark1/agentic-doc-intelligence
- Repository: https://github.com/nextgenspark1/agentic-doc-intelligence

## Overview

Agentic Document Intelligence is a document-analysis platform with two product workflows: investigations and tendering. Users work through separate web applications; the backend provides shared API, authentication, and persistence alongside product-specific analysis. Investigation analysis is explicitly triggered by its route and scheduled as a background task. Tendering exposes workspaces, requirements, bid decisions, and a document library. The source index supports many module relationships, but does not reveal all runtime wiring; unverified frontend-to-API links are dashed.

Main entry points: [`backend/apps/investigation/pipeline/__init__.py`](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/__init__.py) (Case analysis), [`backend/apps/tendering/routes.py`](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/routes.py) (Tender routes), [`backend/core/main.py`](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/main.py) (Core API), [`backend/apps/investigation/routes.py`](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/routes.py) (Investigation routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interfaces"]
  node_case_app["Case application<br/>[App.tsx]"]
  node_case_workspace["Case workspace"]
  node_case_api_client["Case API client<br/>[api.ts]"]
  node_tender_app["Tender application<br/>[App.tsx]"]
  node_tender_library["Document library"]
  node_tender_api_client["Tender API client<br/>[tenders.ts]"]
end

subgraph group_shared["Shared backend"]
  node_core_app["Core API<br/>[main.py]"]
  node_auth["JWT authentication<br/>[auth.py]"]
end

subgraph group_investigation["Investigations"]
  node_investigation_routes["Investigation routes<br/>[routes.py]"]
  node_case_analysis["Case analysis<br/>[__init__.py]"]
  node_entity_resolution["Entity resolution"]
  node_relationship_building["Relationship building"]
  node_anomaly_detection["Anomaly detection"]
  node_timeline_reconstruction["Timeline reconstruction"]
  node_case_summaries["Case summaries<br/>[summarise.py]"]
end

subgraph group_tendering["Tendering"]
  node_tender_routes["Tender routes<br/>[routes.py]"]
  node_tender_pipeline["Tender workflows"]
  node_readiness_review["Readiness review"]
  node_tender_evidence["Evidence matching"]
end

subgraph group_storage_ai["Data and AI"]
  node_document_extraction["Document extraction<br/>[extract.py]"]
  node_retrieval["Chunk retrieval<br/>[retrieval.py]"]
  node_language_models["LLM services<br/>[llm.py]"]
  node_case_store[("Case data store<br/>[db_core.py]")]
  node_investigation_store[("Investigation store<br/>[db.py]")]
  node_tender_store[("Tender store<br/>[db.py]")]
end

node_investigator(("Investigator"))
node_tender_user(("Tendering user"))

node_investigator -.->|"uses"| node_case_app
node_case_app -->|"routes to"| node_case_workspace
node_case_workspace -->|"requests data"| node_case_api_client
node_case_api_client -.->|"calls API"| node_core_app
node_core_app -->|"mounts routes"| node_investigation_routes
node_investigation_routes -->|"authenticates"| node_auth
node_investigation_routes -->|"reads and writes"| node_investigation_store
node_investigation_routes -->|"schedules analysis"| node_case_analysis
node_case_analysis -->|"runs stage"| node_entity_resolution
node_case_analysis -->|"runs stage"| node_relationship_building
node_case_analysis -->|"runs stage"| node_anomaly_detection
node_case_analysis -->|"runs stage"| node_timeline_reconstruction
node_case_analysis -->|"runs stage"| node_case_summaries
node_case_analysis -->|"uses"| node_document_extraction
node_tender_user -.->|"uses"| node_tender_app
node_tender_app -->|"routes to"| node_tender_library
node_tender_library -->|"requests data"| node_tender_api_client
node_tender_api_client -.->|"calls API"| node_tender_routes
node_core_app -->|"mounts routes"| node_tender_routes
node_tender_routes -->|"authenticates"| node_auth
node_tender_routes -->|"reads and writes"| node_tender_store
node_tender_routes -->|"dispatches workflows"| node_tender_pipeline
node_tender_pipeline -.->|"includes stage"| node_readiness_review
node_tender_pipeline -.->|"includes stage"| node_tender_evidence
node_core_app -->|"uses"| node_case_store
node_retrieval -->|"queries chunks"| node_case_store
node_retrieval -->|"embeds queries"| node_language_models
node_readiness_review -->|"requests reasoning"| node_language_models
node_readiness_review -->|"reads data"| node_tender_store

click node_case_app "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/frontend/src/App.tsx"
click node_case_workspace "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/frontend/src/pages/CaseWorkspacePage.tsx"
click node_case_api_client "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/frontend/src/api.ts"
click node_tender_app "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/tendering-frontend/src/App.tsx"
click node_tender_library "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/tendering-frontend/src/pages/DocumentLibraryPage.tsx"
click node_tender_api_client "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/tendering-frontend/src/api/tenders.ts"
click node_core_app "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/main.py"
click node_auth "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/auth.py"
click node_investigation_routes "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/routes.py"
click node_case_analysis "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/__init__.py"
click node_entity_resolution "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/resolve_entities.py"
click node_relationship_building "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/build_relationships.py"
click node_anomaly_detection "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/detect_anomalies.py"
click node_timeline_reconstruction "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/reconstruct_timeline.py"
click node_case_summaries "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/summarise.py"
click node_tender_routes "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/routes.py"
click node_tender_pipeline "https://github.com/nextgenspark1/agentic-doc-intelligence/tree/main/backend/apps/tendering/pipeline"
click node_readiness_review "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/pipeline/readiness_review.py"
click node_tender_evidence "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/pipeline/evidence_matching.py"
click node_document_extraction "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/extract.py"
click node_retrieval "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/retrieval.py"
click node_language_models "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/llm.py"
click node_case_store "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/db_core.py"
click node_investigation_store "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/db.py"
click node_tender_store "https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/db.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_case_app,node_case_workspace,node_case_api_client,node_tender_app,node_tender_library,node_tender_api_client,node_tender_user toneBlue
class node_core_app,node_auth toneAmber
class node_investigation_routes,node_case_analysis,node_entity_resolution,node_relationship_building,node_anomaly_detection,node_timeline_reconstruction,node_case_summaries toneMint
class node_tender_routes,node_tender_pipeline,node_readiness_review,node_tender_evidence toneRose
class node_document_extraction,node_retrieval,node_language_models,node_case_store,node_investigation_store,node_tender_store,node_investigator toneIndigo
```

## Components

### User interfaces

- [Case application](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Case workspace](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/frontend/src/pages/CaseWorkspacePage.tsx): `frontend/src/pages/CaseWorkspacePage.tsx`
- [Case API client](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Tender application](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/tendering-frontend/src/App.tsx): `tendering-frontend/src/App.tsx`
- [Document library](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/tendering-frontend/src/pages/DocumentLibraryPage.tsx): `tendering-frontend/src/pages/DocumentLibraryPage.tsx`
- [Tender API client](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/tendering-frontend/src/api/tenders.ts): `tendering-frontend/src/api/tenders.ts`

### Shared backend

- [Core API](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/main.py): `backend/core/main.py`
- [JWT authentication](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/auth.py): `backend/core/auth.py`

### Investigations

- [Investigation routes](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/routes.py): `backend/apps/investigation/routes.py`
- [Case analysis](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/__init__.py): `backend/apps/investigation/pipeline/__init__.py`
- [Entity resolution](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/resolve_entities.py): `backend/apps/investigation/pipeline/resolve_entities.py`
- [Relationship building](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/build_relationships.py): `backend/apps/investigation/pipeline/build_relationships.py`
- [Anomaly detection](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/detect_anomalies.py): `backend/apps/investigation/pipeline/detect_anomalies.py`
- [Timeline reconstruction](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/reconstruct_timeline.py): `backend/apps/investigation/pipeline/reconstruct_timeline.py`
- [Case summaries](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/pipeline/summarise.py): `backend/apps/investigation/pipeline/summarise.py`

### Tendering

- [Tender routes](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/routes.py): `backend/apps/tendering/routes.py`
- [Tender workflows](https://github.com/nextgenspark1/agentic-doc-intelligence/tree/main/backend/apps/tendering/pipeline): `backend/apps/tendering/pipeline`
- [Readiness review](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/pipeline/readiness_review.py): `backend/apps/tendering/pipeline/readiness_review.py`
- [Evidence matching](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/pipeline/evidence_matching.py): `backend/apps/tendering/pipeline/evidence_matching.py`

### Data and AI

- [Document extraction](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/extract.py): `backend/core/extract.py`
- [Chunk retrieval](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/retrieval.py): `backend/core/retrieval.py`
- [LLM services](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/llm.py): `backend/core/llm.py`
- [Case data store](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/core/db_core.py): `backend/core/db_core.py`
- [Investigation store](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/investigation/db.py): `backend/apps/investigation/db.py`
- [Tender store](https://github.com/nextgenspark1/agentic-doc-intelligence/blob/main/backend/apps/tendering/db.py): `backend/apps/tendering/db.py`

### Other components

- **Investigator**
- **Tendering user**

## Connections

- Investigator → Case application: uses
- Case application → Case workspace: routes to (evidence: `frontend/src/App.tsx`)
- Case workspace → Case API client: requests data (evidence: `frontend/src/pages/CaseWorkspacePage.tsx`)
- Case API client → Core API: calls API
- Core API → Investigation routes: mounts routes (evidence: `backend/core/main.py`)
- Investigation routes → JWT authentication: authenticates (evidence: `backend/apps/investigation/routes.py`)
- Investigation routes → Investigation store: reads and writes (evidence: `backend/apps/investigation/routes.py`)
- Investigation routes → Case analysis: schedules analysis (evidence: `backend/apps/investigation/routes.py`)
- Case analysis → Entity resolution: runs stage (evidence: `backend/apps/investigation/pipeline/__init__.py`)
- Case analysis → Relationship building: runs stage (evidence: `backend/apps/investigation/pipeline/__init__.py`)
- Case analysis → Anomaly detection: runs stage (evidence: `backend/apps/investigation/pipeline/__init__.py`)
- Case analysis → Timeline reconstruction: runs stage (evidence: `backend/apps/investigation/pipeline/__init__.py`)
- Case analysis → Case summaries: runs stage (evidence: `backend/apps/investigation/pipeline/__init__.py`)
- Case analysis → Document extraction: uses (evidence: `backend/apps/investigation/pipeline/__init__.py`)
- Tendering user → Tender application: uses
- Tender application → Document library: routes to (evidence: `tendering-frontend/src/App.tsx`)
- Document library → Tender API client: requests data (evidence: `tendering-frontend/src/pages/DocumentLibraryPage.tsx`)
- Tender API client → Tender routes: calls API
- Core API → Tender routes: mounts routes (evidence: `backend/core/main.py`)
- Tender routes → JWT authentication: authenticates (evidence: `backend/apps/tendering/routes.py`)
- Tender routes → Tender store: reads and writes (evidence: `backend/apps/tendering/routes.py`)
- Tender routes → Tender workflows: dispatches workflows (evidence: `backend/apps/tendering/routes.py`)
- Tender workflows → Readiness review: includes stage
- Tender workflows → Evidence matching: includes stage
- Core API → Case data store: uses (evidence: `backend/core/main.py`)
- Chunk retrieval → Case data store: queries chunks (evidence: `backend/core/retrieval.py`)
- Chunk retrieval → LLM services: embeds queries (evidence: `backend/eval/retrievers.py`)
- Readiness review → LLM services: requests reasoning (evidence: `backend/apps/tendering/pipeline/readiness_review.py`)
- Readiness review → Tender store: reads data (evidence: `backend/apps/tendering/pipeline/readiness_review.py`)
