# talha915/gen-ai-dice-final-project architecture

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

- Interactive diagram: https://gitdiagram.com/talha915/gen-ai-dice-final-project
- Repository: https://github.com/talha915/gen-ai-dice-final-project

## Overview

This is a natural-language chatbot for querying structured car data and uploaded documents. A user asks through the Streamlit chat UI, which posts to the FastAPI chatbot route; its LangGraph workflow routes database questions through SQL generation, execution, and answer formatting, or sends other questions to retrieval-augmented generation. Separately, users upload PDFs through the UI and ingestion route, which stores document chunks in Chroma for later retrieval. The graph includes the documented product branches; unsampled health-check and workflow details are not expanded.

Main entry points: [`server/app/api/chatbot.py`](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/api/chatbot.py) (Chat route and graph), [`server/app/core/kb_query.py`](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/kb_query.py) (RAG query engine), [`server/app/core/knowledge_base.py`](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/knowledge_base.py) (Document ingestion builder), [`client/main.py`](https://github.com/talha915/gen-ai-dice-final-project/blob/main/client/main.py) (Streamlit UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_streamlit["Streamlit UI<br/>[main.py]"]
end

subgraph group_api["API and routing"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_chat_route["Chat route and graph<br/>[chatbot.py]"]
  node_ingest_route["Ingestion route<br/>[ingestion.py]"]
  node_state_models["Graph state models<br/>[models.py]"]
end

subgraph group_database["Database agent"]
  node_db_agent["Database agent<br/>[db_agent.py]"]
  node_sqlite[("Car database<br/>[used_cars.db]")]
end

subgraph group_knowledge["Knowledge base"]
  node_kb_query["RAG query engine<br/>[kb_query.py]"]
  node_rag_builder["Document ingestion builder<br/>[knowledge_base.py]"]
  node_documents["Uploaded PDFs"]
  node_chroma[("Chroma vector store")]
end

node_user(("User"))
node_groq{{"Groq language model"}}
node_hf{{"HuggingFace embeddings"}}

node_user -->|"asks or uploads"| node_streamlit
node_streamlit -->|"posts query"| node_chat_route
node_streamlit -->|"posts file"| node_ingest_route
node_fastapi -->|"registers route"| node_chat_route
node_fastapi -->|"registers route"| node_ingest_route
node_chat_route -->|"uses state"| node_state_models
node_chat_route -->|"runs workflow"| node_db_agent
node_chat_route -->|"queries knowledge base"| node_kb_query
node_db_agent -->|"reads and writes"| node_sqlite
node_db_agent -->|"generates and summarizes"| node_groq
node_ingest_route -->|"builds index"| node_rag_builder
node_rag_builder -->|"loads PDFs"| node_documents
node_rag_builder -->|"stores chunks"| node_chroma
node_rag_builder -->|"embeds chunks"| node_hf
node_kb_query -->|"retrieves chunks"| node_chroma
node_kb_query -->|"embeds query"| node_hf
node_kb_query -->|"generates answer"| node_groq

click node_streamlit "https://github.com/talha915/gen-ai-dice-final-project/blob/main/client/main.py"
click node_fastapi "https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/main.py"
click node_chat_route "https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/api/chatbot.py"
click node_ingest_route "https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/api/ingestion.py"
click node_state_models "https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/models.py"
click node_db_agent "https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/db_agent.py"
click node_sqlite "https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/db/used_cars.db"
click node_kb_query "https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/kb_query.py"
click node_rag_builder "https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/knowledge_base.py"
click node_documents "https://github.com/talha915/gen-ai-dice-final-project/tree/main/server/app/documents"
click node_chroma "https://github.com/talha915/gen-ai-dice-final-project/tree/main/server/chroma_store"

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_streamlit,node_user toneBlue
class node_fastapi,node_chat_route,node_ingest_route,node_state_models toneAmber
class node_db_agent,node_sqlite toneMint
class node_kb_query,node_rag_builder,node_documents,node_chroma toneRose
class node_groq,node_hf toneIndigo
```

## Components

### Chat interface

- [Streamlit UI](https://github.com/talha915/gen-ai-dice-final-project/blob/main/client/main.py): `client/main.py`

### API and routing

- [FastAPI app](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/main.py): `server/app/main.py`
- [Chat route and graph](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/api/chatbot.py): `server/app/api/chatbot.py`
- [Ingestion route](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/api/ingestion.py): `server/app/api/ingestion.py`
- [Graph state models](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/models.py): `server/app/core/models.py`

### Database agent

- [Database agent](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/db_agent.py): `server/app/core/db_agent.py`
- [Car database](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/db/used_cars.db): `server/app/db/used_cars.db`

### Knowledge base

- [RAG query engine](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/kb_query.py): `server/app/core/kb_query.py`
- [Document ingestion builder](https://github.com/talha915/gen-ai-dice-final-project/blob/main/server/app/core/knowledge_base.py): `server/app/core/knowledge_base.py`
- [Uploaded PDFs](https://github.com/talha915/gen-ai-dice-final-project/tree/main/server/app/documents): `server/app/documents`
- [Chroma vector store](https://github.com/talha915/gen-ai-dice-final-project/tree/main/server/chroma_store): `server/chroma_store`

### Other components

- **User**
- **Groq language model**
- **HuggingFace embeddings**

## Connections

- User → Streamlit UI: asks or uploads (evidence: `README.md`)
- Streamlit UI → Chat route and graph: posts query (evidence: `client/main.py`)
- Streamlit UI → Ingestion route: posts file (evidence: `client/main.py`)
- FastAPI app → Chat route and graph: registers route (evidence: `server/app/main.py`)
- FastAPI app → Ingestion route: registers route (evidence: `server/app/main.py`)
- Chat route and graph → Graph state models: uses state (evidence: `server/app/api/chatbot.py`)
- Chat route and graph → Database agent: runs workflow (evidence: `server/app/api/chatbot.py`)
- Chat route and graph → RAG query engine: queries knowledge base (evidence: `server/app/api/chatbot.py`)
- Database agent → Car database: reads and writes (evidence: `server/app/core/db_agent.py`)
- Database agent → Groq language model: generates and summarizes (evidence: `server/app/core/db_agent.py`)
- Ingestion route → Document ingestion builder: builds index (evidence: `server/app/api/ingestion.py`)
- Document ingestion builder → Uploaded PDFs: loads PDFs (evidence: `server/app/core/knowledge_base.py`)
- Document ingestion builder → Chroma vector store: stores chunks (evidence: `server/app/core/knowledge_base.py`)
- Document ingestion builder → HuggingFace embeddings: embeds chunks (evidence: `server/app/core/knowledge_base.py`)
- RAG query engine → Chroma vector store: retrieves chunks (evidence: `server/app/core/kb_query.py`)
- RAG query engine → HuggingFace embeddings: embeds query (evidence: `server/app/core/kb_query.py`)
- RAG query engine → Groq language model: generates answer (evidence: `server/app/core/kb_query.py`)
