# kientrung2005/retail-price-intelligence architecture

> Architecture diagram of the GitHub repository kientrung2005/retail-price-intelligence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kientrung2005/retail-price-intelligence
- Repository: https://github.com/kientrung2005/retail-price-intelligence

## Overview

Retail Price Intelligence is an orchestrated ETL and analytics platform. Airflow enqueues province/category/store work, workers crawl retailer sites, and raw JSON lands in MinIO. Spark flattens and partitions those records, loading PostgreSQL raw data and processed Parquet. dbt then builds the snowflake-style analytical warehouse, which Power BI uses for regional, retailer, availability, discount, review, and price comparisons. The graph reflects documented orchestration and sampled implementations; several retailer workers and dbt models are represented at their exact enclosing paths because their full source was not sampled.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Orchestration"]
  node_airflow["Airflow DAG"]
  node_task_enqueue["Task Enqueuer<br/>[enqueue_tasks.py]"]
  node_redis_queue["Redis Queues<br/>[client.py]"]
end

subgraph group_acquisition["Data Acquisition"]
  node_crawler_runner["Crawler Runner<br/>[run_crawlers.py]"]
  node_cellphones["CellphoneS Crawler"]
  node_fptshop["FPT Shop Crawler<br/>[fptshop_crawler.py]"]
  node_dienmayxanh["Dien May Xanh Crawler"]
  node_review_enrichment["Review Enrichment<br/>[review_utils.py]"]
end

subgraph group_processing["Processing"]
  node_minio[("MinIO Data Lake<br/>[minio_client.py]")]
  node_spark_etl["Spark ETL"]
  node_spark_connect["Spark Connector<br/>[spark_connect.py]"]
  node_parquet[("Processed Parquet")]
end

subgraph group_warehouse["Warehouse"]
  node_postgres_raw[("PostgreSQL Raw Data<br/>[create_tables.py]")]
  node_dbt_models["dbt Warehouse Models"]
  node_warehouse_schema[("Analytical Warehouse")]
end

subgraph group_analytics["Analytics"]
  node_powerbi["Power BI Dashboard"]
  node_results["Comparison Results"]
end

node_analyst(("Business Analyst"))
node_retailer_sites["Retailer Websites"]

node_analyst -->|"triggers"| node_airflow
node_airflow -->|"runs"| node_task_enqueue
node_task_enqueue -->|"pushes tasks"| node_redis_queue
node_airflow -->|"runs"| node_crawler_runner
node_redis_queue -->|"dispatches tasks"| node_crawler_runner
node_crawler_runner -->|"invokes"| node_cellphones
node_crawler_runner -->|"invokes"| node_fptshop
node_crawler_runner -->|"invokes"| node_dienmayxanh
node_cellphones -->|"fetches listings"| node_retailer_sites
node_fptshop -->|"fetches listings"| node_retailer_sites
node_dienmayxanh -->|"fetches listings"| node_retailer_sites
node_cellphones -->|"enriches reviews"| node_review_enrichment
node_dienmayxanh -->|"enriches reviews"| node_review_enrichment
node_review_enrichment -.->|"caches reviews"| node_redis_queue
node_crawler_runner -->|"writes raw JSON"| node_minio
node_airflow -->|"runs"| node_spark_etl
node_spark_etl -->|"creates session"| node_spark_connect
node_spark_etl -->|"reads raw JSON"| node_minio
node_spark_etl -->|"writes partitions"| node_parquet
node_spark_etl -->|"loads records"| node_postgres_raw
node_airflow -->|"runs dbt"| node_dbt_models
node_dbt_models -->|"reads raw data"| node_postgres_raw
node_dbt_models -->|"builds marts"| node_warehouse_schema
node_powerbi -->|"reads models"| node_warehouse_schema
node_analyst -->|"views comparisons"| node_powerbi
node_powerbi -->|"exports visuals"| node_results

click node_airflow "https://github.com/kientrung2005/retail-price-intelligence/blob/main/dags/retail_pipeline_dag.py"
click node_task_enqueue "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/redis/enqueue_tasks.py"
click node_redis_queue "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/redis/client.py"
click node_crawler_runner "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/crawler/run_crawlers.py"
click node_cellphones "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/crawler/cellphones_crawler.py"
click node_fptshop "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/crawler/fptshop_crawler.py"
click node_dienmayxanh "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/crawler/dienmayxanh_crawler.py"
click node_minio "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/storage/minio_client.py"
click node_review_enrichment "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/utils/review_utils.py"
click node_spark_etl "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/spark/load_to_postgres.py"
click node_spark_connect "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/spark/spark_connect.py"
click node_parquet "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/spark/load_to_postgres.py"
click node_postgres_raw "https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/database/create_tables.py"
click node_dbt_models "https://github.com/kientrung2005/retail-price-intelligence/tree/main/dbt/models"
click node_warehouse_schema "https://github.com/kientrung2005/retail-price-intelligence/tree/main/dbt/models/marts"
click node_powerbi "https://github.com/kientrung2005/retail-price-intelligence/blob/main/dashboard/retail-intelligence.pbix"
click node_results "https://github.com/kientrung2005/retail-price-intelligence/tree/main/results"

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_airflow,node_task_enqueue,node_redis_queue toneBlue
class node_crawler_runner,node_cellphones,node_fptshop,node_dienmayxanh,node_review_enrichment toneAmber
class node_minio,node_spark_etl,node_spark_connect,node_parquet toneMint
class node_postgres_raw,node_dbt_models,node_warehouse_schema toneRose
class node_powerbi,node_results,node_analyst,node_retailer_sites toneIndigo
```

## Components

### Orchestration

- [Airflow DAG](https://github.com/kientrung2005/retail-price-intelligence/blob/main/dags/retail_pipeline_dag.py): `dags/retail_pipeline_dag.py`
- [Task Enqueuer](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/redis/enqueue_tasks.py): `src/redis/enqueue_tasks.py`
- [Redis Queues](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/redis/client.py): `src/redis/client.py`

### Data Acquisition

- [Crawler Runner](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/crawler/run_crawlers.py): `src/crawler/run_crawlers.py`
- [CellphoneS Crawler](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/crawler/cellphones_crawler.py): `src/crawler/cellphones_crawler.py`
- [FPT Shop Crawler](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/crawler/fptshop_crawler.py): `src/crawler/fptshop_crawler.py`
- [Dien May Xanh Crawler](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/crawler/dienmayxanh_crawler.py): `src/crawler/dienmayxanh_crawler.py`
- [Review Enrichment](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/utils/review_utils.py): `src/utils/review_utils.py`

### Processing

- [MinIO Data Lake](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/storage/minio_client.py): `src/storage/minio_client.py`
- [Spark ETL](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/spark/load_to_postgres.py): `src/spark/load_to_postgres.py`
- [Spark Connector](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/spark/spark_connect.py): `src/spark/spark_connect.py`
- [Processed Parquet](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/spark/load_to_postgres.py): `src/spark/load_to_postgres.py`

### Warehouse

- [PostgreSQL Raw Data](https://github.com/kientrung2005/retail-price-intelligence/blob/main/src/database/create_tables.py): `src/database/create_tables.py`
- [dbt Warehouse Models](https://github.com/kientrung2005/retail-price-intelligence/tree/main/dbt/models): `dbt/models`
- [Analytical Warehouse](https://github.com/kientrung2005/retail-price-intelligence/tree/main/dbt/models/marts): `dbt/models/marts`

### Analytics

- [Power BI Dashboard](https://github.com/kientrung2005/retail-price-intelligence/blob/main/dashboard/retail-intelligence.pbix): `dashboard/retail-intelligence.pbix`
- [Comparison Results](https://github.com/kientrung2005/retail-price-intelligence/tree/main/results): `results`

### Other components

- **Business Analyst**
- **Retailer Websites**

## Connections

- Business Analyst → Airflow DAG: triggers
- Airflow DAG → Task Enqueuer: runs
- Task Enqueuer → Redis Queues: pushes tasks
- Airflow DAG → Crawler Runner: runs
- Redis Queues → Crawler Runner: dispatches tasks
- Crawler Runner → CellphoneS Crawler: invokes
- Crawler Runner → FPT Shop Crawler: invokes
- Crawler Runner → Dien May Xanh Crawler: invokes
- CellphoneS Crawler → Retailer Websites: fetches listings
- FPT Shop Crawler → Retailer Websites: fetches listings
- Dien May Xanh Crawler → Retailer Websites: fetches listings
- CellphoneS Crawler → Review Enrichment: enriches reviews
- Dien May Xanh Crawler → Review Enrichment: enriches reviews
- Review Enrichment → Redis Queues: caches reviews
- Crawler Runner → MinIO Data Lake: writes raw JSON
- Airflow DAG → Spark ETL: runs
- Spark ETL → Spark Connector: creates session
- Spark ETL → MinIO Data Lake: reads raw JSON
- Spark ETL → Processed Parquet: writes partitions
- Spark ETL → PostgreSQL Raw Data: loads records
- Airflow DAG → dbt Warehouse Models: runs dbt
- dbt Warehouse Models → PostgreSQL Raw Data: reads raw data
- dbt Warehouse Models → Analytical Warehouse: builds marts
- Power BI Dashboard → Analytical Warehouse: reads models
- Business Analyst → Power BI Dashboard: views comparisons
- Power BI Dashboard → Comparison Results: exports visuals
