# haseebahsan-n/hostelcare-ai-agent architecture

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

- Interactive diagram: https://gitdiagram.com/haseebahsan-n/hostelcare-ai-agent
- Repository: https://github.com/haseebahsan-n/hostelcare-ai-agent

## Overview

HostelCare AI is a Streamlit complaint-management application. Students sign in, describe an issue conversationally, review and confirm a structured ticket, then track it; staff inspect tickets, resolve or escalate them, and review reporting. Gemini assists with complaint understanding, while routing rules assign authority and handle escalation. SQLite stores accounts, complaints, and history. The README documents several workflows not fully shown in the excerpts; those links are cited to the README rather than implying the unsampled implementation was inspected.

Main entry points: [`app.py`](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py) (Streamlit application), [`database.py`](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/database.py) (Database operations), [`routing.py`](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/routing.py) (Manual and timed escalation), [`agent.py`](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/agent.py) (Conversational complaint agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Application experience"]
  node_app["Streamlit application<br/>[app.py]"]
  node_identity["Sign-in and registration<br/>[app.py]"]
  node_complaint_chat["Complaint conversation<br/>[app.py]"]
  node_ticket_review["Ticket confirmation<br/>[app.py]"]
  node_ticket_tracking["Ticket tracking<br/>[app.py]"]
  node_staff_dashboard["Staff dashboard<br/>[app.py]"]
  node_analytics["Analytics and export<br/>[app.py]"]
end

subgraph group_intelligence["Complaint intelligence"]
  node_agent["Conversational complaint agent<br/>[agent.py]"]
  node_gemini["Google Gemini"]
end

subgraph group_operations["Routing and escalation"]
  node_routing["Initial complaint routing<br/>[routing.py]"]
  node_escalation["Manual and timed escalation<br/>[routing.py]"]
end

subgraph group_persistence["Persistence and history"]
  node_database["Database operations<br/>[database.py]"]
  node_schema["SQLite schema<br/>[schema.sql]"]
  node_sqlite[("SQLite database")]
  node_history["Complaint and action history<br/>[database.py]"]
end

node_students(("Students"))
node_staff(("Warden and staff"))

node_students -->|"use application"| node_app
node_staff -->|"manage complaints"| node_app
node_app -->|"presents"| node_identity
node_app -->|"presents"| node_complaint_chat
node_app -->|"presents"| node_ticket_review
node_app -->|"presents"| node_ticket_tracking
node_app -->|"presents"| node_staff_dashboard
node_app -->|"presents"| node_analytics
node_identity -->|"checks and registers"| node_database
node_complaint_chat -->|"sends conversation"| node_agent
node_agent -->|"requests parsing"| node_gemini
node_agent -->|"requests assignment"| node_routing
node_ticket_review -->|"creates ticket"| node_database
node_ticket_tracking -->|"reads tickets"| node_database
node_staff_dashboard -->|"updates complaints"| node_database
node_staff_dashboard -->|"requests escalation"| node_escalation
node_analytics -->|"reads records"| node_database
node_analytics -->|"exports filtered CSV"| node_students
node_app -->|"checks on execution"| node_escalation
node_escalation -->|"loads and updates tickets"| node_database
node_escalation -->|"records actions"| node_history
node_database -->|"initializes from"| node_schema
node_database -->|"reads and writes"| node_sqlite
node_database -->|"records updates and logs"| node_history

click node_app "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py"
click node_identity "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py"
click node_complaint_chat "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py"
click node_ticket_review "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py"
click node_ticket_tracking "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py"
click node_staff_dashboard "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py"
click node_analytics "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py"
click node_agent "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/agent.py"
click node_routing "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/routing.py"
click node_escalation "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/routing.py"
click node_database "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/database.py"
click node_schema "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/schema.sql"
click node_history "https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/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_app,node_identity,node_complaint_chat,node_ticket_review,node_ticket_tracking,node_staff_dashboard,node_analytics toneBlue
class node_agent,node_gemini toneAmber
class node_routing,node_escalation toneMint
class node_database,node_schema,node_sqlite,node_history toneRose
class node_students,node_staff toneIndigo
```

## Components

### Application experience

- [Streamlit application](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py): `app.py`
- [Sign-in and registration](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py): `app.py`
- [Complaint conversation](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py): `app.py`
- [Ticket confirmation](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py): `app.py`
- [Ticket tracking](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py): `app.py`
- [Staff dashboard](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py): `app.py`
- [Analytics and export](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/app.py): `app.py`

### Complaint intelligence

- [Conversational complaint agent](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/agent.py): `agent.py`
- **Google Gemini**

### Routing and escalation

- [Initial complaint routing](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/routing.py): `routing.py`
- [Manual and timed escalation](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/routing.py): `routing.py`

### Persistence and history

- [Database operations](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/database.py): `database.py`
- [SQLite schema](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/schema.sql): `schema.sql`
- **SQLite database**
- [Complaint and action history](https://github.com/haseebahsan-n/hostelcare-ai-agent/blob/main/database.py): `database.py`

### Other components

- **Students**
- **Warden and staff**

## Connections

- Students → Streamlit application: use application (evidence: `README.md`)
- Warden and staff → Streamlit application: manage complaints (evidence: `README.md`)
- Streamlit application → Sign-in and registration: presents (evidence: `README.md`)
- Streamlit application → Complaint conversation: presents (evidence: `README.md`)
- Streamlit application → Ticket confirmation: presents (evidence: `README.md`)
- Streamlit application → Ticket tracking: presents (evidence: `README.md`)
- Streamlit application → Staff dashboard: presents (evidence: `README.md`)
- Streamlit application → Analytics and export: presents (evidence: `README.md`)
- Sign-in and registration → Database operations: checks and registers (evidence: `app.py`)
- Complaint conversation → Conversational complaint agent: sends conversation (evidence: `app.py`)
- Conversational complaint agent → Google Gemini: requests parsing (evidence: `agent.py`)
- Conversational complaint agent → Initial complaint routing: requests assignment (evidence: `agent.py`)
- Ticket confirmation → Database operations: creates ticket (evidence: `app.py`)
- Ticket tracking → Database operations: reads tickets (evidence: `README.md`)
- Staff dashboard → Database operations: updates complaints (evidence: `README.md`)
- Staff dashboard → Manual and timed escalation: requests escalation (evidence: `README.md`)
- Analytics and export → Database operations: reads records (evidence: `README.md`)
- Analytics and export → Students: exports filtered CSV (evidence: `app.py`)
- Streamlit application → Manual and timed escalation: checks on execution (evidence: `README.md`)
- Manual and timed escalation → Database operations: loads and updates tickets (evidence: `routing.py`)
- Manual and timed escalation → Complaint and action history: records actions (evidence: `routing.py`)
- Database operations → SQLite schema: initializes from (evidence: `database.py`)
- Database operations → SQLite database: reads and writes (evidence: `database.py`)
- Database operations → Complaint and action history: records updates and logs (evidence: `database.py`)
