# timothylee58/slackbot-project architecture

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

- Interactive diagram: https://gitdiagram.com/timothylee58/slackbot-project
- Repository: https://github.com/timothylee58/slackbot-project

## Overview

This is a three-region weather and traffic notification service with an Express API, interactive map, scheduled and manual Slack delivery, runtime credential settings, and Prometheus metrics. The main workflow is scheduled or user-triggered notification → regional data collection → message formatting → Slack. API routes expose weather, traffic, combined status, location metadata, settings, and a Maps key. Some modules are represented from the source index and README rather than inspected excerpts; uncertain frontend-to-API wiring is omitted.

Main entry points: [`backend/services/slackService.js`](https://github.com/timothylee58/slackbot-project/blob/master/backend/services/slackService.js) (Message Builder and Sender), [`backend/routes/api.js`](https://github.com/timothylee58/slackbot-project/blob/master/backend/routes/api.js) (API Routes), [`backend/app.js`](https://github.com/timothylee58/slackbot-project/blob/master/backend/app.js) (Express App), [`backend/controllers/weatherController.js`](https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/weatherController.js) (Weather Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and API"]
  node_express["Express App<br/>[app.js]"]
  node_api["API Routes<br/>[api.js]"]
  node_pages["Page Routes<br/>[pages.js]"]
  node_webmap["Map UI<br/>[app.js]"]
  node_error["Error Handler<br/>[errorHandler.js]"]
end

subgraph group_data["Regional Data"]
  node_locations["Location Metadata<br/>[locations.js]"]
  node_weatherctl["Weather Controller"]
  node_trafficctl["Traffic Controller"]
  node_weather["Weather Fetch and Cache<br/>[weatherService.js]"]
  node_traffic["Traffic Fetch<br/>[trafficService.js]"]
  node_proxy["Maps Key Proxy"]
end

subgraph group_notify["Notifications"]
  node_cron["Cron Scheduler<br/>[cron-schedule.js]"]
  node_slackctl["Manual Trigger<br/>[slackController.js]"]
  node_slackservice["Message Builder and Sender<br/>[slackService.js]"]
end

subgraph group_ops["Settings and Metrics"]
  node_settingsctl["Settings Controller"]
  node_runtime["Runtime Settings<br/>[runtimeSettings.js]"]
  node_metrics["Prometheus Metrics<br/>[metrics.js]"]
end

node_operator(("Operator"))
node_mapuser(("Map User"))
node_weatherapi["Government Weather APIs"]
node_trafficapi["Transport Data APIs"]
node_maps["Google Maps"]
node_slack["Slack Channel"]

node_operator -->|"schedules updates"| node_cron
node_operator -->|"triggers manually"| node_slackctl
node_mapuser -->|"views map"| node_webmap
node_express -->|"mounts API"| node_api
node_express -->|"mounts pages"| node_pages
node_express -->|"records requests"| node_metrics
node_express -->|"handles errors"| node_error
node_api -->|"routes weather/status"| node_weatherctl
node_api -->|"routes traffic"| node_trafficctl
node_api -->|"serves locations"| node_slackctl
node_api -->|"routes map key"| node_proxy
node_api -->|"routes settings"| node_settingsctl
node_weatherctl -->|"fetches weather"| node_weather
node_weatherctl -->|"fetches traffic"| node_traffic
node_weatherctl -->|"validates regions"| node_locations
node_weather -->|"requests forecasts"| node_weatherapi
node_trafficctl -->|"fetches incidents"| node_traffic
node_traffic -->|"requests incidents"| node_trafficapi
node_cron -->|"runs notifications"| node_slackservice
node_slackctl -->|"sends notification"| node_slackservice
node_slackservice -->|"fetches regional weather"| node_weather
node_slackservice -->|"fetches regional traffic"| node_traffic
node_slackservice -->|"formats regions"| node_locations
node_slackservice -->|"reads credentials"| node_runtime
node_slackservice -->|"records durations"| node_metrics
node_slackservice -->|"posts message"| node_slack
node_settingsctl -->|"reads and updates"| node_runtime
node_proxy -->|"provides map key"| node_maps

click node_express "https://github.com/timothylee58/slackbot-project/blob/master/backend/app.js"
click node_api "https://github.com/timothylee58/slackbot-project/blob/master/backend/routes/api.js"
click node_pages "https://github.com/timothylee58/slackbot-project/blob/master/backend/routes/pages.js"
click node_webmap "https://github.com/timothylee58/slackbot-project/blob/master/backend/public/app.js"
click node_locations "https://github.com/timothylee58/slackbot-project/blob/master/backend/config/locations.js"
click node_weatherctl "https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/weatherController.js"
click node_trafficctl "https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/trafficController.js"
click node_weather "https://github.com/timothylee58/slackbot-project/blob/master/backend/services/weatherService.js"
click node_traffic "https://github.com/timothylee58/slackbot-project/blob/master/backend/services/trafficService.js"
click node_proxy "https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/weatherProxyController.js"
click node_cron "https://github.com/timothylee58/slackbot-project/blob/master/backend/cron-schedule.js"
click node_slackctl "https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/slackController.js"
click node_slackservice "https://github.com/timothylee58/slackbot-project/blob/master/backend/services/slackService.js"
click node_settingsctl "https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/settingsController.js"
click node_runtime "https://github.com/timothylee58/slackbot-project/blob/master/backend/config/runtimeSettings.js"
click node_metrics "https://github.com/timothylee58/slackbot-project/blob/master/backend/services/metrics.js"
click node_error "https://github.com/timothylee58/slackbot-project/blob/master/backend/middleware/errorHandler.js"

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_express,node_api,node_pages,node_webmap,node_error,node_mapuser toneBlue
class node_locations,node_weatherctl,node_trafficctl,node_weather,node_traffic,node_proxy toneAmber
class node_cron,node_slackctl,node_slackservice,node_weatherapi,node_trafficapi toneMint
class node_settingsctl,node_runtime,node_metrics toneRose
class node_operator,node_maps,node_slack toneIndigo
```

## Components

### Entry and API

- [Express App](https://github.com/timothylee58/slackbot-project/blob/master/backend/app.js): `backend/app.js`
- [API Routes](https://github.com/timothylee58/slackbot-project/blob/master/backend/routes/api.js): `backend/routes/api.js`
- [Page Routes](https://github.com/timothylee58/slackbot-project/blob/master/backend/routes/pages.js): `backend/routes/pages.js`
- [Map UI](https://github.com/timothylee58/slackbot-project/blob/master/backend/public/app.js): `backend/public/app.js`
- [Error Handler](https://github.com/timothylee58/slackbot-project/blob/master/backend/middleware/errorHandler.js): `backend/middleware/errorHandler.js`

### Regional Data

- [Location Metadata](https://github.com/timothylee58/slackbot-project/blob/master/backend/config/locations.js): `backend/config/locations.js`
- [Weather Controller](https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/weatherController.js): `backend/controllers/weatherController.js`
- [Traffic Controller](https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/trafficController.js): `backend/controllers/trafficController.js`
- [Weather Fetch and Cache](https://github.com/timothylee58/slackbot-project/blob/master/backend/services/weatherService.js): `backend/services/weatherService.js`
- [Traffic Fetch](https://github.com/timothylee58/slackbot-project/blob/master/backend/services/trafficService.js): `backend/services/trafficService.js`
- [Maps Key Proxy](https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/weatherProxyController.js): `backend/controllers/weatherProxyController.js`

### Notifications

- [Cron Scheduler](https://github.com/timothylee58/slackbot-project/blob/master/backend/cron-schedule.js): `backend/cron-schedule.js`
- [Manual Trigger](https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/slackController.js): `backend/controllers/slackController.js`
- [Message Builder and Sender](https://github.com/timothylee58/slackbot-project/blob/master/backend/services/slackService.js): `backend/services/slackService.js`

### Settings and Metrics

- [Settings Controller](https://github.com/timothylee58/slackbot-project/blob/master/backend/controllers/settingsController.js): `backend/controllers/settingsController.js`
- [Runtime Settings](https://github.com/timothylee58/slackbot-project/blob/master/backend/config/runtimeSettings.js): `backend/config/runtimeSettings.js`
- [Prometheus Metrics](https://github.com/timothylee58/slackbot-project/blob/master/backend/services/metrics.js): `backend/services/metrics.js`

### Other components

- **Operator**
- **Map User**
- **Government Weather APIs**
- **Transport Data APIs**
- **Google Maps**
- **Slack Channel**

## Connections

- Operator → Cron Scheduler: schedules updates (evidence: `README.md`)
- Operator → Manual Trigger: triggers manually (evidence: `README.md`)
- Map User → Map UI: views map (evidence: `README.md`)
- Express App → API Routes: mounts API (evidence: `backend/app.js`)
- Express App → Page Routes: mounts pages (evidence: `backend/app.js`)
- Express App → Prometheus Metrics: records requests (evidence: `backend/app.js`)
- Express App → Error Handler: handles errors (evidence: `backend/app.js`)
- API Routes → Weather Controller: routes weather/status (evidence: `backend/routes/api.js`)
- API Routes → Traffic Controller: routes traffic (evidence: `backend/routes/api.js`)
- API Routes → Manual Trigger: serves locations (evidence: `backend/routes/api.js`)
- API Routes → Maps Key Proxy: routes map key (evidence: `backend/routes/api.js`)
- API Routes → Settings Controller: routes settings (evidence: `backend/routes/api.js`)
- Weather Controller → Weather Fetch and Cache: fetches weather (evidence: `backend/controllers/weatherController.js`)
- Weather Controller → Traffic Fetch: fetches traffic (evidence: `backend/controllers/weatherController.js`)
- Weather Controller → Location Metadata: validates regions (evidence: `backend/controllers/weatherController.js`)
- Weather Fetch and Cache → Government Weather APIs: requests forecasts (evidence: `backend/services/weatherService.js`)
- Traffic Controller → Traffic Fetch: fetches incidents (evidence: `backend/controllers/trafficController.js`)
- Traffic Fetch → Transport Data APIs: requests incidents (evidence: `backend/services/trafficService.js`)
- Cron Scheduler → Message Builder and Sender: runs notifications (evidence: `backend/cron-schedule.js`)
- Manual Trigger → Message Builder and Sender: sends notification (evidence: `backend/controllers/slackController.js`)
- Message Builder and Sender → Weather Fetch and Cache: fetches regional weather (evidence: `backend/services/slackService.js`)
- Message Builder and Sender → Traffic Fetch: fetches regional traffic (evidence: `backend/services/slackService.js`)
- Message Builder and Sender → Location Metadata: formats regions (evidence: `backend/services/slackService.js`)
- Message Builder and Sender → Runtime Settings: reads credentials (evidence: `backend/services/slackService.js`)
- Message Builder and Sender → Prometheus Metrics: records durations (evidence: `backend/services/slackService.js`)
- Message Builder and Sender → Slack Channel: posts message (evidence: `README.md`)
- Settings Controller → Runtime Settings: reads and updates (evidence: `backend/controllers/settingsController.js`)
- Maps Key Proxy → Google Maps: provides map key (evidence: `README.md`)
