# tansatwibu/works_2 architecture

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

- Interactive diagram: https://gitdiagram.com/tansatwibu/works_2
- Repository: https://github.com/tansatwibu/works_2

## Overview

Long Chau Store Intelligence collects store data for three brands, tracks daily presence and changes, and serves a browser dashboard for exploring store counts, locations and events. The main workflow runs crawlers, persists snapshots and store records in MongoDB, then exposes them through HTTP APIs to the dashboard. The README documents the scheduled three-crawler run; crawler-to-sync wiring is not shown in the sampled excerpts, so that handoff is not drawn. The dashboard’s stores and events capabilities are represented even though their full UI flow was not sampled.

Main entry points: [`run_daily.ps1`](https://github.com/tansatwibu/works_2/blob/main/run_daily.ps1) (Daily scheduler), [`frontend/dashboardView.js`](https://github.com/tansatwibu/works_2/blob/main/frontend/dashboardView.js) (Dashboard views), [`frontend/dashboardController.js`](https://github.com/tansatwibu/works_2/blob/main/frontend/dashboardController.js) (UI controller), [`server.js`](https://github.com/tansatwibu/works_2/blob/main/server.js) (HTTP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Data collection"]
  node_scheduler["Daily scheduler<br/>[run_daily.ps1]"]
  node_longchau_crawler["Long Chau crawler<br/>[crawl_nhathuoc.py]"]
  node_bhx_crawler["Bách Hoá Xanh crawler<br/>[crawl_bhx.py]"]
  node_vaccine_crawler["Vaccination crawler<br/>[crawl_tiemchung.py]"]
end

subgraph group_tracking["Daily tracking"]
  node_node_sync["Node sync<br/>[sync_daily.js]"]
  node_python_sync["Python sync<br/>[sync_daily.py]"]
  node_mongo[("MongoDB")]
end

subgraph group_backend["Dashboard backend"]
  node_web_server["HTTP server<br/>[server.js]"]
  node_api_routes["API routes<br/>[apiRoutes.js]"]
  node_api_controller["Dashboard controller"]
  node_dashboard_model["Dashboard data model<br/>[dashboardModel.js]"]
end

subgraph group_frontend["Dashboard interface"]
  node_dashboard_shell["Dashboard shell<br/>[dashboard.html]"]
  node_ui_controller["UI controller"]
  node_ui_model["API client<br/>[dashboardModel.js]"]
  node_chart_utils["Chart utilities<br/>[chartUtils.js]"]
  node_ui_view["Dashboard views<br/>[dashboardView.js]"]
  node_stats_view["Stats dashboard<br/>[dashboard.html]"]
  node_stores_view["Store listing<br/>[dashboard.html]"]
  node_events_view["Store events<br/>[dashboard.html]"]
end

node_operator(("Operator"))
node_browser(("Dashboard user"))

node_operator -->|"starts daily run"| node_scheduler
node_scheduler -->|"runs crawler"| node_longchau_crawler
node_scheduler -->|"runs crawler"| node_bhx_crawler
node_scheduler -->|"runs crawler"| node_vaccine_crawler
node_node_sync -->|"writes records"| node_mongo
node_python_sync -->|"writes records"| node_mongo
node_operator -->|"opens dashboard"| node_web_server
node_web_server -->|"resolves route"| node_api_routes
node_web_server -->|"serves static files"| node_dashboard_shell
node_api_routes -->|"dispatches request"| node_api_controller
node_api_controller -->|"calls query"| node_dashboard_model
node_dashboard_model -->|"queries collections"| node_mongo
node_browser -->|"uses dashboard"| node_dashboard_shell
node_ui_controller -->|"requests data"| node_ui_model
node_ui_model -->|"fetches API"| node_api_routes
node_ui_controller -->|"calculates date range"| node_chart_utils
node_ui_controller -->|"renders results"| node_ui_view
node_ui_view -->|"updates dashboard"| node_stats_view
node_ui_view -->|"renders stores"| node_stores_view
node_ui_view -->|"renders events"| node_events_view

click node_scheduler "https://github.com/tansatwibu/works_2/blob/main/run_daily.ps1"
click node_longchau_crawler "https://github.com/tansatwibu/works_2/blob/main/crawl_nhathuoc.py"
click node_bhx_crawler "https://github.com/tansatwibu/works_2/blob/main/crawl_bhx.py"
click node_vaccine_crawler "https://github.com/tansatwibu/works_2/blob/main/crawl_tiemchung.py"
click node_node_sync "https://github.com/tansatwibu/works_2/blob/main/sync_daily.js"
click node_python_sync "https://github.com/tansatwibu/works_2/blob/main/sync_daily.py"
click node_web_server "https://github.com/tansatwibu/works_2/blob/main/server.js"
click node_api_routes "https://github.com/tansatwibu/works_2/blob/main/src/routes/apiRoutes.js"
click node_api_controller "https://github.com/tansatwibu/works_2/blob/main/src/controllers/dashboardController.js"
click node_dashboard_model "https://github.com/tansatwibu/works_2/blob/main/src/models/dashboardModel.js"
click node_dashboard_shell "https://github.com/tansatwibu/works_2/blob/main/dashboard.html"
click node_ui_controller "https://github.com/tansatwibu/works_2/blob/main/frontend/dashboardController.js"
click node_ui_model "https://github.com/tansatwibu/works_2/blob/main/frontend/dashboardModel.js"
click node_chart_utils "https://github.com/tansatwibu/works_2/blob/main/frontend/chartUtils.js"
click node_ui_view "https://github.com/tansatwibu/works_2/blob/main/frontend/dashboardView.js"
click node_stats_view "https://github.com/tansatwibu/works_2/blob/main/dashboard.html"
click node_stores_view "https://github.com/tansatwibu/works_2/blob/main/dashboard.html"
click node_events_view "https://github.com/tansatwibu/works_2/blob/main/dashboard.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_scheduler,node_longchau_crawler,node_bhx_crawler,node_vaccine_crawler,node_browser toneBlue
class node_node_sync,node_python_sync,node_mongo toneAmber
class node_web_server,node_api_routes,node_api_controller,node_dashboard_model toneMint
class node_dashboard_shell,node_ui_controller,node_ui_model,node_chart_utils,node_ui_view,node_stats_view,node_stores_view,node_events_view toneRose
class node_operator toneIndigo
```

## Components

### Data collection

- [Daily scheduler](https://github.com/tansatwibu/works_2/blob/main/run_daily.ps1): `run_daily.ps1`
- [Long Chau crawler](https://github.com/tansatwibu/works_2/blob/main/crawl_nhathuoc.py): `crawl_nhathuoc.py`
- [Bách Hoá Xanh crawler](https://github.com/tansatwibu/works_2/blob/main/crawl_bhx.py): `crawl_bhx.py`
- [Vaccination crawler](https://github.com/tansatwibu/works_2/blob/main/crawl_tiemchung.py): `crawl_tiemchung.py`

### Daily tracking

- [Node sync](https://github.com/tansatwibu/works_2/blob/main/sync_daily.js): `sync_daily.js`
- [Python sync](https://github.com/tansatwibu/works_2/blob/main/sync_daily.py): `sync_daily.py`
- **MongoDB**

### Dashboard backend

- [HTTP server](https://github.com/tansatwibu/works_2/blob/main/server.js): `server.js`
- [API routes](https://github.com/tansatwibu/works_2/blob/main/src/routes/apiRoutes.js): `src/routes/apiRoutes.js`
- [Dashboard controller](https://github.com/tansatwibu/works_2/blob/main/src/controllers/dashboardController.js): `src/controllers/dashboardController.js`
- [Dashboard data model](https://github.com/tansatwibu/works_2/blob/main/src/models/dashboardModel.js): `src/models/dashboardModel.js`

### Dashboard interface

- [Dashboard shell](https://github.com/tansatwibu/works_2/blob/main/dashboard.html): `dashboard.html`
- [UI controller](https://github.com/tansatwibu/works_2/blob/main/frontend/dashboardController.js): `frontend/dashboardController.js`
- [API client](https://github.com/tansatwibu/works_2/blob/main/frontend/dashboardModel.js): `frontend/dashboardModel.js`
- [Chart utilities](https://github.com/tansatwibu/works_2/blob/main/frontend/chartUtils.js): `frontend/chartUtils.js`
- [Dashboard views](https://github.com/tansatwibu/works_2/blob/main/frontend/dashboardView.js): `frontend/dashboardView.js`
- [Stats dashboard](https://github.com/tansatwibu/works_2/blob/main/dashboard.html): `dashboard.html`
- [Store listing](https://github.com/tansatwibu/works_2/blob/main/dashboard.html): `dashboard.html`
- [Store events](https://github.com/tansatwibu/works_2/blob/main/dashboard.html): `dashboard.html`

### Other components

- **Operator**
- **Dashboard user**

## Connections

- Operator → Daily scheduler: starts daily run (evidence: `README.md`)
- Daily scheduler → Long Chau crawler: runs crawler (evidence: `README.md`)
- Daily scheduler → Bách Hoá Xanh crawler: runs crawler (evidence: `README.md`)
- Daily scheduler → Vaccination crawler: runs crawler (evidence: `README.md`)
- Node sync → MongoDB: writes records (evidence: `sync_daily.js`)
- Python sync → MongoDB: writes records (evidence: `sync_daily.py`)
- Operator → HTTP server: opens dashboard (evidence: `README.md`)
- HTTP server → API routes: resolves route (evidence: `server.js`)
- HTTP server → Dashboard shell: serves static files (evidence: `server.js`)
- API routes → Dashboard controller: dispatches request (evidence: `src/routes/apiRoutes.js`)
- Dashboard controller → Dashboard data model: calls query (evidence: `src/controllers/dashboardController.js`)
- Dashboard data model → MongoDB: queries collections (evidence: `src/models/dashboardModel.js`)
- Dashboard user → Dashboard shell: uses dashboard (evidence: `README.md`)
- UI controller → API client: requests data (evidence: `frontend/dashboardController.js`)
- API client → API routes: fetches API (evidence: `frontend/dashboardModel.js`)
- UI controller → Chart utilities: calculates date range (evidence: `frontend/dashboardController.js`)
- UI controller → Dashboard views: renders results (evidence: `frontend/dashboardController.js`)
- Dashboard views → Stats dashboard: updates dashboard (evidence: `frontend/dashboardView.js`)
- Dashboard views → Store listing: renders stores (evidence: `frontend/dashboardView.js`)
- Dashboard views → Store events: renders events (evidence: `frontend/dashboardView.js`)
