# rishi-raj-anand/veridoc architecture

> Architecture diagram of the GitHub repository rishi-raj-anand/veridoc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rishi-raj-anand/veridoc
- Repository: https://github.com/rishi-raj-anand/veridoc

## Overview

VeriDoc AI is a local medical-document question-answering product with a React client, a FastAPI application backend, and a separate FastAPI AI service. Users sign in, ask questions, and receive document-grounded answers with citations; admins upload and manage reference documents and tune assistant behavior. The AI service parses and indexes uploads, then applies safety and intent routing before retrieval, generation, and verification with escalating search. The README documents the service boundaries; several detailed links within unsampled subsystems are therefore omitted or left unverified.

Main entry points: [`frontend/src/App.tsx`](https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/App.tsx) (React application), [`backend/app/main.py`](https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/main.py) (HTTP application), [`ai/ai_service/graph/pipeline.py`](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/graph/pipeline.py) (Agent state graph), [`ai/ai_service/ingestion/indexer.py`](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/ingestion/indexer.py) (Document indexing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_web["React application<br/>[App.tsx]"]
  node_clientapi["Typed API client<br/>[client.ts]"]
  node_authstate["Auth context<br/>[AuthContext.tsx]"]
  node_chatui["Chat experience<br/>[ChatPage.tsx]"]
  node_adminui["Admin pages<br/>[AdminPage.tsx]"]
end

subgraph group_backend["Application backend"]
  node_backendapp["HTTP application<br/>[main.py]"]
  node_authroutes["Authentication routes<br/>[auth.py]"]
  node_authservice["Auth service<br/>[auth_service.py]"]
  node_chatroutes["Chat routes<br/>[chat.py]"]
  node_chatservice["Chat service<br/>[chat_service.py]"]
  node_documents["Document management"]
  node_db[("Application database<br/>[db.py]")]
end

subgraph group_ai["AI service"]
  node_airoutes["AI HTTP routes<br/>[chat.py]"]
  node_runtime["AI runtime<br/>[runtime.py]"]
  node_pipeline["Agent state graph<br/>[pipeline.py]"]
  node_agents["Safety and agents"]
  node_memory[("Session memory<br/>[chat_store.py]")]
  node_ollamaclient["Ollama client<br/>[ollama_client.py]"]
end

subgraph group_knowledge["Knowledge pipeline"]
  node_ingestroute["Ingest endpoint<br/>[ingest.py]"]
  node_indexer["Document indexing<br/>[indexer.py]"]
  node_parsers["File parsers<br/>[parsers.py]"]
  node_retriever["Escalating retrieval<br/>[retriever.py]"]
  node_vectors[("Vector store<br/>[vector_store.py]")]
  node_docstore[("Parent docstore<br/>[docstore.py]")]
end

subgraph group_models["Local models"]
  node_ollama["Ollama models"]
end

node_user(("User"))
node_admin(("Administrator"))

node_user -->|"uses"| node_web
node_admin -->|"uses"| node_web
node_web -->|"calls"| node_clientapi
node_web -->|"initializes"| node_authstate
node_authstate -->|"provides token"| node_clientapi
node_web -->|"routes to"| node_chatui
node_web -->|"routes to"| node_adminui
node_clientapi -->|"HTTP requests"| node_backendapp
node_backendapp -->|"registers"| node_authroutes
node_backendapp -->|"registers"| node_chatroutes
node_authroutes -->|"uses"| node_authservice
node_authservice -->|"queries users"| node_db
node_backendapp -->|"configures"| node_db
node_chatroutes -.->|"delegates"| node_chatservice
node_chatservice -.->|"calls AI service"| node_airoutes
node_backendapp -->|"owns uploads"| node_documents
node_documents -.->|"requests indexing"| node_ingestroute
node_ingestroute -->|"runs indexing"| node_indexer
node_indexer -.->|"parses files"| node_parsers
node_airoutes -.->|"dispatches query"| node_runtime
node_runtime -->|"builds graph"| node_pipeline
node_pipeline -->|"invokes stages"| node_agents
node_pipeline -->|"retrieves context"| node_retriever
node_pipeline -->|"uses history"| node_memory
node_retriever -->|"searches"| node_vectors
node_retriever -->|"loads parents"| node_docstore
node_indexer -.->|"writes embeddings"| node_vectors
node_indexer -.->|"stores parents"| node_docstore
node_ollamaclient -->|"calls"| node_ollama
node_retriever -->|"embeds queries"| node_ollamaclient
node_agents -->|"uses models"| node_ollamaclient

click node_web "https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/App.tsx"
click node_clientapi "https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/api/client.ts"
click node_authstate "https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/context/AuthContext.tsx"
click node_chatui "https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/pages/ChatPage.tsx"
click node_adminui "https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/pages/AdminPage.tsx"
click node_backendapp "https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/routers/auth.py"
click node_authservice "https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/services/auth_service.py"
click node_chatroutes "https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/routers/chat.py"
click node_chatservice "https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/services/chat_service.py"
click node_documents "https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/services/document_service.py"
click node_db "https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/db.py"
click node_airoutes "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/routers/chat.py"
click node_runtime "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/runtime.py"
click node_pipeline "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/graph/pipeline.py"
click node_agents "https://github.com/rishi-raj-anand/veridoc/tree/main/ai/ai_service/agents"
click node_memory "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/memory/chat_store.py"
click node_ingestroute "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/routers/ingest.py"
click node_indexer "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/ingestion/indexer.py"
click node_parsers "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/ingestion/parsers.py"
click node_retriever "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/retrieval/retriever.py"
click node_vectors "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/retrieval/vector_store.py"
click node_docstore "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/retrieval/docstore.py"
click node_ollamaclient "https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/llm/ollama_client.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_web,node_clientapi,node_authstate,node_chatui,node_adminui,node_user toneBlue
class node_backendapp,node_authroutes,node_authservice,node_chatroutes,node_chatservice,node_documents,node_db toneAmber
class node_airoutes,node_runtime,node_pipeline,node_agents,node_memory,node_ollamaclient toneMint
class node_ingestroute,node_indexer,node_parsers,node_retriever,node_vectors,node_docstore toneRose
class node_ollama,node_admin toneIndigo
```

## Components

### User interface

- [React application](https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Typed API client](https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Auth context](https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Chat experience](https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/pages/ChatPage.tsx): `frontend/src/pages/ChatPage.tsx`
- [Admin pages](https://github.com/rishi-raj-anand/veridoc/blob/main/frontend/src/pages/AdminPage.tsx): `frontend/src/pages/AdminPage.tsx`

### Application backend

- [HTTP application](https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Auth service](https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [Chat routes](https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/routers/chat.py): `backend/app/routers/chat.py`
- [Chat service](https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`
- [Document management](https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/services/document_service.py): `backend/app/services/document_service.py`
- [Application database](https://github.com/rishi-raj-anand/veridoc/blob/main/backend/app/db.py): `backend/app/db.py`

### AI service

- [AI HTTP routes](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/routers/chat.py): `ai/ai_service/routers/chat.py`
- [AI runtime](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/runtime.py): `ai/ai_service/runtime.py`
- [Agent state graph](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/graph/pipeline.py): `ai/ai_service/graph/pipeline.py`
- [Safety and agents](https://github.com/rishi-raj-anand/veridoc/tree/main/ai/ai_service/agents): `ai/ai_service/agents`
- [Session memory](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/memory/chat_store.py): `ai/ai_service/memory/chat_store.py`
- [Ollama client](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/llm/ollama_client.py): `ai/ai_service/llm/ollama_client.py`

### Knowledge pipeline

- [Ingest endpoint](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/routers/ingest.py): `ai/ai_service/routers/ingest.py`
- [Document indexing](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/ingestion/indexer.py): `ai/ai_service/ingestion/indexer.py`
- [File parsers](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/ingestion/parsers.py): `ai/ai_service/ingestion/parsers.py`
- [Escalating retrieval](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/retrieval/retriever.py): `ai/ai_service/retrieval/retriever.py`
- [Vector store](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/retrieval/vector_store.py): `ai/ai_service/retrieval/vector_store.py`
- [Parent docstore](https://github.com/rishi-raj-anand/veridoc/blob/main/ai/ai_service/retrieval/docstore.py): `ai/ai_service/retrieval/docstore.py`

### Local models

- **Ollama models**

### Other components

- **User**
- **Administrator**

## Connections

- User → React application: uses (evidence: `README.md`)
- Administrator → React application: uses (evidence: `README.md`)
- React application → Typed API client: calls (evidence: `frontend/src/api/client.ts`)
- React application → Auth context: initializes (evidence: `frontend/src/main.tsx`)
- Auth context → Typed API client: provides token (evidence: `frontend/src/api/client.ts`)
- React application → Chat experience: routes to (evidence: `frontend/src/App.tsx`)
- React application → Admin pages: routes to (evidence: `frontend/src/App.tsx`)
- Typed API client → HTTP application: HTTP requests (evidence: `README.md`)
- HTTP application → Authentication routes: registers (evidence: `backend/app/main.py`)
- HTTP application → Chat routes: registers (evidence: `backend/app/main.py`)
- Authentication routes → Auth service: uses (evidence: `backend/app/routers/auth.py`)
- Auth service → Application database: queries users
- HTTP application → Application database: configures (evidence: `backend/app/main.py`)
- Chat routes → Chat service: delegates
- Chat service → AI HTTP routes: calls AI service (evidence: `README.md`)
- HTTP application → Document management: owns uploads (evidence: `backend/app/main.py`)
- Document management → Ingest endpoint: requests indexing (evidence: `README.md`)
- Ingest endpoint → Document indexing: runs indexing (evidence: `ai/ai_service/routers/ingest.py`)
- Document indexing → File parsers: parses files
- AI HTTP routes → AI runtime: dispatches query
- AI runtime → Agent state graph: builds graph (evidence: `ai/ai_service/runtime.py`)
- Agent state graph → Safety and agents: invokes stages (evidence: `ai/ai_service/graph/pipeline.py`)
- Agent state graph → Escalating retrieval: retrieves context (evidence: `ai/ai_service/graph/pipeline.py`)
- Agent state graph → Session memory: uses history (evidence: `ai/ai_service/graph/pipeline.py`)
- Escalating retrieval → Vector store: searches (evidence: `ai/ai_service/retrieval/retriever.py`)
- Escalating retrieval → Parent docstore: loads parents (evidence: `ai/ai_service/retrieval/retriever.py`)
- Document indexing → Vector store: writes embeddings (evidence: `README.md`)
- Document indexing → Parent docstore: stores parents (evidence: `README.md`)
- Ollama client → Ollama models: calls (evidence: `ai/ai_service/llm/ollama_client.py`)
- Escalating retrieval → Ollama client: embeds queries (evidence: `ai/ai_service/retrieval/retriever.py`)
- Safety and agents → Ollama client: uses models (evidence: `ai/ai_service/agents/verifier.py`)
