# truongvi-ute/student-information-assistant-ai-service architecture

> Architecture diagram of the GitHub repository truongvi-ute/student-information-assistant-ai-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/truongvi-ute/student-information-assistant-ai-service
- Repository: https://github.com/truongvi-ute/student-information-assistant-ai-service

## Overview

SIA AI Service exposes document ingestion, vector search, and cited RAG chat for a Student Information Assistant. The main workflow accepts supported files, extracts and chunks their text, embeds and stores the chunks in Qdrant, then embeds user queries, retrieves relevant chunks, and generates answers with citations. The README also documents CLI batch ingestion and collection statistics. Relationships are grounded in excerpts, the SOURCE INDEX, or README; inference details not shown in excerpts are limited to indexed references and documentation.

Main entry points: [`app/services/ingestion/pipeline.py`](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/pipeline.py) (Ingestion Pipeline), [`app/db/qdrant.py`](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/db/qdrant.py) (Qdrant Client Layer), [`app/main.py`](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/main.py) (FastAPI App), [`app/services/inference/generator.py`](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/inference/generator.py) (RAG Answer Generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Entrypoints"]
  node_server["FastAPI App<br/>[main.py]"]
  node_documents_api["Document Routes<br/>[documents.py]"]
  node_chat_api["Chat and Search Routes<br/>[chat.py]"]
  node_health_api["Health Routes<br/>[health.py]"]
  node_batch_cli["Batch Ingestion CLI<br/>[ingest.py]"]
end

subgraph group_ingestion["Document Ingestion"]
  node_loader["Document Loading<br/>[loader.py]"]
  node_converters["Format Converters<br/>[converters.py]"]
  node_chunker["Text Chunking<br/>[chunker.py]"]
  node_pipeline["Ingestion Pipeline<br/>[pipeline.py]"]
  node_document_schema["Document Models<br/>[document.py]"]
end

subgraph group_inference["RAG Inference"]
  node_retriever["Vector Retrieval<br/>[retriever.py]"]
  node_generator["RAG Answer Generation<br/>[generator.py]"]
  node_prompts["Prompt Templates<br/>[prompts.py]"]
  node_response_schema["Response Models<br/>[response.py]"]
end

subgraph group_platform["Vector and Models"]
  node_embedding["Embedding Service<br/>[embedding.py]"]
  node_qdrant_client["Qdrant Client Layer<br/>[qdrant.py]"]
end

node_user(("API Client"))
node_qdrant[("Qdrant Vector DB")]
node_gemini["Google Gemini"]

node_user -->|"sends requests"| node_server
node_server -->|"registers routes"| node_documents_api
node_server -->|"registers routes"| node_chat_api
node_server -->|"initializes collection"| node_qdrant_client
node_documents_api -->|"ingests uploads"| node_pipeline
node_documents_api -->|"reads statistics"| node_qdrant_client
node_batch_cli -->|"runs ingestion"| node_pipeline
node_pipeline -->|"loads files"| node_loader
node_loader -->|"converts formats"| node_converters
node_pipeline -->|"splits documents"| node_chunker
node_pipeline -->|"embeds chunks"| node_embedding
node_pipeline -->|"upserts vectors"| node_qdrant_client
node_qdrant_client -->|"manages collection"| node_qdrant
node_embedding -->|"requests embeddings"| node_gemini
node_chat_api -->|"searches chunks"| node_retriever
node_chat_api -->|"requests answers"| node_generator
node_retriever -->|"embeds query"| node_embedding
node_retriever -->|"queries vectors"| node_qdrant_client
node_generator -->|"retrieves context"| node_retriever
node_generator -->|"uses templates"| node_prompts
node_generator -.->|"generates answer"| node_gemini

click node_server "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/main.py"
click node_documents_api "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/api/v1/routers/documents.py"
click node_chat_api "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/api/v1/routers/chat.py"
click node_health_api "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/api/v1/routers/health.py"
click node_batch_cli "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/scripts/ingest.py"
click node_loader "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/loader.py"
click node_converters "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/converters.py"
click node_chunker "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/chunker.py"
click node_pipeline "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/pipeline.py"
click node_document_schema "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/schemas/document.py"
click node_embedding "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/embedding.py"
click node_retriever "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/inference/retriever.py"
click node_generator "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/inference/generator.py"
click node_prompts "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/inference/prompts.py"
click node_response_schema "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/schemas/response.py"
click node_qdrant_client "https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/db/qdrant.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_server,node_documents_api,node_chat_api,node_health_api,node_batch_cli,node_user toneBlue
class node_loader,node_converters,node_chunker,node_pipeline,node_document_schema,node_qdrant toneAmber
class node_retriever,node_generator,node_prompts,node_response_schema toneMint
class node_embedding,node_qdrant_client toneRose
class node_gemini toneIndigo
```

## Components

### API and Entrypoints

- [FastAPI App](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/main.py): `app/main.py`
- [Document Routes](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/api/v1/routers/documents.py): `app/api/v1/routers/documents.py`
- [Chat and Search Routes](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/api/v1/routers/chat.py): `app/api/v1/routers/chat.py`
- [Health Routes](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/api/v1/routers/health.py): `app/api/v1/routers/health.py`
- [Batch Ingestion CLI](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/scripts/ingest.py): `scripts/ingest.py`

### Document Ingestion

- [Document Loading](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/loader.py): `app/services/ingestion/loader.py`
- [Format Converters](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/converters.py): `app/services/ingestion/converters.py`
- [Text Chunking](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/chunker.py): `app/services/ingestion/chunker.py`
- [Ingestion Pipeline](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/ingestion/pipeline.py): `app/services/ingestion/pipeline.py`
- [Document Models](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/schemas/document.py): `app/schemas/document.py`

### RAG Inference

- [Vector Retrieval](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/inference/retriever.py): `app/services/inference/retriever.py`
- [RAG Answer Generation](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/inference/generator.py): `app/services/inference/generator.py`
- [Prompt Templates](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/inference/prompts.py): `app/services/inference/prompts.py`
- [Response Models](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/schemas/response.py): `app/schemas/response.py`

### Vector and Models

- [Embedding Service](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/services/embedding.py): `app/services/embedding.py`
- [Qdrant Client Layer](https://github.com/truongvi-ute/student-information-assistant-ai-service/blob/main/app/db/qdrant.py): `app/db/qdrant.py`

### Other components

- **API Client**
- **Qdrant Vector DB**
- **Google Gemini**

## Connections

- API Client → FastAPI App: sends requests (evidence: `README.md`)
- FastAPI App → Document Routes: registers routes (evidence: `app/main.py`)
- FastAPI App → Chat and Search Routes: registers routes (evidence: `app/main.py`)
- FastAPI App → Qdrant Client Layer: initializes collection (evidence: `app/main.py`)
- Document Routes → Ingestion Pipeline: ingests uploads (evidence: `app/api/v1/routers/documents.py`)
- Document Routes → Qdrant Client Layer: reads statistics (evidence: `app/api/v1/routers/documents.py`)
- Batch Ingestion CLI → Ingestion Pipeline: runs ingestion (evidence: `scripts/ingest.py`)
- Ingestion Pipeline → Document Loading: loads files (evidence: `app/services/ingestion/pipeline.py`)
- Document Loading → Format Converters: converts formats (evidence: `app/services/ingestion/loader.py`)
- Ingestion Pipeline → Text Chunking: splits documents (evidence: `app/services/ingestion/pipeline.py`)
- Ingestion Pipeline → Embedding Service: embeds chunks (evidence: `app/services/ingestion/pipeline.py`)
- Ingestion Pipeline → Qdrant Client Layer: upserts vectors (evidence: `app/services/ingestion/pipeline.py`)
- Qdrant Client Layer → Qdrant Vector DB: manages collection (evidence: `app/db/qdrant.py`)
- Embedding Service → Google Gemini: requests embeddings (evidence: `app/services/embedding.py`)
- Chat and Search Routes → Vector Retrieval: searches chunks (evidence: `app/api/v1/routers/chat.py`)
- Chat and Search Routes → RAG Answer Generation: requests answers (evidence: `app/api/v1/routers/chat.py`)
- Vector Retrieval → Embedding Service: embeds query (evidence: `app/services/inference/retriever.py`)
- Vector Retrieval → Qdrant Client Layer: queries vectors (evidence: `app/services/inference/retriever.py`)
- RAG Answer Generation → Vector Retrieval: retrieves context (evidence: `app/services/inference/generator.py`)
- RAG Answer Generation → Prompt Templates: uses templates (evidence: `app/services/inference/generator.py`)
- RAG Answer Generation → Google Gemini: generates answer
