# tuanduy35399/chat_bot_maivang-backend architecture

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

- Interactive diagram: https://gitdiagram.com/tuanduy35399/chat_bot_maivang-backend
- Repository: https://github.com/tuanduy35399/chat_bot_maivang-backend

## Overview

This is a Django REST backend for a Vietnamese mai-tree disease chatbot. Users can browse a disease guide, manage accounts, and create chat histories; chat requests are sent to an external AI service, while image-chat requests first send the uploaded image to a YOLO service and then send detections to the AI service. The README also describes image uploads as illustrative rather than AI recognition, which differs from the sampled backend implementation. Relationships below follow sampled calls, indexed references, and documented capabilities; unsampled URL wiring and other details are omitted where not evidenced.

Main entry points: [`history/views.py`](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/history/views.py) (Chat and history API), [`backend/settings.py`](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/backend/settings.py) (Django configuration), [`backend/urls.py`](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/backend/urls.py) (API routing), [`user/views.py`](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/user/views.py) (Account endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_routes["API routing<br/>[urls.py]"]
  node_account_api["Account endpoints<br/>[views.py]"]
  node_account_data["Account serialization<br/>[serializers.py]"]
  node_account_model["User accounts<br/>[models.py]"]
end

subgraph group_guide["Disease guide"]
  node_disease_api["Disease endpoints<br/>[views.py]"]
  node_disease_serialization["Disease serialization<br/>[serializers.py]"]
  node_disease_model["Disease catalog<br/>[models.py]"]
end

subgraph group_chat["Chat and diagnosis"]
  node_history_api["Chat and history API<br/>[views.py]"]
  node_chat_serialization["Chat serialization<br/>[serializers.py]"]
  node_chat_model["Chat records<br/>[models.py]"]
end

subgraph group_runtime["Runtime and storage"]
  node_configuration["Django configuration<br/>[settings.py]"]
  node_database[("Application database")]
end

node_visitor(("API user"))
node_text_ai{{"Text AI service"}}
node_yolo{{"YOLO service"}}
node_image_ai{{"Image AI service"}}

node_visitor -.->|"sends requests"| node_routes
node_routes -.->|"routes to"| node_account_api
node_routes -.->|"routes to"| node_disease_api
node_routes -.->|"routes to"| node_history_api
node_account_api -->|"serializes with"| node_account_data
node_account_api -->|"queries"| node_account_model
node_account_data -->|"serializes"| node_account_model
node_disease_api -->|"serializes with"| node_disease_serialization
node_disease_api -->|"queries"| node_disease_model
node_disease_serialization -->|"serializes"| node_disease_model
node_history_api -->|"validates with"| node_chat_serialization
node_history_api -->|"reads and writes"| node_chat_model
node_history_api -->|"posts chat"| node_text_ai
node_history_api -->|"posts image"| node_yolo
node_history_api -->|"posts detections"| node_image_ai
node_configuration -->|"configures"| node_database
node_configuration -->|"sets endpoint"| node_text_ai
node_configuration -->|"sets endpoint"| node_yolo
node_configuration -->|"sets endpoint"| node_image_ai
node_account_model -.->|"persists records"| node_database
node_disease_model -.->|"persists records"| node_database
node_chat_model -.->|"persists records"| node_database

click node_routes "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/backend/urls.py"
click node_account_api "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/user/views.py"
click node_account_data "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/user/serializers.py"
click node_account_model "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/user/models.py"
click node_disease_api "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/diseases/views.py"
click node_disease_serialization "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/diseases/serializers.py"
click node_disease_model "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/diseases/models.py"
click node_history_api "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/history/views.py"
click node_chat_serialization "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/history/serializers.py"
click node_chat_model "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/history/models.py"
click node_configuration "https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/backend/settings.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_routes,node_account_api,node_account_data,node_account_model,node_visitor toneBlue
class node_disease_api,node_disease_serialization,node_disease_model toneAmber
class node_history_api,node_chat_serialization,node_chat_model toneMint
class node_configuration,node_database toneRose
class node_text_ai,node_yolo,node_image_ai toneIndigo
```

## Components

### API and identity

- [API routing](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/backend/urls.py): `backend/urls.py`
- [Account endpoints](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/user/views.py): `user/views.py`
- [Account serialization](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/user/serializers.py): `user/serializers.py`
- [User accounts](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/user/models.py): `user/models.py`

### Disease guide

- [Disease endpoints](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/diseases/views.py): `diseases/views.py`
- [Disease serialization](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/diseases/serializers.py): `diseases/serializers.py`
- [Disease catalog](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/diseases/models.py): `diseases/models.py`

### Chat and diagnosis

- [Chat and history API](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/history/views.py): `history/views.py`
- [Chat serialization](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/history/serializers.py): `history/serializers.py`
- [Chat records](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/history/models.py): `history/models.py`

### Runtime and storage

- [Django configuration](https://github.com/tuanduy35399/chat_bot_maivang-backend/blob/main/backend/settings.py): `backend/settings.py`
- **Application database**

### Other components

- **API user**
- **Text AI service**
- **YOLO service**
- **Image AI service**

## Connections

- API user → API routing: sends requests
- API routing → Account endpoints: routes to
- API routing → Disease endpoints: routes to
- API routing → Chat and history API: routes to
- Account endpoints → Account serialization: serializes with (evidence: `user/views.py`)
- Account endpoints → User accounts: queries (evidence: `user/views.py`)
- Account serialization → User accounts: serializes (evidence: `user/serializers.py`)
- Disease endpoints → Disease serialization: serializes with (evidence: `diseases/views.py`)
- Disease endpoints → Disease catalog: queries (evidence: `diseases/views.py`)
- Disease serialization → Disease catalog: serializes (evidence: `diseases/serializers.py`)
- Chat and history API → Chat serialization: validates with (evidence: `history/views.py`)
- Chat and history API → Chat records: reads and writes (evidence: `history/views.py`)
- Chat and history API → Text AI service: posts chat (evidence: `history/views.py`)
- Chat and history API → YOLO service: posts image (evidence: `history/views.py`)
- Chat and history API → Image AI service: posts detections (evidence: `history/views.py`)
- Django configuration → Application database: configures (evidence: `backend/settings.py`)
- Django configuration → Text AI service: sets endpoint (evidence: `backend/settings.py`)
- Django configuration → YOLO service: sets endpoint (evidence: `backend/settings.py`)
- Django configuration → Image AI service: sets endpoint (evidence: `backend/settings.py`)
- User accounts → Application database: persists records
- Disease catalog → Application database: persists records
- Chat records → Application database: persists records
