# viengthong2015/ai architecture

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

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

## Overview

Laos Population Forecast is a Streamlit dashboard for exploring district population history and producing forecasts. Users load the bundled CSV or upload their own, filter records and choose a forecast model or compare all models. The app evaluates models on a chronological holdout, then uses the full historical series for future projections. It also offers nationwide outlier checks, forecast charts and downloadable CSV/HTML reports. The app’s imports and README support the main module links; some detailed internal calls are not shown in the excerpts.

Main entry points: [`app.py`](https://github.com/viengthong2015/ai/blob/main/app.py) (Streamlit app), [`population_forecast.py`](https://github.com/viengthong2015/ai/blob/main/population_forecast.py) (Holdout evaluation), [`outlier_detection.py`](https://github.com/viengthong2015/ai/blob/main/outlier_detection.py) (Outlier checks), [`data/dataDistrict.csv`](https://github.com/viengthong2015/ai/blob/main/data/dataDistrict.csv) (Default district data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Population inputs"]
  node_csv["Default district data<br/>[dataDistrict.csv]"]
  node_upload["Uploaded CSV"]
  node_filters["Record and year filters<br/>[app.py]"]
end

subgraph group_analysis["Analysis and forecasting"]
  node_outlier["Outlier checks"]
  node_correction["Historical corrections"]
  node_validation["Holdout evaluation"]
  node_linear["Linear regression"]
  node_polynomial["Polynomial regression"]
  node_exponential["Exponential growth"]
  node_forecast["Final forecasts"]
end

subgraph group_dashboard["Dashboard outputs"]
  node_app["Streamlit app<br/>[app.py]"]
  node_overview["Forecast overview<br/>[app.py]"]
  node_sourceview["Source data and flags<br/>[app.py]"]
  node_pyramid["Population charts<br/>[app.py]"]
  node_exports["CSV and HTML exports"]
  node_methodology["Methodology guidance<br/>[app.py]"]
end

node_planner(("Dashboard user"))

node_planner -->|"uses"| node_app
node_csv -->|"loads by default"| node_app
node_upload -->|"uploads data"| node_app
node_app -->|"filters records"| node_filters
node_app -->|"runs checks"| node_outlier
node_app -.->|"prepares corrections"| node_correction
node_app -->|"evaluates models"| node_validation
node_validation -->|"scores"| node_linear
node_validation -->|"scores"| node_polynomial
node_validation -->|"scores"| node_exponential
node_app -->|"forecasts"| node_forecast
node_forecast -->|"fits"| node_linear
node_forecast -->|"fits"| node_polynomial
node_forecast -->|"fits"| node_exponential
node_app -->|"renders"| node_overview
node_app -->|"renders"| node_sourceview
node_sourceview -->|"displays flags"| node_outlier
node_app -->|"renders"| node_pyramid
node_app -->|"creates downloads"| node_exports
node_app -->|"documents workflow"| node_methodology
node_planner -->|"reviews"| node_overview
node_planner -->|"inspects"| node_sourceview
node_planner -->|"downloads"| node_exports

click node_app "https://github.com/viengthong2015/ai/blob/main/app.py"
click node_csv "https://github.com/viengthong2015/ai/blob/main/data/dataDistrict.csv"
click node_filters "https://github.com/viengthong2015/ai/blob/main/app.py"
click node_outlier "https://github.com/viengthong2015/ai/blob/main/outlier_detection.py"
click node_correction "https://github.com/viengthong2015/ai/blob/main/outlier_detection.py"
click node_validation "https://github.com/viengthong2015/ai/blob/main/population_forecast.py"
click node_linear "https://github.com/viengthong2015/ai/blob/main/population_forecast.py"
click node_polynomial "https://github.com/viengthong2015/ai/blob/main/population_forecast.py"
click node_exponential "https://github.com/viengthong2015/ai/blob/main/population_forecast.py"
click node_forecast "https://github.com/viengthong2015/ai/blob/main/population_forecast.py"
click node_overview "https://github.com/viengthong2015/ai/blob/main/app.py"
click node_sourceview "https://github.com/viengthong2015/ai/blob/main/app.py"
click node_pyramid "https://github.com/viengthong2015/ai/blob/main/app.py"
click node_exports "https://github.com/viengthong2015/ai/blob/main/population_forecast.py"
click node_methodology "https://github.com/viengthong2015/ai/blob/main/app.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_csv,node_upload,node_filters,node_planner toneBlue
class node_outlier,node_correction,node_validation,node_linear,node_polynomial,node_exponential,node_forecast toneAmber
class node_app,node_overview,node_sourceview,node_pyramid,node_exports,node_methodology toneMint
```

## Components

### Population inputs

- [Default district data](https://github.com/viengthong2015/ai/blob/main/data/dataDistrict.csv): `data/dataDistrict.csv`
- **Uploaded CSV**
- [Record and year filters](https://github.com/viengthong2015/ai/blob/main/app.py): `app.py`

### Analysis and forecasting

- [Outlier checks](https://github.com/viengthong2015/ai/blob/main/outlier_detection.py): `outlier_detection.py`
- [Historical corrections](https://github.com/viengthong2015/ai/blob/main/outlier_detection.py): `outlier_detection.py`
- [Holdout evaluation](https://github.com/viengthong2015/ai/blob/main/population_forecast.py): `population_forecast.py`
- [Linear regression](https://github.com/viengthong2015/ai/blob/main/population_forecast.py): `population_forecast.py`
- [Polynomial regression](https://github.com/viengthong2015/ai/blob/main/population_forecast.py): `population_forecast.py`
- [Exponential growth](https://github.com/viengthong2015/ai/blob/main/population_forecast.py): `population_forecast.py`
- [Final forecasts](https://github.com/viengthong2015/ai/blob/main/population_forecast.py): `population_forecast.py`

### Dashboard outputs

- [Streamlit app](https://github.com/viengthong2015/ai/blob/main/app.py): `app.py`
- [Forecast overview](https://github.com/viengthong2015/ai/blob/main/app.py): `app.py`
- [Source data and flags](https://github.com/viengthong2015/ai/blob/main/app.py): `app.py`
- [Population charts](https://github.com/viengthong2015/ai/blob/main/app.py): `app.py`
- [CSV and HTML exports](https://github.com/viengthong2015/ai/blob/main/population_forecast.py): `population_forecast.py`
- [Methodology guidance](https://github.com/viengthong2015/ai/blob/main/app.py): `app.py`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Streamlit app: uses (evidence: `README.md`)
- Default district data → Streamlit app: loads by default (evidence: `README.md`)
- Uploaded CSV → Streamlit app: uploads data (evidence: `README.md`)
- Streamlit app → Record and year filters: filters records (evidence: `README.md`)
- Streamlit app → Outlier checks: runs checks (evidence: `app.py`)
- Streamlit app → Historical corrections: prepares corrections (evidence: `app.py`)
- Streamlit app → Holdout evaluation: evaluates models (evidence: `README.md`)
- Holdout evaluation → Linear regression: scores (evidence: `population_forecast.py`)
- Holdout evaluation → Polynomial regression: scores (evidence: `population_forecast.py`)
- Holdout evaluation → Exponential growth: scores (evidence: `population_forecast.py`)
- Streamlit app → Final forecasts: forecasts (evidence: `README.md`)
- Final forecasts → Linear regression: fits (evidence: `population_forecast.py`)
- Final forecasts → Polynomial regression: fits (evidence: `population_forecast.py`)
- Final forecasts → Exponential growth: fits (evidence: `population_forecast.py`)
- Streamlit app → Forecast overview: renders (evidence: `app.py`)
- Streamlit app → Source data and flags: renders (evidence: `app.py`)
- Source data and flags → Outlier checks: displays flags (evidence: `README.md`)
- Streamlit app → Population charts: renders (evidence: `app.py`)
- Streamlit app → CSV and HTML exports: creates downloads (evidence: `README.md`)
- Streamlit app → Methodology guidance: documents workflow (evidence: `README.md`)
- Dashboard user → Forecast overview: reviews (evidence: `README.md`)
- Dashboard user → Source data and flags: inspects (evidence: `README.md`)
- Dashboard user → CSV and HTML exports: downloads (evidence: `README.md`)
