# zhanghongqi1/ganxiaopang-agri-data-analysis architecture

> Architecture diagram of the GitHub repository zhanghongqi1/ganxiaopang-agri-data-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zhanghongqi1/ganxiaopang-agri-data-analysis
- Repository: https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis

## Overview

甘小胖 is a reproducible, simulated-data business analytics project spanning livestream commerce, e-commerce, B2B supply, warehousing, delivery, and stores. Its documented workflow generates data, cleans it, loads MySQL, runs five SQL analyses with Pandas cross-checks, then produces figures, an Excel dashboard, and a Markdown report. The graph follows the documented pipeline and sampled script behavior; details of unsampled SQL and scripts are represented only where the README or runner establishes their role.

Main entry points: [`scripts/05_run_queries.py`](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/05_run_queries.py) (SQL analysis runner), [`scripts/run_all.py`](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/run_all.py) (Pipeline runner), [`scripts/07_make_dashboard.py`](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/07_make_dashboard.py) (Dashboard generator), [`scripts/08_make_report.py`](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/08_make_report.py) (Report generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Data pipeline"]
  node_runner["Pipeline runner<br/>[run_all.py]"]
  node_generator["Data generator"]
  node_raw["Raw CSV data"]
  node_cleaner["Data cleaner<br/>[02_clean_data.py]"]
  node_processed["Processed CSV data"]
  node_sample_export["Sample exporter"]
  node_samples["Sample CSV data"]
end

subgraph group_warehouse["MySQL analytics"]
  node_loader["MySQL loader"]
  node_schema["Database schema"]
  node_mysql[("MySQL database")]
  node_metric_views["Metric views"]
end

subgraph group_analysis["Business analysis"]
  node_analysis_runner["SQL analysis runner<br/>[05_run_queries.py]"]
  node_category["Category ROI<br/>[a_category_roi.sql]"]
  node_rfm["User RFM<br/>[b_user_rfm.sql]"]
  node_live["Livestream funnel<br/>[c_live_funnel.sql]"]
  node_supply["Supply chain<br/>[d_supply_chain.sql]"]
  node_store["Store profitability<br/>[e_store_pnl.sql]"]
  node_results["Analysis results"]
  node_analysis_csv["Analysis tables"]
end

subgraph group_delivery["Analysis deliverables"]
  node_figure_generator["Figure generator<br/>[06_make_figures.py]"]
  node_figures["Analysis figures"]
  node_dashboard_generator["Dashboard generator"]
  node_dashboard["Excel dashboard<br/>[甘小胖经营分析看板.xlsx]"]
  node_report_generator["Report generator<br/>[08_make_report.py]"]
  node_report["Analysis report<br/>[甘小胖经营数据分析报告.md]"]
end

node_operator(("Operator"))

node_operator -->|"starts"| node_runner
node_runner -->|"runs"| node_generator
node_runner -->|"runs"| node_cleaner
node_runner -->|"runs"| node_loader
node_runner -->|"runs"| node_sample_export
node_runner -->|"runs"| node_analysis_runner
node_runner -->|"runs"| node_figure_generator
node_runner -->|"runs"| node_dashboard_generator
node_runner -->|"runs"| node_report_generator
node_generator -->|"writes"| node_raw
node_cleaner -->|"reads"| node_raw
node_cleaner -->|"writes"| node_processed
node_sample_export -->|"reads"| node_raw
node_sample_export -->|"writes"| node_samples
node_loader -->|"loads"| node_processed
node_loader -->|"executes"| node_schema
node_loader -->|"creates and loads"| node_mysql
node_analysis_runner -->|"executes"| node_category
node_analysis_runner -->|"executes"| node_rfm
node_analysis_runner -->|"executes"| node_live
node_analysis_runner -->|"executes"| node_supply
node_analysis_runner -->|"executes"| node_store
node_analysis_runner -->|"queries"| node_mysql
node_analysis_runner -->|"queries"| node_metric_views
node_analysis_runner -->|"writes"| node_analysis_csv
node_analysis_runner -->|"writes"| node_results
node_figure_generator -->|"reads"| node_results
node_figure_generator -->|"reads"| node_analysis_csv
node_figure_generator -->|"writes"| node_figures
node_dashboard_generator -->|"reads"| node_results
node_dashboard_generator -->|"reads"| node_analysis_csv
node_dashboard_generator -->|"embeds"| node_figures
node_dashboard_generator -->|"writes"| node_dashboard
node_report_generator -->|"reads"| node_results
node_report_generator -->|"reads"| node_analysis_csv
node_report_generator -->|"references"| node_figures
node_report_generator -->|"writes"| node_report

click node_runner "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/run_all.py"
click node_generator "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/01_generate_data.py"
click node_raw "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/data/raw"
click node_cleaner "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/02_clean_data.py"
click node_processed "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/data/processed"
click node_sample_export "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/04_export_samples.py"
click node_samples "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/data/sample"
click node_loader "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/03_load_to_mysql.py"
click node_schema "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/00_create_database.sql"
click node_metric_views "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/01_metric_views.sql"
click node_analysis_runner "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/05_run_queries.py"
click node_category "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/a_category_roi.sql"
click node_rfm "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/b_user_rfm.sql"
click node_live "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/c_live_funnel.sql"
click node_supply "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/d_supply_chain.sql"
click node_store "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/e_store_pnl.sql"
click node_results "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/logs/analysis_results.json"
click node_analysis_csv "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/data/processed"
click node_figure_generator "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/06_make_figures.py"
click node_figures "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/reports/figures"
click node_dashboard_generator "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/07_make_dashboard.py"
click node_dashboard "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/dashboard/%E7%94%98%E5%B0%8F%E8%83%96%E7%BB%8F%E8%90%A5%E5%88%86%E6%9E%90%E7%9C%8B%E6%9D%BF.xlsx"
click node_report_generator "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/08_make_report.py"
click node_report "https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/reports/%E7%94%98%E5%B0%8F%E8%83%96%E7%BB%8F%E8%90%A5%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E6%8A%A5%E5%91%8A.md"

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_runner,node_generator,node_raw,node_cleaner,node_processed,node_sample_export,node_samples toneBlue
class node_loader,node_schema,node_mysql,node_metric_views toneAmber
class node_analysis_runner,node_category,node_rfm,node_live,node_supply,node_store,node_results,node_analysis_csv toneMint
class node_figure_generator,node_figures,node_dashboard_generator,node_dashboard,node_report_generator,node_report toneRose
class node_operator toneIndigo
```

## Components

### Data pipeline

- [Pipeline runner](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/run_all.py): `scripts/run_all.py`
- [Data generator](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/01_generate_data.py): `scripts/01_generate_data.py`
- [Raw CSV data](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/data/raw): `data/raw`
- [Data cleaner](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/02_clean_data.py): `scripts/02_clean_data.py`
- [Processed CSV data](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/data/processed): `data/processed`
- [Sample exporter](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/04_export_samples.py): `scripts/04_export_samples.py`
- [Sample CSV data](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/data/sample): `data/sample`

### MySQL analytics

- [MySQL loader](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/03_load_to_mysql.py): `scripts/03_load_to_mysql.py`
- [Database schema](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/00_create_database.sql): `sql/00_create_database.sql`
- **MySQL database**
- [Metric views](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/01_metric_views.sql): `sql/01_metric_views.sql`

### Business analysis

- [SQL analysis runner](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/05_run_queries.py): `scripts/05_run_queries.py`
- [Category ROI](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/a_category_roi.sql): `sql/a_category_roi.sql`
- [User RFM](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/b_user_rfm.sql): `sql/b_user_rfm.sql`
- [Livestream funnel](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/c_live_funnel.sql): `sql/c_live_funnel.sql`
- [Supply chain](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/d_supply_chain.sql): `sql/d_supply_chain.sql`
- [Store profitability](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/sql/e_store_pnl.sql): `sql/e_store_pnl.sql`
- [Analysis results](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/logs/analysis_results.json): `logs/analysis_results.json`
- [Analysis tables](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/data/processed): `data/processed`

### Analysis deliverables

- [Figure generator](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/06_make_figures.py): `scripts/06_make_figures.py`
- [Analysis figures](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/tree/main/reports/figures): `reports/figures`
- [Dashboard generator](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/07_make_dashboard.py): `scripts/07_make_dashboard.py`
- [Excel dashboard](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/dashboard/%E7%94%98%E5%B0%8F%E8%83%96%E7%BB%8F%E8%90%A5%E5%88%86%E6%9E%90%E7%9C%8B%E6%9D%BF.xlsx): `dashboard/甘小胖经营分析看板.xlsx`
- [Report generator](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/scripts/08_make_report.py): `scripts/08_make_report.py`
- [Analysis report](https://github.com/zhanghongqi1/ganxiaopang-agri-data-analysis/blob/main/reports/%E7%94%98%E5%B0%8F%E8%83%96%E7%BB%8F%E8%90%A5%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E6%8A%A5%E5%91%8A.md): `reports/甘小胖经营数据分析报告.md`

### Other components

- **Operator**

## Connections

- Operator → Pipeline runner: starts
- Pipeline runner → Data generator: runs
- Pipeline runner → Data cleaner: runs
- Pipeline runner → MySQL loader: runs
- Pipeline runner → Sample exporter: runs
- Pipeline runner → SQL analysis runner: runs
- Pipeline runner → Figure generator: runs
- Pipeline runner → Dashboard generator: runs
- Pipeline runner → Report generator: runs
- Data generator → Raw CSV data: writes
- Data cleaner → Raw CSV data: reads
- Data cleaner → Processed CSV data: writes
- Sample exporter → Raw CSV data: reads
- Sample exporter → Sample CSV data: writes
- MySQL loader → Processed CSV data: loads
- MySQL loader → Database schema: executes
- MySQL loader → MySQL database: creates and loads
- SQL analysis runner → Category ROI: executes
- SQL analysis runner → User RFM: executes
- SQL analysis runner → Livestream funnel: executes
- SQL analysis runner → Supply chain: executes
- SQL analysis runner → Store profitability: executes
- SQL analysis runner → MySQL database: queries
- SQL analysis runner → Metric views: queries
- SQL analysis runner → Analysis tables: writes
- SQL analysis runner → Analysis results: writes
- Figure generator → Analysis results: reads
- Figure generator → Analysis tables: reads
- Figure generator → Analysis figures: writes
- Dashboard generator → Analysis results: reads
- Dashboard generator → Analysis tables: reads
- Dashboard generator → Analysis figures: embeds
- Dashboard generator → Excel dashboard: writes
- Report generator → Analysis results: reads
- Report generator → Analysis tables: reads
- Report generator → Analysis figures: references
- Report generator → Analysis report: writes
