# benjaminarielkatani-eng/unilia-chatbot architecture

> Architecture diagram of the GitHub repository benjaminarielkatani-eng/unilia-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benjaminarielkatani-eng/unilia-chatbot
- Repository: https://github.com/benjaminarielkatani-eng/unilia-chatbot

## Overview

UNILIA AI Helpdesk is a student-facing university chatbot with document management and a FastAPI backend. The documented chat workflow accepts a question, finds or creates a session, stores the question, requests an answer through the AI service, saves the response and returns it; students can also retrieve session history. Staff can upload, list, update and soft-delete knowledge-base documents. The repository shows a placeholder AI response, while the README describes the RAG engine as in progress. The frontend and AI directories contain no implementation in the supplied tree, so their runtime connections remain unverified.

Main entry points: [`backend/database/database.py`](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/database/database.py) (Database access), [`backend/main.py`](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/main.py) (FastAPI application), [`backend/routers/chat.py`](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/routers/chat.py) (Chat API), [`backend/routers/documents.py`](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/routers/documents.py) (Document API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and workflows"]
  node_server["FastAPI application<br/>[main.py]"]
  node_health["Health endpoint<br/>[health.py]"]
  node_chatapi["Chat API<br/>[chat.py]"]
  node_chatschema["Chat schemas<br/>[chat.py]"]
end

subgraph group_knowledge["Knowledge management"]
  node_docapi["Document API<br/>[documents.py]"]
  node_docschema["Document schemas<br/>[document.py]"]
  node_docmodel["Document records<br/>[document.py]"]
  node_fileuploads["Uploaded files"]
end

subgraph group_chatdata["Chat and persistence"]
  node_sessions["Chat sessions<br/>[chat.py]"]
  node_users["User accounts<br/>[user.py]"]
  node_feedback["Answer feedback<br/>[feedback.py]"]
  node_dbaccess["Database access<br/>[database.py]"]
  node_database[("Application database")]
end

subgraph group_ai["Answer generation"]
  node_aiservice["AI service<br/>[ai_service.py]"]
  node_rag["RAG engine"]
end

node_student(("Student"))
node_staff(("Staff"))

node_student -->|"sends requests"| node_server
node_staff -->|"manages documents"| node_server
node_server -->|"registers"| node_health
node_server -->|"registers"| node_docapi
node_server -->|"registers"| node_chatapi
node_docapi -->|"queries and updates"| node_docmodel
node_docapi -->|"validates and returns"| node_docschema
node_docapi -->|"writes files"| node_fileuploads
node_chatapi -->|"validates and returns"| node_chatschema
node_chatapi -->|"reads and writes"| node_sessions
node_chatapi -->|"requests answer"| node_aiservice
node_aiservice -.->|"planned integration"| node_rag
node_aiservice -->|"returns answer"| node_chatapi
node_docapi -->|"uses sessions"| node_dbaccess
node_chatapi -->|"uses sessions"| node_dbaccess
node_dbaccess -->|"connects"| node_database
node_server -->|"creates tables"| node_dbaccess
node_sessions -->|"inherits base"| node_dbaccess
node_docmodel -->|"inherits base"| node_dbaccess
node_users -->|"inherits base"| node_dbaccess
node_feedback -->|"inherits base"| node_dbaccess

click node_server "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/main.py"
click node_health "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/routers/health.py"
click node_docapi "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/routers/documents.py"
click node_docschema "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/schemas/document.py"
click node_docmodel "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/models/document.py"
click node_fileuploads "https://github.com/benjaminarielkatani-eng/unilia-chatbot/tree/main/backend/uploads"
click node_chatapi "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/routers/chat.py"
click node_chatschema "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/schemas/chat.py"
click node_sessions "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/models/chat.py"
click node_users "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/models/user.py"
click node_feedback "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/models/feedback.py"
click node_dbaccess "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/database/database.py"
click node_aiservice "https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/services/ai_service.py"
click node_rag "https://github.com/benjaminarielkatani-eng/unilia-chatbot/tree/main/ai"

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_health,node_chatapi,node_chatschema toneBlue
class node_docapi,node_docschema,node_docmodel,node_fileuploads toneAmber
class node_sessions,node_users,node_feedback,node_dbaccess,node_database toneMint
class node_aiservice,node_rag toneRose
class node_student,node_staff toneIndigo
```

## Components

### API and workflows

- [FastAPI application](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/main.py): `backend/main.py`
- [Health endpoint](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/routers/health.py): `backend/routers/health.py`
- [Chat API](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/routers/chat.py): `backend/routers/chat.py`
- [Chat schemas](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/schemas/chat.py): `backend/schemas/chat.py`

### Knowledge management

- [Document API](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/routers/documents.py): `backend/routers/documents.py`
- [Document schemas](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/schemas/document.py): `backend/schemas/document.py`
- [Document records](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/models/document.py): `backend/models/document.py`
- [Uploaded files](https://github.com/benjaminarielkatani-eng/unilia-chatbot/tree/main/backend/uploads): `backend/uploads`

### Chat and persistence

- [Chat sessions](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/models/chat.py): `backend/models/chat.py`
- [User accounts](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/models/user.py): `backend/models/user.py`
- [Answer feedback](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/models/feedback.py): `backend/models/feedback.py`
- [Database access](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/database/database.py): `backend/database/database.py`
- **Application database**

### Answer generation

- [AI service](https://github.com/benjaminarielkatani-eng/unilia-chatbot/blob/main/backend/services/ai_service.py): `backend/services/ai_service.py`
- [RAG engine](https://github.com/benjaminarielkatani-eng/unilia-chatbot/tree/main/ai): `ai`

### Other components

- **Student**
- **Staff**

## Connections

- Student → FastAPI application: sends requests (evidence: `README.md`)
- Staff → FastAPI application: manages documents (evidence: `README.md`)
- FastAPI application → Health endpoint: registers (evidence: `backend/main.py`)
- FastAPI application → Document API: registers (evidence: `backend/main.py`)
- FastAPI application → Chat API: registers (evidence: `backend/main.py`)
- Document API → Document records: queries and updates (evidence: `backend/routers/documents.py`)
- Document API → Document schemas: validates and returns (evidence: `backend/routers/documents.py`)
- Document API → Uploaded files: writes files (evidence: `backend/routers/documents.py`)
- Chat API → Chat schemas: validates and returns (evidence: `backend/routers/chat.py`)
- Chat API → Chat sessions: reads and writes (evidence: `backend/routers/chat.py`)
- Chat API → AI service: requests answer (evidence: `backend/routers/chat.py`)
- AI service → RAG engine: planned integration
- AI service → Chat API: returns answer (evidence: `backend/routers/chat.py`)
- Document API → Database access: uses sessions (evidence: `backend/routers/documents.py`)
- Chat API → Database access: uses sessions (evidence: `backend/routers/chat.py`)
- Database access → Application database: connects (evidence: `backend/database/database.py`)
- FastAPI application → Database access: creates tables (evidence: `backend/main.py`)
- Chat sessions → Database access: inherits base (evidence: `backend/models/chat.py`)
- Document records → Database access: inherits base (evidence: `backend/models/document.py`)
- User accounts → Database access: inherits base (evidence: `backend/models/user.py`)
- Answer feedback → Database access: inherits base (evidence: `backend/models/feedback.py`)
