# lengocvu234/mango-ai-app architecture

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

- Interactive diagram: https://gitdiagram.com/lengocvu234/mango-ai-app
- Repository: https://github.com/lengocvu234/mango-ai-app

## Overview

Xoài AI is a Streamlit mango-detection application. Users authenticate, choose image upload or live camera, receive model detections, and can review saved results; upload results can also be emailed. Separate branches provide account settings and an AI chat assistant, while feature panels expose history and additional tools. The graph follows the visible app routing and sampled calls; some implementation details are omitted because excerpts are partial, and unsampled modules are represented only where the source index or visible wiring supports them.

Main entry points: [`DuAnXoai/app.py`](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/app.py) (Streamlit app), [`DuAnXoai/database.py`](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/database.py) (User and history data), [`DuAnXoai/ui_pages.py`](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/ui_pages.py) (Upload and camera pages), [`DuAnXoai/detection_service.py`](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/detection_service.py) (Mango detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application flow"]
  node_app["Streamlit app<br/>[app.py]"]
  node_config["App configuration<br/>[app_config.py]"]
  node_pages["Upload and camera pages<br/>[ui_pages.py]"]
  node_components["Shared UI components<br/>[ui_components.py]"]
end

subgraph group_vision["Mango vision"]
  node_detection["Mango detection"]
  node_model["YOLO model<br/>[best.pt]"]
  node_panels["Feature and history panels<br/>[feature_panels.py]"]
end

subgraph group_accounts["Accounts and history"]
  node_auth["Login and signup<br/>[auth.py]"]
  node_settings["Account settings<br/>[user_settings.py]"]
  node_database[("User and history data<br/>[database.py]")]
end

subgraph group_extras["Additional features"]
  node_email["Result email delivery<br/>[email_service.py]"]
  node_chat["Floating chat<br/>[chatbot.py]"]
end

node_user(("User"))
node_smtp{{"Gmail SMTP"}}
node_groq{{"Groq AI service"}}

node_user -->|"uses"| node_app
node_app -->|"loads settings"| node_config
node_app -->|"routes login"| node_auth
node_app -->|"routes pages"| node_pages
node_app -->|"renders panels"| node_panels
node_app -->|"renders chat"| node_chat
node_app -->|"loads model"| node_model
node_app -->|"passes detector"| node_detection
node_pages -->|"runs detection"| node_detection
node_detection -->|"saves history"| node_database
node_pages -->|"sends result"| node_email
node_email -->|"delivers email"| node_smtp
node_chat -.->|"requests advice"| node_groq
node_auth -->|"checks accounts"| node_database
node_auth -->|"uses settings"| node_settings
node_settings -->|"updates account"| node_database
node_pages -->|"reads profile"| node_database
node_panels -->|"reads history"| node_database
node_panels -->|"uses detection"| node_detection
node_components -->|"opens settings"| node_settings

click node_app "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/app.py"
click node_config "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/app_config.py"
click node_pages "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/ui_pages.py"
click node_auth "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/auth.py"
click node_settings "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/user_settings.py"
click node_database "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/database.py"
click node_detection "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/detection_service.py"
click node_model "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/best.pt"
click node_panels "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/feature_panels.py"
click node_email "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/email_service.py"
click node_chat "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/chatbot.py"
click node_components "https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/ui_components.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_config,node_pages,node_components,node_user toneBlue
class node_detection,node_model,node_panels toneAmber
class node_auth,node_settings,node_database toneMint
class node_email,node_chat toneRose
class node_smtp,node_groq toneIndigo
```

## Components

### Application flow

- [Streamlit app](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/app.py): `DuAnXoai/app.py`
- [App configuration](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/app_config.py): `DuAnXoai/app_config.py`
- [Upload and camera pages](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/ui_pages.py): `DuAnXoai/ui_pages.py`
- [Shared UI components](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/ui_components.py): `DuAnXoai/ui_components.py`

### Mango vision

- [Mango detection](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/detection_service.py): `DuAnXoai/detection_service.py`
- [YOLO model](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/best.pt): `DuAnXoai/best.pt`
- [Feature and history panels](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/feature_panels.py): `DuAnXoai/feature_panels.py`

### Accounts and history

- [Login and signup](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/auth.py): `DuAnXoai/auth.py`
- [Account settings](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/user_settings.py): `DuAnXoai/user_settings.py`
- [User and history data](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/database.py): `DuAnXoai/database.py`

### Additional features

- [Result email delivery](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/email_service.py): `DuAnXoai/email_service.py`
- [Floating chat](https://github.com/lengocvu234/mango-ai-app/blob/main/DuAnXoai/chatbot.py): `DuAnXoai/chatbot.py`

### Other components

- **User**
- **Gmail SMTP**
- **Groq AI service**

## Connections

- User → Streamlit app: uses (evidence: `DuAnXoai/app.py`)
- Streamlit app → App configuration: loads settings (evidence: `DuAnXoai/app.py`)
- Streamlit app → Login and signup: routes login (evidence: `DuAnXoai/app.py`)
- Streamlit app → Upload and camera pages: routes pages (evidence: `DuAnXoai/app.py`)
- Streamlit app → Feature and history panels: renders panels (evidence: `DuAnXoai/app.py`)
- Streamlit app → Floating chat: renders chat (evidence: `DuAnXoai/app.py`)
- Streamlit app → YOLO model: loads model (evidence: `DuAnXoai/app.py`)
- Streamlit app → Mango detection: passes detector (evidence: `DuAnXoai/app.py`)
- Upload and camera pages → Mango detection: runs detection (evidence: `DuAnXoai/app.py`)
- Mango detection → User and history data: saves history (evidence: `DuAnXoai/detection_service.py`)
- Upload and camera pages → Result email delivery: sends result (evidence: `DuAnXoai/ui_pages.py`)
- Result email delivery → Gmail SMTP: delivers email (evidence: `DuAnXoai/email_service.py`)
- Floating chat → Groq AI service: requests advice
- Login and signup → User and history data: checks accounts (evidence: `DuAnXoai/auth.py`)
- Login and signup → Account settings: uses settings (evidence: `DuAnXoai/auth.py`)
- Account settings → User and history data: updates account (evidence: `DuAnXoai/user_settings.py`)
- Upload and camera pages → User and history data: reads profile (evidence: `DuAnXoai/ui_pages.py`)
- Feature and history panels → User and history data: reads history (evidence: `DuAnXoai/feature_panels.py`)
- Feature and history panels → Mango detection: uses detection (evidence: `DuAnXoai/feature_panels.py`)
- Shared UI components → Account settings: opens settings (evidence: `DuAnXoai/ui_components.py`)
