# manojvarmapenmetsa/ai architecture

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

- Interactive diagram: https://gitdiagram.com/manojvarmapenmetsa/ai
- Repository: https://github.com/manojvarmapenmetsa/ai

## Overview

This is an evidence-aware IT support copilot: a browser question reaches FastAPI, then the LangGraph workflow routes casual messages directly or grounds IT answers in the private knowledge base, falling back to web evidence and a bounded rewrite when needed. A separate authenticated upload flow parses and chunks documents before indexing them. The graph also shows answer/audit handling and the model, vector database, and web-search integrations. Workflow stages share one implementation file; their internal transitions are documented in that excerpt. Other connections are limited to shown calls or README statements.

Main entry points: [`app/api/routes.py`](https://github.com/manojvarmapenmetsa/ai/blob/main/app/api/routes.py) (API routes), [`app/rag/workflow.py`](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py) (Private KB retrieval), [`app/rag/vectorstore.py`](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/vectorstore.py) (Vector store), [`app/main.py`](https://github.com/manojvarmapenmetsa/ai/blob/main/app/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_browser["Chat interface<br/>[app.js]"]
  node_page["Chat page<br/>[index.html]"]
end

subgraph group_api["API and ingestion"]
  node_app["FastAPI app<br/>[main.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_fileproc["Document loader and chunker<br/>[ingestion.py]"]
end

subgraph group_workflow["RAG workflow"]
  node_router["Question routing<br/>[workflow.py]"]
  node_direct["Direct response<br/>[workflow.py]"]
  node_retrieval["Private KB retrieval<br/>[workflow.py]"]
  node_kbgrade["Private evidence grading<br/>[workflow.py]"]
  node_websearch["Web fallback<br/>[workflow.py]"]
  node_webgrade["Web evidence grading<br/>[workflow.py]"]
  node_rewrite["Query rewrite<br/>[workflow.py]"]
  node_answer["Answer generation<br/>[workflow.py]"]
  node_state["Workflow state<br/>[state.py]"]
end

subgraph group_data["Knowledge and audit"]
  node_vector["Vector store<br/>[vectorstore.py]"]
  node_audit[("Audit records<br/>[audit.py]")]
  node_kb["Company knowledge files"]
end

subgraph group_integrations["External services"]
  node_model["OpenRouter model"]
  node_pinecone[("Pinecone")]
  node_tavily["Tavily search"]
end

node_user(("Support user"))

node_user -->|"asks"| node_browser
node_browser -->|"posts chat"| node_routes
node_app -->|"renders"| node_page
node_app -->|"registers"| node_routes
node_routes -->|"calls ask"| node_router
node_router -->|"routes casual"| node_direct
node_router -->|"routes IT"| node_retrieval
node_retrieval -->|"grades evidence"| node_kbgrade
node_kbgrade -->|"uses good evidence"| node_answer
node_kbgrade -->|"falls back"| node_websearch
node_websearch -->|"grades results"| node_webgrade
node_webgrade -->|"uses good evidence"| node_answer
node_webgrade -->|"retries weak evidence"| node_rewrite
node_rewrite -->|"repeats retrieval"| node_retrieval
node_direct -->|"invokes"| node_model
node_answer -->|"invokes"| node_model
node_router -->|"classifies with"| node_model
node_rewrite -->|"rewrites with"| node_model
node_retrieval -->|"gets retriever"| node_vector
node_vector -->|"retrieves vectors"| node_pinecone
node_websearch -->|"searches with"| node_tavily
node_routes -->|"writes chat audit"| node_audit
node_app -->|"initializes"| node_audit
node_routes -->|"loads and chunks"| node_fileproc
node_routes -->|"adds chunks"| node_vector
node_fileproc -->|"provides chunks"| node_vector
node_vector -->|"indexes vectors"| node_pinecone
node_kb -->|"indexed from"| node_fileproc
node_retrieval -->|"reads and updates"| node_state
node_answer -->|"returns citations and trace"| node_browser

click node_browser "https://github.com/manojvarmapenmetsa/ai/blob/main/static/js/app.js"
click node_page "https://github.com/manojvarmapenmetsa/ai/blob/main/templates/index.html"
click node_app "https://github.com/manojvarmapenmetsa/ai/blob/main/app/main.py"
click node_routes "https://github.com/manojvarmapenmetsa/ai/blob/main/app/api/routes.py"
click node_fileproc "https://github.com/manojvarmapenmetsa/ai/blob/main/app/services/ingestion.py"
click node_router "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py"
click node_direct "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py"
click node_retrieval "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py"
click node_kbgrade "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py"
click node_websearch "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py"
click node_webgrade "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py"
click node_rewrite "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py"
click node_answer "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py"
click node_state "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/state.py"
click node_vector "https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/vectorstore.py"
click node_audit "https://github.com/manojvarmapenmetsa/ai/blob/main/app/services/audit.py"
click node_kb "https://github.com/manojvarmapenmetsa/ai/tree/main/data/sample_kb"

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_browser,node_page,node_user toneBlue
class node_app,node_routes,node_fileproc toneAmber
class node_router,node_direct,node_retrieval,node_kbgrade,node_websearch,node_webgrade,node_rewrite,node_answer,node_state toneMint
class node_vector,node_audit,node_kb toneRose
class node_model,node_pinecone,node_tavily toneIndigo
```

## Components

### Web experience

- [Chat interface](https://github.com/manojvarmapenmetsa/ai/blob/main/static/js/app.js): `static/js/app.js`
- [Chat page](https://github.com/manojvarmapenmetsa/ai/blob/main/templates/index.html): `templates/index.html`

### API and ingestion

- [FastAPI app](https://github.com/manojvarmapenmetsa/ai/blob/main/app/main.py): `app/main.py`
- [API routes](https://github.com/manojvarmapenmetsa/ai/blob/main/app/api/routes.py): `app/api/routes.py`
- [Document loader and chunker](https://github.com/manojvarmapenmetsa/ai/blob/main/app/services/ingestion.py): `app/services/ingestion.py`

### RAG workflow

- [Question routing](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Direct response](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Private KB retrieval](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Private evidence grading](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Web fallback](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Web evidence grading](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Query rewrite](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Answer generation](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/workflow.py): `app/rag/workflow.py`
- [Workflow state](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/state.py): `app/rag/state.py`

### Knowledge and audit

- [Vector store](https://github.com/manojvarmapenmetsa/ai/blob/main/app/rag/vectorstore.py): `app/rag/vectorstore.py`
- [Audit records](https://github.com/manojvarmapenmetsa/ai/blob/main/app/services/audit.py): `app/services/audit.py`
- [Company knowledge files](https://github.com/manojvarmapenmetsa/ai/tree/main/data/sample_kb): `data/sample_kb`

### External services

- **OpenRouter model**
- **Pinecone**
- **Tavily search**

### Other components

- **Support user**

## Connections

- Support user → Chat interface: asks (evidence: `README.md`)
- Chat interface → API routes: posts chat (evidence: `static/js/app.js`)
- FastAPI app → Chat page: renders (evidence: `README.md`)
- FastAPI app → API routes: registers (evidence: `app/main.py`)
- API routes → Question routing: calls ask (evidence: `app/api/routes.py`)
- Question routing → Direct response: routes casual (evidence: `app/rag/workflow.py`)
- Question routing → Private KB retrieval: routes IT (evidence: `app/rag/workflow.py`)
- Private KB retrieval → Private evidence grading: grades evidence (evidence: `app/rag/workflow.py`)
- Private evidence grading → Answer generation: uses good evidence (evidence: `app/rag/workflow.py`)
- Private evidence grading → Web fallback: falls back (evidence: `README.md`)
- Web fallback → Web evidence grading: grades results (evidence: `app/rag/workflow.py`)
- Web evidence grading → Answer generation: uses good evidence (evidence: `README.md`)
- Web evidence grading → Query rewrite: retries weak evidence (evidence: `app/rag/workflow.py`)
- Query rewrite → Private KB retrieval: repeats retrieval (evidence: `app/rag/workflow.py`)
- Direct response → OpenRouter model: invokes (evidence: `app/rag/workflow.py`)
- Answer generation → OpenRouter model: invokes (evidence: `app/rag/workflow.py`)
- Question routing → OpenRouter model: classifies with (evidence: `app/rag/workflow.py`)
- Query rewrite → OpenRouter model: rewrites with (evidence: `app/rag/workflow.py`)
- Private KB retrieval → Vector store: gets retriever (evidence: `app/rag/workflow.py`)
- Vector store → Pinecone: retrieves vectors (evidence: `app/rag/vectorstore.py`)
- Web fallback → Tavily search: searches with (evidence: `README.md`)
- API routes → Audit records: writes chat audit (evidence: `app/api/routes.py`)
- FastAPI app → Audit records: initializes (evidence: `app/main.py`)
- API routes → Document loader and chunker: loads and chunks (evidence: `app/api/routes.py`)
- API routes → Vector store: adds chunks (evidence: `app/api/routes.py`)
- Document loader and chunker → Vector store: provides chunks (evidence: `app/api/routes.py`)
- Vector store → Pinecone: indexes vectors (evidence: `app/rag/vectorstore.py`)
- Company knowledge files → Document loader and chunker: indexed from (evidence: `README.md`)
- Private KB retrieval → Workflow state: reads and updates (evidence: `app/rag/workflow.py`)
- Answer generation → Chat interface: returns citations and trace (evidence: `README.md`)
