# mirajul100/agentic-rag-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/mirajul100/agentic-rag-copilot
- Repository: https://github.com/mirajul100/agentic-rag-copilot

## Overview

Agentic RAG Copilot is a FastAPI document-grounded chat application. A browser submits a question and conversation ID; the API loads recent history, then the workflow supervisor chooses direct response, private knowledge retrieval, public search, or both, before returning an evidence-based answer and citations. A separate upload workflow parses and chunks documents before indexing them. SQLite stores conversation turns and audit records; Pinecone holds searchable document vectors. The README documents streaming, follow-ups, and optional web search; unsampled workflow sections limit finer-grained call links.

Main entry points: [`app/api/routes.py`](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/api/routes.py) (API routes), [`app/rag/work_flow.py`](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py) (Route supervisor), [`app/rag/vector_store.py`](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/vector_store.py) (Vector store), [`app/core/config.py`](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/core/config.py) (App settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App and API"]
  node_app["FastAPI app<br/>[main.py]"]
  node_api["API routes<br/>[routes.py]"]
end

subgraph group_workflow["Question workflow"]
  node_supervisor["Route supervisor<br/>[work_flow.py]"]
  node_retrieval["KB retrieval<br/>[work_flow.py]"]
  node_websearch["Web search<br/>[work_flow.py]"]
  node_answer["Answer generation<br/>[work_flow.py]"]
  node_workflowstate["Workflow state<br/>[state.py]"]
end

subgraph group_knowledge["Knowledge ingestion"]
  node_ingest["Document ingestion<br/>[ingestion.py]"]
  node_vectors[("Vector store<br/>[vector_store.py]")]
end

subgraph group_state["Persistence and settings"]
  node_memory[("Conversation memory<br/>[memory.py]")]
  node_audit[("Audit records<br/>[audit.py]")]
  node_settings["App settings<br/>[config.py]"]
  node_logging["Logging config<br/>[logging.py]"]
end

node_browser["Browser chat<br/>[app.js]"]
node_user(("User"))
node_gemini{{"Gemini"}}
node_pinecone[("Pinecone")]
node_tavily{{"Tavily"}}
node_sqlite[("SQLite database")]

node_user -->|"asks"| node_browser
node_browser -->|"submits chat"| node_api
node_app -->|"mounts routes"| node_api
node_api -->|"asks"| node_supervisor
node_api -->|"loads and saves"| node_memory
node_api -->|"writes records"| node_audit
node_supervisor -->|"routes KB"| node_retrieval
node_supervisor -->|"routes web"| node_websearch
node_supervisor -->|"routes direct"| node_answer
node_retrieval -->|"retrieves chunks"| node_vectors
node_websearch -->|"searches web"| node_tavily
node_answer -->|"generates answer"| node_gemini
node_supervisor -->|"selects route"| node_gemini
node_supervisor -->|"updates state"| node_workflowstate
node_api -->|"loads and splits"| node_ingest
node_api -->|"indexes chunks"| node_vectors
node_ingest -->|"provides chunks"| node_vectors
node_vectors -->|"embeds text"| node_gemini
node_vectors -->|"stores vectors"| node_pinecone
node_memory -->|"reads and writes"| node_sqlite
node_audit -->|"writes records"| node_sqlite
node_app -->|"initializes database"| node_audit
node_api -->|"reads settings"| node_settings
node_vectors -->|"reads settings"| node_settings
node_memory -->|"reads database path"| node_settings
node_audit -->|"reads database path"| node_settings
node_app -->|"reads app name"| node_settings
node_api -->|"uses logger"| node_logging

click node_browser "https://github.com/mirajul100/agentic-rag-copilot/blob/main/static/app.js"
click node_app "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/main.py"
click node_api "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/api/routes.py"
click node_supervisor "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py"
click node_retrieval "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py"
click node_websearch "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py"
click node_answer "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py"
click node_workflowstate "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/state.py"
click node_ingest "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/services/ingestion.py"
click node_vectors "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/vector_store.py"
click node_memory "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/memory.py"
click node_audit "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/services/audit.py"
click node_settings "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/core/config.py"
click node_logging "https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/core/logging.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_app,node_api,node_browser,node_user toneBlue
class node_supervisor,node_retrieval,node_websearch,node_answer,node_workflowstate,node_pinecone,node_sqlite toneAmber
class node_ingest,node_vectors toneMint
class node_memory,node_audit,node_settings,node_logging toneRose
class node_gemini,node_tavily toneIndigo
```

## Components

### App and API

- [FastAPI app](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/main.py): `app/main.py`
- [API routes](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/api/routes.py): `app/api/routes.py`

### Question workflow

- [Route supervisor](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py): `app/rag/work_flow.py`
- [KB retrieval](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py): `app/rag/work_flow.py`
- [Web search](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py): `app/rag/work_flow.py`
- [Answer generation](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/work_flow.py): `app/rag/work_flow.py`
- [Workflow state](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/state.py): `app/rag/state.py`

### Knowledge ingestion

- [Document ingestion](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/services/ingestion.py): `app/services/ingestion.py`
- [Vector store](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/vector_store.py): `app/rag/vector_store.py`

### Persistence and settings

- [Conversation memory](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/rag/memory.py): `app/rag/memory.py`
- [Audit records](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/services/audit.py): `app/services/audit.py`
- [App settings](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/core/config.py): `app/core/config.py`
- [Logging config](https://github.com/mirajul100/agentic-rag-copilot/blob/main/app/core/logging.py): `app/core/logging.py`

### Other components

- [Browser chat](https://github.com/mirajul100/agentic-rag-copilot/blob/main/static/app.js): `static/app.js`
- **User**
- **Gemini**
- **Pinecone**
- **Tavily**
- **SQLite database**

## Connections

- User → Browser chat: asks (evidence: `README.md`)
- Browser chat → API routes: submits chat (evidence: `README.md`)
- FastAPI app → API routes: mounts routes (evidence: `app/main.py`)
- API routes → Route supervisor: asks (evidence: `app/api/routes.py`)
- API routes → Conversation memory: loads and saves (evidence: `app/api/routes.py`)
- API routes → Audit records: writes records (evidence: `app/api/routes.py`)
- Route supervisor → KB retrieval: routes KB (evidence: `README.md`)
- Route supervisor → Web search: routes web (evidence: `README.md`)
- Route supervisor → Answer generation: routes direct (evidence: `README.md`)
- KB retrieval → Vector store: retrieves chunks (evidence: `README.md`)
- Web search → Tavily: searches web (evidence: `README.md`)
- Answer generation → Gemini: generates answer (evidence: `README.md`)
- Route supervisor → Gemini: selects route (evidence: `app/rag/work_flow.py`)
- Route supervisor → Workflow state: updates state (evidence: `app/rag/work_flow.py`)
- API routes → Document ingestion: loads and splits (evidence: `app/api/routes.py`)
- API routes → Vector store: indexes chunks (evidence: `app/api/routes.py`)
- Document ingestion → Vector store: provides chunks (evidence: `README.md`)
- Vector store → Gemini: embeds text (evidence: `app/rag/vector_store.py`)
- Vector store → Pinecone: stores vectors (evidence: `app/rag/vector_store.py`)
- Conversation memory → SQLite database: reads and writes (evidence: `app/rag/memory.py`)
- Audit records → SQLite database: writes records (evidence: `app/services/audit.py`)
- FastAPI app → Audit records: initializes database (evidence: `app/main.py`)
- API routes → App settings: reads settings (evidence: `app/api/routes.py`)
- Vector store → App settings: reads settings (evidence: `app/rag/vector_store.py`)
- Conversation memory → App settings: reads database path (evidence: `app/rag/memory.py`)
- Audit records → App settings: reads database path (evidence: `app/services/audit.py`)
- FastAPI app → App settings: reads app name (evidence: `app/main.py`)
- API routes → Logging config: uses logger (evidence: `app/api/routes.py`)
