# nareshmac2024/enterprise-it-support-agentic-rag-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot
- Repository: https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot

## Overview

This is an employee-facing enterprise IT support copilot: users ask questions, receive grounded answers with citations and a decision trace, and authorized staff can upload knowledge documents. The main runtime routes questions, checks private Pinecone evidence first, falls back to Tavily when needed, grades and may retry evidence, then generates an answer or reports insufficient evidence. Uploads are loaded and chunked before indexing; chat decisions are audited in SQLite. Workflow stages are shown separately although implemented in one module. The graph reflects excerpts and README statements; unsampled UI markup and integrations are not inferred beyond documented links.

Main entry points: [`app/api/routes.py`](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/api/routes.py) (Chat and ingest API), [`app/rag/workflow.py`](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py) (Question routing), [`static/js/app.js`](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/static/js/app.js) (Copilot web UI), [`app/services/audit.py`](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/services/audit.py) (Query audit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_webui["Copilot web UI<br/>[app.js]"]
  node_page["Web page<br/>[index.html]"]
end

subgraph group_api["API and services"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_routes["Chat and ingest API<br/>[routes.py]"]
  node_ingestion["Document loading and chunking<br/>[ingestion.py]"]
  node_audit[("Query audit<br/>[audit.py]")]
  node_settings["Application settings<br/>[config.py]"]
end

subgraph group_rag["Agentic RAG"]
  node_state["Workflow state and decisions<br/>[state.py]"]
  node_router["Question routing<br/>[workflow.py]"]
  node_private["Private KB retrieval<br/>[workflow.py]"]
  node_kbgrade["Private evidence grading<br/>[workflow.py]"]
  node_websearch["Web fallback search<br/>[workflow.py]"]
  node_webgrade["Web evidence grading<br/>[workflow.py]"]
  node_rewrite["Query rewrite and retry<br/>[workflow.py]"]
  node_answer["Answer generation<br/>[workflow.py]"]
end

subgraph group_integrations["Storage and providers"]
  node_vectorstore[("Pinecone vector store<br/>[vectorstore.py]")]
  node_llm{{"OpenAI language model"}}
  node_tavily{{"Tavily search"}}
  node_sqlite[("SQLite audit database<br/>[audit.db]")]
end

node_employee(("Employee / staff"))

node_employee -->|"asks / uploads"| node_webui
node_webui -.->|"uses page"| node_page
node_webui -->|"posts chat / ingest"| node_routes
node_fastapi -->|"mounts router"| node_routes
node_fastapi -->|"initializes audit"| node_audit
node_routes -->|"reads settings"| node_settings
node_routes -->|"calls ask"| node_router
node_routes -->|"writes chat trace"| node_audit
node_routes -->|"loads and chunks"| node_ingestion
node_routes -->|"indexes chunks"| node_vectorstore
node_router -->|"uses typed state"| node_state
node_router -->|"routes IT queries"| node_private
node_router -->|"answers direct chat"| node_answer
node_private -->|"retrieves chunks"| node_vectorstore
node_private -->|"grades retrieved evidence"| node_kbgrade
node_kbgrade -->|"uses sufficient KB"| node_answer
node_kbgrade -->|"falls back if weak"| node_websearch
node_websearch -->|"searches web"| node_tavily
node_websearch -->|"grades search results"| node_webgrade
node_webgrade -->|"uses sufficient web"| node_answer
node_webgrade -->|"rewrites if weak"| node_rewrite
node_rewrite -->|"retries private retrieval"| node_private
node_router -->|"routes with model"| node_llm
node_kbgrade -->|"grades with model"| node_llm
node_webgrade -->|"grades with model"| node_llm
node_rewrite -->|"rewrites with model"| node_llm
node_answer -->|"generates answer"| node_llm
node_vectorstore -->|"configures index"| node_settings
node_routes -->|"returns answer and trace"| node_webui
node_audit -->|"writes audit rows"| node_sqlite

click node_webui "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/static/js/app.js"
click node_page "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/templates/index.html"
click node_fastapi "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/main.py"
click node_routes "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/api/routes.py"
click node_ingestion "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/services/ingestion.py"
click node_audit "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/services/audit.py"
click node_settings "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/core/config.py"
click node_state "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/state.py"
click node_router "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py"
click node_private "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py"
click node_kbgrade "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py"
click node_websearch "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py"
click node_webgrade "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py"
click node_rewrite "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py"
click node_answer "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py"
click node_vectorstore "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/vectorstore.py"
click node_sqlite "https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/data/audit.db"

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_webui,node_page toneBlue
class node_fastapi,node_routes,node_ingestion,node_audit,node_settings toneAmber
class node_state,node_router,node_private,node_kbgrade,node_websearch,node_webgrade,node_rewrite,node_answer toneMint
class node_vectorstore,node_llm,node_tavily,node_sqlite toneRose
class node_employee toneIndigo
```

## Components

### User experience

- [Copilot web UI](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/static/js/app.js): `static/js/app.js`
- [Web page](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/templates/index.html): `templates/index.html`

### API and services

- [FastAPI app](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/main.py): `app/main.py`
- [Chat and ingest API](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/api/routes.py): `app/api/routes.py`
- [Document loading and chunking](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/services/ingestion.py): `app/services/ingestion.py`
- [Query audit](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/services/audit.py): `app/services/audit.py`
- [Application settings](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/core/config.py): `app/core/config.py`

### Agentic RAG

- [Workflow state and decisions](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/state.py): `app/rag/state.py`
- [Question routing](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Private KB retrieval](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Private evidence grading](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Web fallback search](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Web evidence grading](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Query rewrite and retry](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Answer generation](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/workflow.py): `app/rag/workflow.py`

### Storage and providers

- [Pinecone vector store](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/app/rag/vectorstore.py): `app/rag/vectorstore.py`
- **OpenAI language model**
- **Tavily search**
- [SQLite audit database](https://github.com/nareshmac2024/enterprise-it-support-agentic-rag-copilot/blob/main/data/audit.db): `data/audit.db`

### Other components

- **Employee / staff**

## Connections

- Employee / staff → Copilot web UI: asks / uploads (evidence: `README.md`)
- Copilot web UI → Web page: uses page
- Copilot web UI → Chat and ingest API: posts chat / ingest (evidence: `static/js/app.js`)
- FastAPI app → Chat and ingest API: mounts router (evidence: `app/main.py`)
- FastAPI app → Query audit: initializes audit (evidence: `app/main.py`)
- Chat and ingest API → Application settings: reads settings (evidence: `app/api/routes.py`)
- Chat and ingest API → Question routing: calls ask (evidence: `app/api/routes.py`)
- Chat and ingest API → Query audit: writes chat trace (evidence: `app/api/routes.py`)
- Chat and ingest API → Document loading and chunking: loads and chunks (evidence: `app/api/routes.py`)
- Chat and ingest API → Pinecone vector store: indexes chunks (evidence: `app/api/routes.py`)
- Question routing → Workflow state and decisions: uses typed state (evidence: `app/rag/workflow.py`)
- Question routing → Private KB retrieval: routes IT queries (evidence: `app/rag/workflow.py`)
- Question routing → Answer generation: answers direct chat (evidence: `app/rag/workflow.py`)
- Private KB retrieval → Pinecone vector store: retrieves chunks (evidence: `app/rag/workflow.py`)
- Private KB retrieval → Private evidence grading: grades retrieved evidence (evidence: `app/rag/workflow.py`)
- Private evidence grading → Answer generation: uses sufficient KB (evidence: `app/rag/workflow.py`)
- Private evidence grading → Web fallback search: falls back if weak (evidence: `app/rag/workflow.py`)
- Web fallback search → Tavily search: searches web (evidence: `app/rag/workflow.py`)
- Web fallback search → Web evidence grading: grades search results (evidence: `app/rag/workflow.py`)
- Web evidence grading → Answer generation: uses sufficient web (evidence: `app/rag/workflow.py`)
- Web evidence grading → Query rewrite and retry: rewrites if weak (evidence: `app/rag/workflow.py`)
- Query rewrite and retry → Private KB retrieval: retries private retrieval (evidence: `app/rag/workflow.py`)
- Question routing → OpenAI language model: routes with model (evidence: `app/rag/workflow.py`)
- Private evidence grading → OpenAI language model: grades with model (evidence: `app/rag/workflow.py`)
- Web evidence grading → OpenAI language model: grades with model (evidence: `app/rag/workflow.py`)
- Query rewrite and retry → OpenAI language model: rewrites with model (evidence: `app/rag/workflow.py`)
- Answer generation → OpenAI language model: generates answer (evidence: `app/rag/workflow.py`)
- Pinecone vector store → Application settings: configures index (evidence: `app/rag/vectorstore.py`)
- Chat and ingest API → Copilot web UI: returns answer and trace (evidence: `static/js/app.js`)
- Query audit → SQLite audit database: writes audit rows (evidence: `app/services/audit.py`)
