# danhvo100906/24ct2_vo_thanh_danh architecture

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

- Interactive diagram: https://gitdiagram.com/danhvo100906/24ct2_vo_thanh_danh
- Repository: https://github.com/danhvo100906/24ct2_vo_thanh_danh

## Overview

StudyBot is a Flask web app with user registration/login, role-gated admin pages, an intent-based chatbot, and per-user chat history. The main workflow is a signed-in user submitting a message through the chat API; the route obtains a response from the model and stores the exchange before returning it. The framework also includes a separate training script. The README is empty, so capabilities and links here rely on the supplied source excerpts and index; the retrieval module’s behavior is not shown.

Main entry points: [`app/routes.py`](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/routes.py) (Web routes), [`framework/src/model/chatbot.py`](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/chatbot.py) (Response inference), [`framework/src/model/train.py`](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/train.py) (Training script), [`app/__init__.py`](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/__init__.py) (App setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app_entry["App entry<br/>[main.py]"]
  node_app_factory["App setup<br/>[__init__.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_routes["Web routes<br/>[routes.py]"]
  node_templates["Page templates"]
end

subgraph group_account["Accounts and persistence"]
  node_models["User and history models<br/>[models.py]"]
  node_database[("Application database<br/>[models.py]")]
end

subgraph group_bot["Chatbot runtime"]
  node_chatbot["Response inference<br/>[chatbot.py]"]
  node_neural_net["Neural network<br/>[neural_net.py]"]
  node_text_utils["Text processing<br/>[nltk_utils.py]"]
  node_intents["Intent definitions<br/>[intents.json]"]
  node_weights["Trained model weights<br/>[data.pth]"]
  node_retrieval["Retrieval module<br/>[retrieval.py]"]
end

subgraph group_training["Model training"]
  node_training["Training script<br/>[train.py]"]
end

node_user(("User"))
node_admin(("Admin"))

node_user -->|"registers or logs in"| node_auth
node_auth -->|"queries and saves"| node_models
node_user -->|"requests pages and chat"| node_routes
node_admin -->|"requests admin pages"| node_routes
node_app_entry -->|"creates app"| node_app_factory
node_app_factory -->|"initializes database"| node_models
node_app_factory -->|"registers routes"| node_routes
node_app_factory -->|"registers routes"| node_auth
node_routes -->|"renders pages"| node_templates
node_auth -->|"renders pages"| node_templates
node_routes -->|"queries and stores chats"| node_models
node_models -->|"maps records"| node_database
node_routes -->|"requests response"| node_chatbot
node_chatbot -->|"runs inference"| node_neural_net
node_chatbot -->|"tokenizes and encodes"| node_text_utils
node_chatbot -->|"loads intent responses"| node_intents
node_chatbot -->|"loads model state"| node_weights
node_training -->|"loads training examples"| node_intents
node_training -->|"processes training text"| node_text_utils
node_training -->|"trains network"| node_neural_net
node_training -->|"saves trained state"| node_weights

click node_app_entry "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/main.py"
click node_app_factory "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/__init__.py"
click node_auth "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/auth.py"
click node_routes "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/routes.py"
click node_templates "https://github.com/danhvo100906/24ct2_vo_thanh_danh/tree/main/app/templates"
click node_models "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/models.py"
click node_database "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/models.py"
click node_chatbot "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/chatbot.py"
click node_neural_net "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/neural_net.py"
click node_text_utils "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/nltk_utils.py"
click node_intents "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/data/intents.json"
click node_weights "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/data.pth"
click node_training "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/train.py"
click node_retrieval "https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/processing/retrieval.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_entry,node_app_factory,node_auth,node_routes,node_templates,node_user toneBlue
class node_models,node_database toneAmber
class node_chatbot,node_neural_net,node_text_utils,node_intents,node_weights,node_retrieval toneMint
class node_training toneRose
class node_admin toneIndigo
```

## Components

### Web application

- [App entry](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/main.py): `app/main.py`
- [App setup](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/__init__.py): `app/__init__.py`
- [Authentication](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/auth.py): `app/auth.py`
- [Web routes](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/routes.py): `app/routes.py`
- [Page templates](https://github.com/danhvo100906/24ct2_vo_thanh_danh/tree/main/app/templates): `app/templates`

### Accounts and persistence

- [User and history models](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/models.py): `app/models.py`
- [Application database](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/app/models.py): `app/models.py`

### Chatbot runtime

- [Response inference](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/chatbot.py): `framework/src/model/chatbot.py`
- [Neural network](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/neural_net.py): `framework/src/model/neural_net.py`
- [Text processing](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/nltk_utils.py): `framework/src/model/nltk_utils.py`
- [Intent definitions](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/data/intents.json): `framework/src/data/intents.json`
- [Trained model weights](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/data.pth): `framework/src/model/data.pth`
- [Retrieval module](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/processing/retrieval.py): `framework/src/processing/retrieval.py`

### Model training

- [Training script](https://github.com/danhvo100906/24ct2_vo_thanh_danh/blob/main/framework/src/model/train.py): `framework/src/model/train.py`

### Other components

- **User**
- **Admin**

## Connections

- User → Authentication: registers or logs in (evidence: `app/auth.py`)
- Authentication → User and history models: queries and saves (evidence: `app/auth.py`)
- User → Web routes: requests pages and chat (evidence: `app/routes.py`)
- Admin → Web routes: requests admin pages (evidence: `app/routes.py`)
- App entry → App setup: creates app (evidence: `app/main.py`)
- App setup → User and history models: initializes database (evidence: `app/__init__.py`)
- App setup → Web routes: registers routes (evidence: `app/__init__.py`)
- App setup → Authentication: registers routes (evidence: `app/__init__.py`)
- Web routes → Page templates: renders pages (evidence: `app/routes.py`)
- Authentication → Page templates: renders pages (evidence: `app/auth.py`)
- Web routes → User and history models: queries and stores chats (evidence: `app/routes.py`)
- User and history models → Application database: maps records (evidence: `app/models.py`)
- Web routes → Response inference: requests response (evidence: `app/routes.py`)
- Response inference → Neural network: runs inference (evidence: `framework/src/model/chatbot.py`)
- Response inference → Text processing: tokenizes and encodes (evidence: `framework/src/model/chatbot.py`)
- Response inference → Intent definitions: loads intent responses (evidence: `framework/src/model/chatbot.py`)
- Response inference → Trained model weights: loads model state (evidence: `framework/src/model/chatbot.py`)
- Training script → Intent definitions: loads training examples (evidence: `framework/src/model/train.py`)
- Training script → Text processing: processes training text (evidence: `framework/src/model/train.py`)
- Training script → Neural network: trains network (evidence: `framework/src/model/train.py`)
- Training script → Trained model weights: saves trained state (evidence: `framework/src/model/train.py`)
