# bilal-alshami/bigdata-hybrid-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/bilal-alshami/bigdata-hybrid-pipeline
- Repository: https://github.com/bilal-alshami/bigdata-hybrid-pipeline

## Overview

This is a hybrid e-commerce data pipeline with a FastAPI service and bilingual web dashboard. Its principal workflow accepts a CSV through the CLI or service, chooses a batch or Spark loader, stores raw records in MongoDB, then cleans, classifies, and writes validated or quarantined records before recording run metrics. Separate product capabilities provide indexed queries, aggregations, materialized views, and scheduled KPI jobs. Relationships among unsampled modules are included only where the README or source index supports them; the excerpts do not expose every API route or storage detail.

Main entry points: [`main.py`](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/main.py) (Pipeline CLI), [`src/api.py`](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/api.py) (FastAPI Service), [`src/scheduler.py`](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/scheduler.py) (Job Scheduler), [`src/file_router.py`](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/file_router.py) (File Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data Ingestion"]
  node_csv_input["CSV Input"]
  node_cli["Pipeline CLI<br/>[main.py]"]
  node_router["File Router<br/>[file_router.py]"]
  node_batch["Batch Loader<br/>[batch_loader.py]"]
  node_spark["Spark Loader<br/>[spark_loader.py]"]
  node_mongo_setup["Mongo Setup<br/>[mongo_setup.py]"]
end

subgraph group_elt["ELT Processing"]
  node_mongo[("MongoDB")]
  node_elt_pipeline["ELT Pipeline<br/>[elt_pipeline.py]"]
  node_quality["Quality Rules<br/>[quality_rules.py]"]
  node_metrics["Run Metrics<br/>[metrics.py]"]
  node_results["Run Results<br/>[results.json]"]
end

subgraph group_analytics["Analytics"]
  node_indexes["Indexes and Queries<br/>[indexes_queries.py]"]
  node_aggregations["Aggregations<br/>[aggregations.py]"]
  node_views["Materialized Views"]
  node_scheduler["Job Scheduler<br/>[scheduler.py]"]
  node_kpi_report["Periodic KPI Report"]
end

subgraph group_serving["Product Interfaces"]
  node_api["FastAPI Service<br/>[api.py]"]
  node_dashboard["Web Dashboard<br/>[app.js]"]
  node_dashboard_page["Dashboard Page<br/>[index.html]"]
end

node_operator(("Operator"))

node_operator -->|"runs"| node_cli
node_operator -->|"uses"| node_api
node_operator -->|"uses"| node_dashboard
node_csv_input -->|"supplies data"| node_cli
node_cli -->|"initializes"| node_mongo_setup
node_cli -->|"selects engine"| node_router
node_router -->|"selects small-file"| node_batch
node_router -->|"selects large-file"| node_spark
node_batch -->|"writes raw records"| node_mongo
node_spark -->|"writes raw records"| node_mongo
node_cli -->|"loads raw data"| node_batch
node_cli -->|"loads raw data"| node_spark
node_cli -->|"runs ELT"| node_elt_pipeline
node_elt_pipeline -->|"reads and writes"| node_mongo
node_elt_pipeline -->|"applies rules"| node_quality
node_cli -->|"generates metrics"| node_metrics
node_metrics -->|"writes results"| node_results
node_indexes -->|"indexes and queries"| node_mongo
node_aggregations -->|"aggregates records"| node_mongo
node_views -->|"refreshes views"| node_mongo
node_scheduler -->|"refreshes"| node_views
node_scheduler -->|"writes report"| node_kpi_report
node_scheduler -->|"reads records and logs jobs"| node_mongo
node_api -->|"exposes operations"| node_indexes
node_api -->|"exposes reports"| node_aggregations
node_api -->|"exposes refresh"| node_views
node_api -->|"exposes job controls"| node_scheduler
node_api -->|"serves page"| node_dashboard_page
node_dashboard -->|"requests operations"| node_api
node_dashboard_page -.->|"loads interface logic"| node_dashboard

click node_csv_input "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/data/01_student_test_small.csv"
click node_cli "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/main.py"
click node_router "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/file_router.py"
click node_batch "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/batch_loader.py"
click node_spark "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/spark_loader.py"
click node_mongo_setup "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/mongo_setup.py"
click node_elt_pipeline "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/elt_pipeline.py"
click node_quality "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/quality_rules.py"
click node_metrics "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/metrics.py"
click node_results "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/reports/results.json"
click node_indexes "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/indexes_queries.py"
click node_aggregations "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/aggregations.py"
click node_views "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/materialized_views.py"
click node_scheduler "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/scheduler.py"
click node_kpi_report "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/reports/periodic_kpi_summary.json"
click node_api "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/api.py"
click node_dashboard "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/static/app.js"
click node_dashboard_page "https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/static/index.html"

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_input,node_cli,node_router,node_batch,node_spark,node_mongo_setup toneBlue
class node_mongo,node_elt_pipeline,node_quality,node_metrics,node_results toneAmber
class node_indexes,node_aggregations,node_views,node_scheduler,node_kpi_report toneMint
class node_api,node_dashboard,node_dashboard_page toneRose
class node_operator toneIndigo
```

## Components

### Data Ingestion

- [CSV Input](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/data/01_student_test_small.csv): `data/01_student_test_small.csv`
- [Pipeline CLI](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/main.py): `main.py`
- [File Router](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/file_router.py): `src/file_router.py`
- [Batch Loader](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/batch_loader.py): `src/batch_loader.py`
- [Spark Loader](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/spark_loader.py): `src/spark_loader.py`
- [Mongo Setup](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/mongo_setup.py): `src/mongo_setup.py`

### ELT Processing

- **MongoDB**
- [ELT Pipeline](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/elt_pipeline.py): `src/elt_pipeline.py`
- [Quality Rules](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/quality_rules.py): `src/quality_rules.py`
- [Run Metrics](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/metrics.py): `src/metrics.py`
- [Run Results](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/reports/results.json): `reports/results.json`

### Analytics

- [Indexes and Queries](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/indexes_queries.py): `src/indexes_queries.py`
- [Aggregations](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/aggregations.py): `src/aggregations.py`
- [Materialized Views](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/materialized_views.py): `src/materialized_views.py`
- [Job Scheduler](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/scheduler.py): `src/scheduler.py`
- [Periodic KPI Report](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/reports/periodic_kpi_summary.json): `reports/periodic_kpi_summary.json`

### Product Interfaces

- [FastAPI Service](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/src/api.py): `src/api.py`
- [Web Dashboard](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/static/app.js): `static/app.js`
- [Dashboard Page](https://github.com/bilal-alshami/bigdata-hybrid-pipeline/blob/main/static/index.html): `static/index.html`

### Other components

- **Operator**

## Connections

- Operator → Pipeline CLI: runs (evidence: `README.md`)
- Operator → FastAPI Service: uses (evidence: `README.md`)
- Operator → Web Dashboard: uses (evidence: `README.md`)
- CSV Input → Pipeline CLI: supplies data (evidence: `main.py`)
- Pipeline CLI → Mongo Setup: initializes (evidence: `main.py`)
- Pipeline CLI → File Router: selects engine (evidence: `main.py`)
- File Router → Batch Loader: selects small-file (evidence: `main.py`)
- File Router → Spark Loader: selects large-file (evidence: `main.py`)
- Batch Loader → MongoDB: writes raw records (evidence: `src/batch_loader.py`)
- Spark Loader → MongoDB: writes raw records (evidence: `src/spark_loader.py`)
- Pipeline CLI → Batch Loader: loads raw data (evidence: `main.py`)
- Pipeline CLI → Spark Loader: loads raw data (evidence: `main.py`)
- Pipeline CLI → ELT Pipeline: runs ELT (evidence: `main.py`)
- ELT Pipeline → MongoDB: reads and writes (evidence: `src/elt_pipeline.py`)
- ELT Pipeline → Quality Rules: applies rules (evidence: `src/elt_pipeline.py`)
- Pipeline CLI → Run Metrics: generates metrics (evidence: `main.py`)
- Run Metrics → Run Results: writes results (evidence: `src/metrics.py`)
- Indexes and Queries → MongoDB: indexes and queries (evidence: `src/indexes_queries.py`)
- Aggregations → MongoDB: aggregates records (evidence: `README.md`)
- Materialized Views → MongoDB: refreshes views (evidence: `src/materialized_views.py`)
- Job Scheduler → Materialized Views: refreshes (evidence: `src/scheduler.py`)
- Job Scheduler → Periodic KPI Report: writes report (evidence: `src/scheduler.py`)
- Job Scheduler → MongoDB: reads records and logs jobs (evidence: `src/scheduler.py`)
- FastAPI Service → Indexes and Queries: exposes operations (evidence: `README.md`)
- FastAPI Service → Aggregations: exposes reports (evidence: `README.md`)
- FastAPI Service → Materialized Views: exposes refresh (evidence: `README.md`)
- FastAPI Service → Job Scheduler: exposes job controls (evidence: `README.md`)
- FastAPI Service → Dashboard Page: serves page (evidence: `src/api.py`)
- Web Dashboard → FastAPI Service: requests operations (evidence: `README.md`)
- Dashboard Page → Web Dashboard: loads interface logic
