# huybip5cc/brethecast architecture

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

- Interactive diagram: https://gitdiagram.com/huybip5cc/brethecast
- Repository: https://github.com/huybip5cc/brethecast

## Overview

Đây là dashboard Streamlit về thời tiết và AQI cho Hà Nội và TP. Hồ Chí Minh, với các chế độ dự báo thời tiết, AQI và gợi ý hôm nay. Người dùng chọn thành phố/chế độ; app lấy dữ liệu Open‑Meteo, rồi điều phối phân tích và hiển thị. Chế độ gợi ý kết hợp mô hình AQI với quy tắc xếp hạng khung giờ. Các nhánh thống kê lịch sử, hướng dẫn sức khỏe và trình bày được giữ riêng. Mô tả quan hệ giữa các mô-đun dựa trên README, SOURCE INDEX và excerpt; không suy đoán các luồng chưa được chỉ ra.

Main entry points: [`app.py`](https://github.com/huybip5cc/brethecast/blob/master/app.py) (Điều phối ứng dụng), [`ui/sidebar.py`](https://github.com/huybip5cc/brethecast/blob/master/ui/sidebar.py) (Điều khiển và tóm tắt), [`ui/air_quality.py`](https://github.com/huybip5cc/brethecast/blob/master/ui/air_quality.py) (Màn hình AQI), [`data.py`](https://github.com/huybip5cc/brethecast/blob/master/data.py) (Nạp và chuẩn hóa)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Điều phối dashboard"]
  node_app["Điều phối ứng dụng<br/>[app.py]"]
  node_city_config["Thành phố<br/>[cities.py]"]
end

subgraph group_data["Dữ liệu và lịch sử"]
  node_weather_api{{"Open-Meteo"}}
  node_data_client["Nạp và chuẩn hóa<br/>[data.py]"]
  node_history_store[("Lịch sử AQI<br/>[history_store.py]")]
end

subgraph group_insights["Phân tích và gợi ý"]
  node_analysis["Phân tích AQI<br/>[analysis.py]"]
  node_health["Hướng dẫn sức khỏe<br/>[health.py]"]
  node_decision["Mô hình AQI<br/>[decision_engine.py]"]
  node_activity["Xếp hạng hoạt động<br/>[activity_rules.py]"]
end

subgraph group_presentation["Giao diện Streamlit"]
  node_sidebar["Điều khiển và tóm tắt<br/>[sidebar.py]"]
  node_weather_view["Màn hình thời tiết<br/>[weather.py]"]
  node_aqi_view["Màn hình AQI<br/>[air_quality.py]"]
  node_today_view["Gợi ý hôm nay<br/>[today.py]"]
  node_widgets["Thẻ và tiện ích<br/>[widgets.py]"]
  node_assets["Tài nguyên giao diện<br/>[assets.py]"]
  node_styles["Kiểu dáng<br/>[styles.py]"]
end

node_user(("Người dùng"))

node_user -->|"chọn chế độ"| node_app
node_app -->|"lấy dữ liệu"| node_data_client
node_data_client -->|"gọi API"| node_weather_api
node_data_client -->|"dùng cấu hình"| node_city_config
node_data_client -->|"đọc ghi lịch sử"| node_history_store
node_app -->|"dùng điều khiển"| node_sidebar
node_app -->|"hiển thị thời tiết"| node_weather_view
node_app -->|"hiển thị AQI"| node_aqi_view
node_app -->|"hiển thị gợi ý"| node_today_view
node_app -->|"huấn luyện và dự báo"| node_decision
node_app -->|"xếp hạng khung giờ"| node_activity
node_aqi_view -->|"tính thống kê"| node_analysis
node_aqi_view -->|"tạo khuyến nghị"| node_health
node_aqi_view -->|"dùng tiện ích"| node_widgets
node_aqi_view -->|"dùng tài nguyên"| node_assets
node_sidebar -->|"dùng phân loại"| node_analysis
node_sidebar -->|"tạo khuyến nghị"| node_health
node_sidebar -->|"dùng tài nguyên"| node_assets
node_sidebar -->|"dùng tiện ích"| node_widgets
node_weather_view -->|"dùng phân tích"| node_analysis
node_weather_view -->|"dùng tài nguyên"| node_assets
node_weather_view -->|"dùng tiện ích"| node_widgets
node_today_view -->|"hiển thị dự báo"| node_decision
node_today_view -->|"hiển thị hướng dẫn"| node_health
node_today_view -->|"dùng quy tắc"| node_activity
node_app -->|"áp dụng kiểu dáng"| node_styles

click node_app "https://github.com/huybip5cc/brethecast/blob/master/app.py"
click node_city_config "https://github.com/huybip5cc/brethecast/blob/master/cities.py"
click node_data_client "https://github.com/huybip5cc/brethecast/blob/master/data.py"
click node_history_store "https://github.com/huybip5cc/brethecast/blob/master/history_store.py"
click node_analysis "https://github.com/huybip5cc/brethecast/blob/master/analysis.py"
click node_health "https://github.com/huybip5cc/brethecast/blob/master/health.py"
click node_decision "https://github.com/huybip5cc/brethecast/blob/master/decision_engine.py"
click node_activity "https://github.com/huybip5cc/brethecast/blob/master/activity_rules.py"
click node_sidebar "https://github.com/huybip5cc/brethecast/blob/master/ui/sidebar.py"
click node_weather_view "https://github.com/huybip5cc/brethecast/blob/master/ui/weather.py"
click node_aqi_view "https://github.com/huybip5cc/brethecast/blob/master/ui/air_quality.py"
click node_today_view "https://github.com/huybip5cc/brethecast/blob/master/ui/today.py"
click node_widgets "https://github.com/huybip5cc/brethecast/blob/master/ui/widgets.py"
click node_assets "https://github.com/huybip5cc/brethecast/blob/master/ui/assets.py"
click node_styles "https://github.com/huybip5cc/brethecast/blob/master/ui/styles.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_city_config toneBlue
class node_weather_api,node_data_client,node_history_store toneAmber
class node_analysis,node_health,node_decision,node_activity toneMint
class node_sidebar,node_weather_view,node_aqi_view,node_today_view,node_widgets,node_assets,node_styles toneRose
class node_user toneIndigo
```

## Components

### Điều phối dashboard

- [Điều phối ứng dụng](https://github.com/huybip5cc/brethecast/blob/master/app.py): `app.py`
- [Thành phố](https://github.com/huybip5cc/brethecast/blob/master/cities.py): `cities.py`

### Dữ liệu và lịch sử

- **Open-Meteo**
- [Nạp và chuẩn hóa](https://github.com/huybip5cc/brethecast/blob/master/data.py): `data.py`
- [Lịch sử AQI](https://github.com/huybip5cc/brethecast/blob/master/history_store.py): `history_store.py`

### Phân tích và gợi ý

- [Phân tích AQI](https://github.com/huybip5cc/brethecast/blob/master/analysis.py): `analysis.py`
- [Hướng dẫn sức khỏe](https://github.com/huybip5cc/brethecast/blob/master/health.py): `health.py`
- [Mô hình AQI](https://github.com/huybip5cc/brethecast/blob/master/decision_engine.py): `decision_engine.py`
- [Xếp hạng hoạt động](https://github.com/huybip5cc/brethecast/blob/master/activity_rules.py): `activity_rules.py`

### Giao diện Streamlit

- [Điều khiển và tóm tắt](https://github.com/huybip5cc/brethecast/blob/master/ui/sidebar.py): `ui/sidebar.py`
- [Màn hình thời tiết](https://github.com/huybip5cc/brethecast/blob/master/ui/weather.py): `ui/weather.py`
- [Màn hình AQI](https://github.com/huybip5cc/brethecast/blob/master/ui/air_quality.py): `ui/air_quality.py`
- [Gợi ý hôm nay](https://github.com/huybip5cc/brethecast/blob/master/ui/today.py): `ui/today.py`
- [Thẻ và tiện ích](https://github.com/huybip5cc/brethecast/blob/master/ui/widgets.py): `ui/widgets.py`
- [Tài nguyên giao diện](https://github.com/huybip5cc/brethecast/blob/master/ui/assets.py): `ui/assets.py`
- [Kiểu dáng](https://github.com/huybip5cc/brethecast/blob/master/ui/styles.py): `ui/styles.py`

### Other components

- **Người dùng**

## Connections

- Người dùng → Điều phối ứng dụng: chọn chế độ (evidence: `README.md`)
- Điều phối ứng dụng → Nạp và chuẩn hóa: lấy dữ liệu (evidence: `README.md`)
- Nạp và chuẩn hóa → Open-Meteo: gọi API (evidence: `data.py`)
- Nạp và chuẩn hóa → Thành phố: dùng cấu hình (evidence: `data.py`)
- Nạp và chuẩn hóa → Lịch sử AQI: đọc ghi lịch sử (evidence: `data.py`)
- Điều phối ứng dụng → Điều khiển và tóm tắt: dùng điều khiển (evidence: `app.py`)
- Điều phối ứng dụng → Màn hình thời tiết: hiển thị thời tiết (evidence: `app.py`)
- Điều phối ứng dụng → Màn hình AQI: hiển thị AQI (evidence: `app.py`)
- Điều phối ứng dụng → Gợi ý hôm nay: hiển thị gợi ý (evidence: `app.py`)
- Điều phối ứng dụng → Mô hình AQI: huấn luyện và dự báo (evidence: `app.py`)
- Điều phối ứng dụng → Xếp hạng hoạt động: xếp hạng khung giờ (evidence: `app.py`)
- Màn hình AQI → Phân tích AQI: tính thống kê (evidence: `ui/air_quality.py`)
- Màn hình AQI → Hướng dẫn sức khỏe: tạo khuyến nghị (evidence: `ui/air_quality.py`)
- Màn hình AQI → Thẻ và tiện ích: dùng tiện ích (evidence: `ui/air_quality.py`)
- Màn hình AQI → Tài nguyên giao diện: dùng tài nguyên (evidence: `ui/air_quality.py`)
- Điều khiển và tóm tắt → Phân tích AQI: dùng phân loại (evidence: `ui/sidebar.py`)
- Điều khiển và tóm tắt → Hướng dẫn sức khỏe: tạo khuyến nghị (evidence: `ui/sidebar.py`)
- Điều khiển và tóm tắt → Tài nguyên giao diện: dùng tài nguyên (evidence: `ui/sidebar.py`)
- Điều khiển và tóm tắt → Thẻ và tiện ích: dùng tiện ích (evidence: `ui/sidebar.py`)
- Màn hình thời tiết → Phân tích AQI: dùng phân tích (evidence: `ui/weather.py`)
- Màn hình thời tiết → Tài nguyên giao diện: dùng tài nguyên (evidence: `ui/weather.py`)
- Màn hình thời tiết → Thẻ và tiện ích: dùng tiện ích (evidence: `ui/weather.py`)
- Gợi ý hôm nay → Mô hình AQI: hiển thị dự báo (evidence: `ui/today.py`)
- Gợi ý hôm nay → Hướng dẫn sức khỏe: hiển thị hướng dẫn (evidence: `ui/today.py`)
- Gợi ý hôm nay → Xếp hạng hoạt động: dùng quy tắc (evidence: `ui/today.py`)
- Điều phối ứng dụng → Kiểu dáng: áp dụng kiểu dáng (evidence: `README.md`)
