# stillchoosingyou/ai-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/stillchoosingyou/ai-chatbot
- Repository: https://github.com/stillchoosingyou/ai-chatbot

## Overview

This is a local Flask prototype for managing school ID records, processing status and appointments, with a staff-facing chatbot and QR-based student profiles. The main workflow is staff search or edit an inventory record, save status or appointment changes, then ask about the selected record; a separate scan path displays limited student details. The app also documents gate logs, incidents, student requests, card previews and CSV export. Some route implementations were not sampled, so those links rely on README statements or are omitted where evidence is insufficient.

Main entry points: [`Chatbot.py`](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py) (Flask application), [`static/app.js`](https://github.com/stillchoosingyou/ai-chatbot/blob/main/static/app.js) (Workspace UI), [`train_model.py`](https://github.com/stillchoosingyou/ai-chatbot/blob/main/train_model.py) (Model training), [`intent_model.py`](https://github.com/stillchoosingyou/ai-chatbot/blob/main/intent_model.py) (Intent inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Staff interface"]
  node_webui["Workspace UI<br/>[app.js]"]
end

subgraph group_operations["ID operations"]
  node_flask["Flask application<br/>[Chatbot.py]"]
  node_inventory["ID inventory<br/>[Chatbot.py]"]
  node_appointments["Status and appointments<br/>[Chatbot.py]"]
  node_gate["Gate logs<br/>[Chatbot.py]"]
  node_incidents["Incident records<br/>[Chatbot.py]"]
  node_requests["Student requests<br/>[Chatbot.py]"]
end

subgraph group_assistant["Chat and training"]
  node_chat["Chat handling<br/>[Chatbot.py]"]
  node_classifier["Intent inference<br/>[intent_model.py]"]
  node_trainer["Model training<br/>[train_model.py]"]
  node_dataset["Intent examples"]
  node_model["Trained model"]
end

subgraph group_records["Records and outputs"]
  node_sqlite[("Inventory database<br/>[inventory.sqlite3]")]
  node_qr["QR and sticker views<br/>[Chatbot.py]"]
  node_card["Card artwork<br/>[id_cards.py]"]
end

node_staff(("Staff user"))
node_student(("Student / phone user"))

node_staff -->|"uses"| node_webui
node_webui -->|"requests API"| node_flask
node_flask -->|"routes inventory"| node_inventory
node_flask -->|"updates status"| node_appointments
node_flask -->|"records entries"| node_gate
node_flask -->|"records incidents"| node_incidents
node_flask -->|"handles requests"| node_requests
node_flask -->|"reads and writes"| node_sqlite
node_webui -->|"sends questions"| node_chat
node_chat -->|"classifies intent"| node_classifier
node_classifier -->|"loads model"| node_model
node_chat -->|"looks up ID data"| node_inventory
node_trainer -->|"trains from"| node_dataset
node_trainer -->|"saves model"| node_model
node_flask -->|"serves QR views"| node_qr
node_flask -->|"renders card images"| node_card
node_student -->|"scans QR"| node_qr
node_qr -->|"reads profile fields"| node_sqlite
node_webui -->|"edits and filters"| node_inventory

click node_webui "https://github.com/stillchoosingyou/ai-chatbot/blob/main/static/app.js"
click node_flask "https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py"
click node_inventory "https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py"
click node_appointments "https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py"
click node_gate "https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py"
click node_incidents "https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py"
click node_requests "https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py"
click node_chat "https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py"
click node_classifier "https://github.com/stillchoosingyou/ai-chatbot/blob/main/intent_model.py"
click node_trainer "https://github.com/stillchoosingyou/ai-chatbot/blob/main/train_model.py"
click node_dataset "https://github.com/stillchoosingyou/ai-chatbot/blob/main/property_management_dataset.csv"
click node_model "https://github.com/stillchoosingyou/ai-chatbot/blob/main/data/intent_model.joblib"
click node_sqlite "https://github.com/stillchoosingyou/ai-chatbot/blob/main/data/inventory.sqlite3"
click node_qr "https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py"
click node_card "https://github.com/stillchoosingyou/ai-chatbot/blob/main/id_cards.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_webui,node_staff,node_student toneBlue
class node_flask,node_inventory,node_appointments,node_gate,node_incidents,node_requests toneAmber
class node_chat,node_classifier,node_trainer,node_dataset,node_model toneMint
class node_sqlite,node_qr,node_card toneRose
```

## Components

### Staff interface

- [Workspace UI](https://github.com/stillchoosingyou/ai-chatbot/blob/main/static/app.js): `static/app.js`

### ID operations

- [Flask application](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py): `Chatbot.py`
- [ID inventory](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py): `Chatbot.py`
- [Status and appointments](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py): `Chatbot.py`
- [Gate logs](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py): `Chatbot.py`
- [Incident records](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py): `Chatbot.py`
- [Student requests](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py): `Chatbot.py`

### Chat and training

- [Chat handling](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py): `Chatbot.py`
- [Intent inference](https://github.com/stillchoosingyou/ai-chatbot/blob/main/intent_model.py): `intent_model.py`
- [Model training](https://github.com/stillchoosingyou/ai-chatbot/blob/main/train_model.py): `train_model.py`
- [Intent examples](https://github.com/stillchoosingyou/ai-chatbot/blob/main/property_management_dataset.csv): `property_management_dataset.csv`
- [Trained model](https://github.com/stillchoosingyou/ai-chatbot/blob/main/data/intent_model.joblib): `data/intent_model.joblib`

### Records and outputs

- [Inventory database](https://github.com/stillchoosingyou/ai-chatbot/blob/main/data/inventory.sqlite3): `data/inventory.sqlite3`
- [QR and sticker views](https://github.com/stillchoosingyou/ai-chatbot/blob/main/Chatbot.py): `Chatbot.py`
- [Card artwork](https://github.com/stillchoosingyou/ai-chatbot/blob/main/id_cards.py): `id_cards.py`

### Other components

- **Staff user**
- **Student / phone user**

## Connections

- Staff user → Workspace UI: uses (evidence: `README.md`)
- Workspace UI → Flask application: requests API (evidence: `static/app.js`)
- Flask application → ID inventory: routes inventory (evidence: `Chatbot.py`)
- Flask application → Status and appointments: updates status (evidence: `README.md`)
- Flask application → Gate logs: records entries (evidence: `Chatbot.py`)
- Flask application → Incident records: records incidents (evidence: `Chatbot.py`)
- Flask application → Student requests: handles requests (evidence: `Chatbot.py`)
- Flask application → Inventory database: reads and writes (evidence: `README.md`)
- Workspace UI → Chat handling: sends questions (evidence: `README.md`)
- Chat handling → Intent inference: classifies intent (evidence: `Chatbot.py`)
- Intent inference → Trained model: loads model (evidence: `intent_model.py`)
- Chat handling → ID inventory: looks up ID data (evidence: `README.md`)
- Model training → Intent examples: trains from (evidence: `README.md`)
- Model training → Trained model: saves model (evidence: `README.md`)
- Flask application → QR and sticker views: serves QR views (evidence: `Chatbot.py`)
- Flask application → Card artwork: renders card images (evidence: `Chatbot.py`)
- Student / phone user → QR and sticker views: scans QR (evidence: `README.md`)
- QR and sticker views → Inventory database: reads profile fields (evidence: `Chatbot.py`)
- Workspace UI → ID inventory: edits and filters (evidence: `static/app.js`)
