# nikhilreddy1011/campusfaq-rag architecture

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

- Interactive diagram: https://gitdiagram.com/nikhilreddy1011/campusfaq-rag
- Repository: https://github.com/nikhilreddy1011/campusfaq-rag

## Overview

This is a local campus FAQ helpdesk: administrators index campus documents, and students ask questions that receive grounded answers with citations or department referrals. The main runtime paths are documented in the README and partially visible in the excerpts; unsampled route details are represented only where the README or SOURCE INDEX supports them.

Main entry points: [`app/main.py`](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/main.py) (FastAPI routes), [`app/retriever.py`](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/retriever.py) (Semantic retrieval), [`app/answer_generator.py`](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/answer_generator.py) (Grounding and answer generation), [`app/embeddings.py`](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/embeddings.py) (Text embeddings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Helpdesk interface"]
  node_chat_ui["Chat interface<br/>[chat.js]"]
  node_admin_ui["Admin portal<br/>[admin.js]"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_templates["Page templates"]
end

subgraph group_ingest["Document indexing"]
  node_processor["Document extraction and chunking"]
  node_embedder["Text embeddings<br/>[embeddings.py]"]
end

subgraph group_search["Retrieval and answers"]
  node_retriever["Semantic retrieval<br/>[retriever.py]"]
  node_answer["Grounding and answer generation"]
end

subgraph group_data["Configuration and storage"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_database[("SQLite document and chunk store<br/>[database.py]")]
end

node_student(("Student"))
node_admin(("Administrator"))
node_ollama{{"Ollama LLM"}}

node_student -->|"asks question"| node_chat_ui
node_chat_ui -->|"posts query"| node_api
node_api -->|"retrieves chunks"| node_retriever
node_retriever -->|"embeds query"| node_embedder
node_retriever -->|"reads chunks"| node_database
node_api -->|"generates answer"| node_answer
node_answer -->|"requests synthesis"| node_ollama
node_answer -->|"returns citations or referral"| node_api
node_api -->|"renders pages"| node_templates
node_admin -->|"manages documents"| node_admin_ui
node_admin_ui -->|"calls admin routes"| node_api
node_api -->|"processes uploads"| node_processor
node_api -->|"embeds chunks"| node_embedder
node_api -->|"stores indexed chunks"| node_database
node_processor -->|"provides chunks"| node_embedder
node_embedder -->|"stores vectors"| node_database
node_database -->|"reads database path"| node_config
node_retriever -->|"uses thresholds"| node_config
node_processor -->|"uses chunk settings"| node_config
node_answer -->|"uses fallback settings"| node_config

click node_chat_ui "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/static/js/chat.js"
click node_admin_ui "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/static/js/admin.js"
click node_api "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/main.py"
click node_templates "https://github.com/nikhilreddy1011/campusfaq-rag/tree/main/app/templates"
click node_processor "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/document_processor.py"
click node_embedder "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/embeddings.py"
click node_retriever "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/retriever.py"
click node_answer "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/answer_generator.py"
click node_config "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/config.py"
click node_database "https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/database.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_chat_ui,node_admin_ui,node_api,node_templates toneBlue
class node_processor,node_embedder toneAmber
class node_retriever,node_answer toneMint
class node_config,node_database toneRose
class node_student,node_admin,node_ollama toneIndigo
```

## Components

### Helpdesk interface

- [Chat interface](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/static/js/chat.js): `app/static/js/chat.js`
- [Admin portal](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/static/js/admin.js): `app/static/js/admin.js`
- [FastAPI routes](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/main.py): `app/main.py`
- [Page templates](https://github.com/nikhilreddy1011/campusfaq-rag/tree/main/app/templates): `app/templates`

### Document indexing

- [Document extraction and chunking](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/document_processor.py): `app/document_processor.py`
- [Text embeddings](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/embeddings.py): `app/embeddings.py`

### Retrieval and answers

- [Semantic retrieval](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/retriever.py): `app/retriever.py`
- [Grounding and answer generation](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/answer_generator.py): `app/answer_generator.py`

### Configuration and storage

- [Runtime configuration](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/config.py): `app/config.py`
- [SQLite document and chunk store](https://github.com/nikhilreddy1011/campusfaq-rag/blob/main/app/database.py): `app/database.py`

### Other components

- **Student**
- **Administrator**
- **Ollama LLM**

## Connections

- Student → Chat interface: asks question (evidence: `README.md`)
- Chat interface → FastAPI routes: posts query (evidence: `app/static/js/chat.js`)
- FastAPI routes → Semantic retrieval: retrieves chunks (evidence: `app/main.py`)
- Semantic retrieval → Text embeddings: embeds query (evidence: `app/retriever.py`)
- Semantic retrieval → SQLite document and chunk store: reads chunks (evidence: `app/retriever.py`)
- FastAPI routes → Grounding and answer generation: generates answer (evidence: `app/main.py`)
- Grounding and answer generation → Ollama LLM: requests synthesis (evidence: `app/answer_generator.py`)
- Grounding and answer generation → FastAPI routes: returns citations or referral (evidence: `README.md`)
- FastAPI routes → Page templates: renders pages (evidence: `app/main.py`)
- Administrator → Admin portal: manages documents (evidence: `README.md`)
- Admin portal → FastAPI routes: calls admin routes (evidence: `app/static/js/admin.js`)
- FastAPI routes → Document extraction and chunking: processes uploads (evidence: `README.md`)
- FastAPI routes → Text embeddings: embeds chunks (evidence: `README.md`)
- FastAPI routes → SQLite document and chunk store: stores indexed chunks (evidence: `app/database.py`)
- Document extraction and chunking → Text embeddings: provides chunks (evidence: `README.md`)
- Text embeddings → SQLite document and chunk store: stores vectors (evidence: `README.md`)
- SQLite document and chunk store → Runtime configuration: reads database path (evidence: `app/database.py`)
- Semantic retrieval → Runtime configuration: uses thresholds (evidence: `app/retriever.py`)
- Document extraction and chunking → Runtime configuration: uses chunk settings (evidence: `app/document_processor.py`)
- Grounding and answer generation → Runtime configuration: uses fallback settings (evidence: `app/answer_generator.py`)
