# muhammad-hassaan11/etl---coding-night- architecture

> Architecture diagram of the GitHub repository muhammad-hassaan11/etl---coding-night-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/muhammad-hassaan11/etl---coding-night-
- Repository: https://github.com/muhammad-hassaan11/etl---coding-night-

## Overview

1. This repository is a small end-to-end analytics pipeline, not a multi-service application. The core flow is: scrape RC product data from Banggood, persist it as flat files, analyze it in SQL, and present it in a Streamlit dashboard.

2. The data acquisition boundary lives in `CODING NIGHT HACKATHON.ipynb`. That notebook uses Selenium for browser automation and BeautifulSoup for HTML parsing to extract product records from Banggood’s product pages. This is the only place where live web interaction happens.

3. The scraper outputs structured snapshots into `rc_products.csv` and `rc_products.json`. These files are the handoff point between acquisition and downstream analysis; they contain the shared product schema: category, name, prices in multiple currencies, rating, URL, and image link.

4. `app.py` is the presentation layer. It is a Streamlit app that loads the scraped CSV, performs in-memory cleaning and aggregation with pandas/NumPy/regex, and renders interactive charts with Matplotlib.

5. The dashboard is built around a few analytical views rather than transactional UI: summary metrics, category price distributions, price-vs-rating scatter analysis, top-rated products, category counts, and a raw-data/diagnostics section. Its role is consumption and exploration of the dataset, not data collection.

6. `code night sql code.sql` is a separate analytics layer. It contains SQL queries for category-level aggregation, rating analysis, price banding, ranking, and value scoring. This suggests a relational database is used for deeper analysis, but that database is external to the files in the repo.

7. The main data contract across the system is the product table. Every downstream component assumes consistent column names and types from the scraper output; the Streamlit app and SQL queries both depend on that schema.

8. The key architectural boundary is between raw scraped data and analytical consumers. The notebook is responsible for noisy, web-specific extraction; the dashboard and SQL script assume cleaned, tabular data and do not deal with browser automation.

9. There is no backend API, message queue, scheduler, or server-side application logic in this repo. The runtime is mostly local and manual: Jupyter for scraping, file-based storage for interchange, and Streamlit for interactive visualization.

10. Relevant technologies that materially shape the architecture are Python, Selenium/ChromeDriver, BeautifulSoup, pandas, Streamlit, Matplotlib, and SQL. The architecture is lightweight and file-driven, with CSV/JSON acting as the integration layer between scraping, analysis, and visualization.

Main entry points: [`code night sql code.sql`](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/HEAD/code%20night%20sql%20code.sql) (SQL analysis), [`rc_products.csv`](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/rc_products.csv) (CSV snapshot), [`CODING NIGHT HACKATHON.ipynb`](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/HEAD/CODING%20NIGHT%20HACKATHON.ipynb) (Scrape notebook), [`app.py`](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/app.py) (Dashboard app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Acquisition"]
  node_n1["Scrape notebook<br/>jupyter scraper"]
  node_n2["Browser automation<br/>selenium"]
  node_n3["HTML parsing<br/>bs4 parser"]
end

subgraph group_g2["Analytics"]
  node_n7["Dashboard app<br/>streamlit app<br/>[app.py]"]
  node_n8["Data prep<br/>pandas/numPy"]
  node_n9["Metrics views<br/>summary analytics"]
  node_n10["Distribution plots<br/>matplotlib charts"]
  node_n11["Top products<br/>ranked view"]
  node_n12["Diagnostics view<br/>raw-data view"]
  node_n13["SQL analysis<br/>sql script"]
  node_n14["Category aggregates<br/>sql aggregation"]
  node_n15["Ranking & scoring<br/>sql analytics"]
end

subgraph group_g3["Data files"]
  node_n4["Product schema<br/>record contract"]
  node_n5["CSV snapshot<br/>flat file<br/>[rc_products.csv]"]
  node_n6["JSON snapshot<br/>flat file<br/>[rc_products.json]"]
end

node_n1 -->|"drives"| node_n2
node_n1 -->|"parses"| node_n3
node_n2 -->|"feeds"| node_n3
node_n3 -->|"extracts"| node_n4
node_n4 -->|"writes"| node_n5
node_n4 -->|"writes"| node_n6
node_n5 -->|"loads"| node_n7
node_n7 -->|"prepares"| node_n8
node_n8 -->|"supports"| node_n9
node_n8 -->|"supports"| node_n10
node_n8 -->|"supports"| node_n11
node_n8 -->|"supports"| node_n12
node_n5 -->|"analyzed by"| node_n13
node_n13 -->|"queries"| node_n14
node_n13 -->|"queries"| node_n15

click node_n1 "https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/CODING NIGHT HACKATHON.ipynb"
click node_n5 "https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/rc_products.csv"
click node_n6 "https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/rc_products.json"
click node_n7 "https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/app.py"
click node_n13 "https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/code night sql code.sql"

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_n1,node_n2,node_n3 toneBlue
class node_n7,node_n8,node_n9,node_n10,node_n11,node_n12,node_n13,node_n14,node_n15 toneAmber
class node_n4,node_n5,node_n6 toneMint
```

## Components

### Acquisition

Live scraping and file output

- [Scrape notebook](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/HEAD/CODING%20NIGHT%20HACKATHON.ipynb): jupyter scraper · Orchestrates the Banggood scraping workflow · `CODING NIGHT HACKATHON.ipynb`
- **Browser automation**: selenium · Drives live page navigation and interaction
- **HTML parsing**: bs4 parser · Extracts product fields from rendered pages

### Analytics

SQL and dashboard consumers

- [Dashboard app](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/app.py): streamlit app · Interactive analytics and presentation layer · `app.py`
- **Data prep**: pandas/numPy · Cleans, filters, and aggregates scraped rows in memory
- **Metrics views**: summary analytics · Builds overview KPIs and category counts
- **Distribution plots**: matplotlib charts · Renders price distributions and scatter analysis
- **Top products**: ranked view · Highlights top-rated products and value candidates
- **Diagnostics view**: raw-data view · Shows raw rows and inspection output
- [SQL analysis](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/HEAD/code%20night%20sql%20code.sql): sql script · Standalone relational analysis queries · `code night sql code.sql`
- **Category aggregates**: sql aggregation · Category-level counts and summaries
- **Ranking & scoring**: sql analytics · Rating analysis, price bands, and value scoring

### Data files

Shared flat-file contract

- **Product schema**: record contract · Shared product fields: category, name, prices, rating, URL, image
- [CSV snapshot](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/rc_products.csv): flat file · Primary tabular handoff for downstream analysis · `rc_products.csv`
- [JSON snapshot](https://github.com/muhammad-hassaan11/etl---coding-night-/blob/master/rc_products.json): flat file · Alternate structured handoff for the same scraped records · `rc_products.json`

## Connections

- Scrape notebook → Browser automation: drives · The notebook uses Selenium for live browsing
- Scrape notebook → HTML parsing: parses · Rendered HTML is parsed with BeautifulSoup
- Browser automation → HTML parsing: feeds · Browser output is passed to the parser
- HTML parsing → Product schema: extracts · Parsed fields are normalized into the shared product schema
- Product schema → CSV snapshot: writes · Structured records are persisted as CSV snapshots
- Product schema → JSON snapshot: writes · Structured records are also persisted as JSON snapshots
- CSV snapshot → Dashboard app: loads · The dashboard reads the scraped CSV
- Dashboard app → Data prep: prepares · The app cleans and reshapes data before display
- Data prep → Metrics views: supports · Prepared data feeds summary metrics and category counts
- Data prep → Distribution plots: supports · Prepared data feeds distribution and scatter plots
- Data prep → Top products: supports · Prepared data feeds top-rated and value-focused views
- Data prep → Diagnostics view: supports · Prepared data feeds raw-data and diagnostics panels
- CSV snapshot → SQL analysis: analyzed by · The SQL layer operates on the same tabular product data
- SQL analysis → Category aggregates: queries · SQL includes category-level aggregation logic
- SQL analysis → Ranking & scoring: queries · SQL includes ranking, rating, price banding, and value scoring
