# varshukarthik/peak-signal architecture

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

- Interactive diagram: https://gitdiagram.com/varshukarthik/peak-signal
- Repository: https://github.com/varshukarthik/peak-signal

## Overview

PeakSignal is a day-ahead electricity forecasting and microgrid capacity-planning web platform. Planners and analysts use its browser pages to forecast household demand, inspect historical usage, manage portfolios, test scenarios, and review reports and prediction history; the frontend communicates with a FastAPI service backed by MySQL. Its internal data layer provides persistence and analytical queries, while a seed pipeline prepares reference data and model-insight snapshots. The README documents the major capabilities and stack; source excerpts confirm selected backend/data calls, but most page-to-endpoint wiring was not sampled.

Main entry points: [`frontend/js/api.js`](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/api.js) (API client), [`backend/main.py`](https://github.com/varshukarthik/peak-signal/blob/main/backend/main.py) (Forecast and analytics API), [`backend/db.py`](https://github.com/varshukarthik/peak-signal/blob/main/backend/db.py) (Persistence and analytics), [`frontend/js/history.js`](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/history.js) (Prediction history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web experience"]
  node_overview_ui["Overview<br/>[overview.js]"]
  node_history_ui["Prediction history<br/>[history.js]"]
  node_reports_ui["Reports<br/>[reports.js]"]
  node_insights_ui["Model insights<br/>[model-insights.js]"]
  node_shared_shell["Navigation and shared UI<br/>[common.js]"]
  node_charting["Charts<br/>[charts.js]"]
  node_about_ui["Methodology page<br/>[about.js]"]
end

subgraph group_forecasting["Forecasting"]
  node_forecast_ui["Day-ahead forecast<br/>[forecast.js]"]
  node_simulator_ui["What-if simulator<br/>[simulator.js]"]
  node_model_runtime["Forecast model runtime<br/>[main.py]"]
  node_training["Model training<br/>[train_model.py]"]
end

subgraph group_planning["Planning analytics"]
  node_portfolio_ui["Portfolio manager<br/>[portfolio.js]"]
  node_explorer_ui["Demand explorer<br/>[explorer.js]"]
  node_peak_ui["Peak thresholds<br/>[peak-load.js]"]
end

subgraph group_service["API and data"]
  node_browser_api["API client<br/>[api.js]"]
  node_fastapi["Forecast and analytics API<br/>[main.py]"]
  node_data_layer["Persistence and analytics<br/>[db.py]"]
  node_mysql[("MySQL database<br/>[schema.sql]")]
  node_seed_pipeline["Reference data seeding<br/>[seed.py]"]
end

node_planner(("Planner or analyst"))

node_planner -->|"requests forecast"| node_forecast_ui
node_planner -->|"tests scenarios"| node_simulator_ui
node_planner -->|"manages capacity"| node_portfolio_ui
node_planner -->|"explores demand"| node_explorer_ui
node_planner -->|"reviews history"| node_history_ui
node_planner -->|"exports reports"| node_reports_ui
node_forecast_ui -.->|"requests data"| node_browser_api
node_simulator_ui -.->|"requests data"| node_browser_api
node_portfolio_ui -.->|"requests data"| node_browser_api
node_explorer_ui -.->|"requests data"| node_browser_api
node_peak_ui -.->|"requests data"| node_browser_api
node_overview_ui -.->|"requests data"| node_browser_api
node_history_ui -.->|"requests data"| node_browser_api
node_reports_ui -.->|"requests data"| node_browser_api
node_insights_ui -.->|"requests data"| node_browser_api
node_browser_api -->|"calls service"| node_fastapi
node_fastapi -->|"predicts demand"| node_model_runtime
node_fastapi -->|"queries and updates"| node_data_layer
node_data_layer -.->|"reads and writes"| node_mysql
node_seed_pipeline -->|"loads reference data"| node_data_layer
node_training -.->|"trains model"| node_model_runtime
node_shared_shell -.->|"supports views"| node_charting

click node_forecast_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/forecast.js"
click node_simulator_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/simulator.js"
click node_portfolio_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/portfolio.js"
click node_explorer_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/explorer.js"
click node_peak_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/peak-load.js"
click node_overview_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/overview.js"
click node_history_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/history.js"
click node_reports_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/reports.js"
click node_insights_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/model-insights.js"
click node_shared_shell "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/common.js"
click node_charting "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/charts.js"
click node_browser_api "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/api.js"
click node_fastapi "https://github.com/varshukarthik/peak-signal/blob/main/backend/main.py"
click node_model_runtime "https://github.com/varshukarthik/peak-signal/blob/main/backend/main.py"
click node_data_layer "https://github.com/varshukarthik/peak-signal/blob/main/backend/db.py"
click node_mysql "https://github.com/varshukarthik/peak-signal/blob/main/backend/schema.sql"
click node_seed_pipeline "https://github.com/varshukarthik/peak-signal/blob/main/backend/seed.py"
click node_training "https://github.com/varshukarthik/peak-signal/blob/main/train_model.py"
click node_about_ui "https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/about.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_overview_ui,node_history_ui,node_reports_ui,node_insights_ui,node_shared_shell,node_charting,node_about_ui toneBlue
class node_forecast_ui,node_simulator_ui,node_model_runtime,node_training toneAmber
class node_portfolio_ui,node_explorer_ui,node_peak_ui toneMint
class node_browser_api,node_fastapi,node_data_layer,node_mysql,node_seed_pipeline toneRose
class node_planner toneIndigo
```

## Components

### Web experience

- [Overview](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/overview.js): `frontend/js/overview.js`
- [Prediction history](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/history.js): `frontend/js/history.js`
- [Reports](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/reports.js): `frontend/js/reports.js`
- [Model insights](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/model-insights.js): `frontend/js/model-insights.js`
- [Navigation and shared UI](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/common.js): `frontend/js/common.js`
- [Charts](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/charts.js): `frontend/js/charts.js`
- [Methodology page](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/about.js): `frontend/js/about.js`

### Forecasting

- [Day-ahead forecast](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/forecast.js): `frontend/js/forecast.js`
- [What-if simulator](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/simulator.js): `frontend/js/simulator.js`
- [Forecast model runtime](https://github.com/varshukarthik/peak-signal/blob/main/backend/main.py): `backend/main.py`
- [Model training](https://github.com/varshukarthik/peak-signal/blob/main/train_model.py): `train_model.py`

### Planning analytics

- [Portfolio manager](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/portfolio.js): `frontend/js/portfolio.js`
- [Demand explorer](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/explorer.js): `frontend/js/explorer.js`
- [Peak thresholds](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/peak-load.js): `frontend/js/peak-load.js`

### API and data

- [API client](https://github.com/varshukarthik/peak-signal/blob/main/frontend/js/api.js): `frontend/js/api.js`
- [Forecast and analytics API](https://github.com/varshukarthik/peak-signal/blob/main/backend/main.py): `backend/main.py`
- [Persistence and analytics](https://github.com/varshukarthik/peak-signal/blob/main/backend/db.py): `backend/db.py`
- [MySQL database](https://github.com/varshukarthik/peak-signal/blob/main/backend/schema.sql): `backend/schema.sql`
- [Reference data seeding](https://github.com/varshukarthik/peak-signal/blob/main/backend/seed.py): `backend/seed.py`

### Other components

- **Planner or analyst**

## Connections

- Planner or analyst → Day-ahead forecast: requests forecast (evidence: `README.md`)
- Planner or analyst → What-if simulator: tests scenarios (evidence: `README.md`)
- Planner or analyst → Portfolio manager: manages capacity (evidence: `README.md`)
- Planner or analyst → Demand explorer: explores demand (evidence: `README.md`)
- Planner or analyst → Prediction history: reviews history (evidence: `README.md`)
- Planner or analyst → Reports: exports reports (evidence: `README.md`)
- Day-ahead forecast → API client: requests data
- What-if simulator → API client: requests data
- Portfolio manager → API client: requests data
- Demand explorer → API client: requests data
- Peak thresholds → API client: requests data
- Overview → API client: requests data
- Prediction history → API client: requests data
- Reports → API client: requests data
- Model insights → API client: requests data
- API client → Forecast and analytics API: calls service (evidence: `README.md`)
- Forecast and analytics API → Forecast model runtime: predicts demand (evidence: `backend/main.py`)
- Forecast and analytics API → Persistence and analytics: queries and updates (evidence: `backend/main.py`)
- Persistence and analytics → MySQL database: reads and writes (evidence: `README.md`)
- Reference data seeding → Persistence and analytics: loads reference data (evidence: `backend/seed.py`)
- Model training → Forecast model runtime: trains model
- Navigation and shared UI → Charts: supports views
