# retr0alfred/voltwise architecture

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

- Interactive diagram: https://gitdiagram.com/retr0alfred/voltwise
- Repository: https://github.com/retr0alfred/voltwise

## Overview

#### Purpose and Runtime

VoltWise is a frontend-first energy-trading analytics dashboard for Indian power-market (IEX), demand, weather, and engineered market-feature data. It runs as a React 18 + TypeScript single-page application built and served by Vite. The backend is only a placeholder at `backend/.gitkeep`; no API, model-serving, or persistence layer is implemented.

Primary browser entry points are `frontend/index.html`, `frontend/src/main.tsx`, and `frontend/src/App.tsx`.

#### Application Shell and Navigation

`frontend/src/App.tsx` defines the application-level composition and route-driven page selection using React Router. The shared navigation shell is implemented in `frontend/src/components/Navbar.tsx`.

The main user-facing routes/pages are:
- Dashboard: `frontend/src/pages/Dashboard.tsx`
- Predictions scaffold: `frontend/src/pages/Predictions.tsx`
- Team/about content: `frontend/src/pages/AboutUs.tsx`

The Predictions route is intentionally a UI boundary for future backend/model integration, represented by `frontend/src/components/predictions/PredictionsPlaceholder.tsx`.

#### Data Boundary: Static CSVs in the Browser

All current analytics data is static and publicly served from `frontend/public/data/`, with no server-side transformation at runtime:
- IEX market data: `frontend/public/data/IEX.csv`
- Demand data: `frontend/public/data/demand.csv`
- Weather history: `frontend/public/data/weather.csv`
- Merged/engineered features: `frontend/public/data/voltwise_final.csv`

This means browser download size, parsing, and visualization performance are the primary operational constraints. There is currently no authentication, remote service dependency, database, or API contract.

#### CSV Ingestion and Data Normalization

`frontend/src/hooks/useCSVData.ts` is the central client-side ingestion boundary. It uses PapaParse with a worker-first parsing strategy and fallback handling, isolating CSV fetch/parse lifecycle from rendering components.

`frontend/src/utils/dataHelpers.ts` contains shared parsing, types, and data-shaping logic. Dashboard consumers should depend on these normalized structures rather than directly interpreting raw CSV fields. This is the natural replacement boundary if static files are later exchanged for backend APIs or model outputs.

#### Dashboard Analytics Composition

`frontend/src/pages/Dashboard.tsx` orchestrates dataset loading and presents the analytics modules. Visualization is decomposed by domain:
- Market pricing and IEX signals: `frontend/src/components/dashboard/IEXChart.tsx`
- National/regional demand: `frontend/src/components/dashboard/DemandChart.tsx`
- Multi-city weather: `frontend/src/components/dashboard/WeatherChart.tsx`
- Aggregate indicators: `frontend/src/components/dashboard/KPICards.tsx`
- Data-driven narrative/summary: `frontend/src/components/dashboard/VoltWiseSummary.tsx`

Charts use Recharts and intentionally minimize heavy animation for stability with large CSV datasets. The flow is static files → PapaParse/normalization → page-level state → chart/KPI props → browser-rendered visuals.

#### UI State and Design System

Theme state is centrally exposed through `frontend/src/context/ThemeContext.tsx`, allowing shared presentation behavior across the application shell and pages. Global styling is rooted at `frontend/src/styles/globals.css`, with Tailwind configured through `frontend/tailwind.config.ts`.

The frontend uses Tailwind CSS for styling and Lucide React for icons. Component-level presentation is separated from data ingestion, so dashboard visual components can be retained when a future service changes the data source.

#### Deployment and Future Integration

The deployable unit is the Vite frontend under `frontend/`, configured by `frontend/vite.config.ts` and dependency/runtime definitions in `frontend/package.json`. Production output is static client assets and can be hosted on any static web host.

Future prediction architecture should introduce an API/model boundary behind the existing predictions page, likely replacing or extending the CSV hook with typed asynchronous service clients. The empty `backend/` directory marks the intended location for that implementation, but no backend runtime or external ML service is presently defined.

Main entry points: [`frontend/src/App.tsx`](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/App.tsx) (App router and shell), [`frontend/src/pages/Dashboard.tsx`](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/pages/Dashboard.tsx) (Dashboard page), [`frontend/src/hooks/useCSVData.ts`](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/hooks/useCSVData.ts) (CSV ingestion hook), [`backend/.gitkeep`](https://github.com/retr0alfred/voltwise/blob/master/backend/.gitkeep) (Reserved backend directory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend Runtime"]
  node_vite{{"Vite build and static host<br/>build runtime<br/>[vite.config.ts]"}}
  node_package["Frontend dependencies<br/>package manifest<br/>[package.json]"]
  node_html["Browser entry<br/>HTML entry<br/>[index.html]"]
  node_main["React bootstrap<br/>application entry<br/>[main.tsx]"]
  node_app["App router and shell<br/>React composition<br/>[App.tsx]"]
  node_navbar["Shared navigation<br/>React component<br/>[Navbar.tsx]"]
  node_theme["Theme state<br/>React context<br/>[ThemeContext.tsx]"]
  node_styles["Global design styles<br/>CSS and Tailwind<br/>[globals.css]"]
  node_about["About page<br/>route page<br/>[AboutUs.tsx]"]
end

subgraph group_data["Client Data Pipeline"]
  node_csv_hook["CSV ingestion hook<br/>client data boundary<br/>[useCSVData.ts]"]
  node_normalization["Data normalization<br/>parsing and shaping<br/>[dataHelpers.ts]"]
  node_datasets[("Static CSV datasets<br/>public browser assets")]
end

subgraph group_dashboard["Dashboard Analytics"]
  node_dashboard_page["Dashboard page<br/>route page<br/>[Dashboard.tsx]"]
  node_visuals["Charts, KPIs, and summary<br/>dashboard components<br/>[IEXChart.tsx]"]
end

subgraph group_future["Future Integration"]
  node_predictions_page["Predictions page<br/>route page<br/>[Predictions.tsx]"]
  node_prediction_placeholder["Predictions placeholder<br/>integration boundary"]
  node_backend["Reserved backend directory<br/>placeholder<br/>[.gitkeep]"]
end

node_package -->|"defines runtime dependencies"| node_vite
node_vite -->|"serves"| node_html
node_html -->|"loads"| node_main
node_main -->|"mounts"| node_app
node_app -->|"composes"| node_navbar
node_app -->|"provides shared state"| node_theme
node_app -->|"uses"| node_styles
node_app -->|"routes to"| node_dashboard_page
node_app -->|"routes to"| node_predictions_page
node_app -->|"routes to"| node_about
node_predictions_page -->|"renders"| node_prediction_placeholder
node_dashboard_page -->|"loads datasets through"| node_csv_hook
node_datasets -->|"browser fetches"| node_csv_hook
node_csv_hook -->|"normalizes parsed rows with"| node_normalization
node_normalization -->|"supplies typed data"| node_dashboard_page
node_dashboard_page -->|"passes analytics props"| node_visuals
node_backend -.->|"future API/model integration"| node_prediction_placeholder
node_backend -.->|"potential future data-source replacement"| node_csv_hook

click node_vite "https://github.com/retr0alfred/voltwise/blob/master/frontend/vite.config.ts"
click node_package "https://github.com/retr0alfred/voltwise/blob/master/frontend/package.json"
click node_html "https://github.com/retr0alfred/voltwise/blob/master/frontend/index.html"
click node_main "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/main.tsx"
click node_app "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/App.tsx"
click node_navbar "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/components/Navbar.tsx"
click node_theme "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/context/ThemeContext.tsx"
click node_styles "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/styles/globals.css"
click node_dashboard_page "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/pages/Dashboard.tsx"
click node_predictions_page "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/pages/Predictions.tsx"
click node_prediction_placeholder "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/components/predictions/PredictionsPlaceholder.tsx"
click node_about "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/pages/AboutUs.tsx"
click node_csv_hook "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/hooks/useCSVData.ts"
click node_normalization "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/utils/dataHelpers.ts"
click node_visuals "https://github.com/retr0alfred/voltwise/blob/master/frontend/src/components/dashboard/IEXChart.tsx"
click node_backend "https://github.com/retr0alfred/voltwise/blob/master/backend/.gitkeep"

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_vite,node_package,node_html,node_main,node_app,node_navbar,node_theme,node_styles,node_about toneBlue
class node_csv_hook,node_normalization,node_datasets toneAmber
class node_dashboard_page,node_visuals toneMint
class node_predictions_page,node_prediction_placeholder,node_backend toneRose
```

## Components

### Frontend Runtime

React SPA built and served by Vite.

- [Vite build and static host](https://github.com/retr0alfred/voltwise/blob/master/frontend/vite.config.ts): build runtime · Builds the deployable browser application. · `frontend/vite.config.ts`
- [Frontend dependencies](https://github.com/retr0alfred/voltwise/blob/master/frontend/package.json): package manifest · `frontend/package.json`
- [Browser entry](https://github.com/retr0alfred/voltwise/blob/master/frontend/index.html): HTML entry · `frontend/index.html`
- [React bootstrap](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/main.tsx): application entry · `frontend/src/main.tsx`
- [App router and shell](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/App.tsx): React composition · Selects routes and composes the shared application shell. · `frontend/src/App.tsx`
- [Shared navigation](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/components/Navbar.tsx): React component · `frontend/src/components/Navbar.tsx`
- [Theme state](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/context/ThemeContext.tsx): React context · `frontend/src/context/ThemeContext.tsx`
- [Global design styles](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/styles/globals.css): CSS and Tailwind · `frontend/src/styles/globals.css`
- [About page](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/pages/AboutUs.tsx): route page · `frontend/src/pages/AboutUs.tsx`

### Client Data Pipeline

Static datasets are fetched and normalized in the browser.

- [CSV ingestion hook](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/hooks/useCSVData.ts): client data boundary · Fetches and parses CSVs with PapaParse worker-first fallback handling. · `frontend/src/hooks/useCSVData.ts`
- [Data normalization](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/utils/dataHelpers.ts): parsing and shaping · Provides shared parsing, types, and normalized dashboard structures. · `frontend/src/utils/dataHelpers.ts`
- **Static CSV datasets**: public browser assets · IEX, demand, weather, and engineered feature CSVs are downloaded directly by the browser.

### Dashboard Analytics

Domain visualizations consume normalized page state.

- [Dashboard page](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/pages/Dashboard.tsx): route page · Orchestrates dataset loading and analytics state. · `frontend/src/pages/Dashboard.tsx`
- [Charts, KPIs, and summary](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/components/dashboard/IEXChart.tsx): dashboard components · IEXChart, DemandChart, WeatherChart, KPICards, and VoltWiseSummary render normalized dashboard props. · `frontend/src/components/dashboard/IEXChart.tsx`

### Future Integration

Reserved boundary; no backend runtime exists.

- [Predictions page](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/pages/Predictions.tsx): route page · UI route reserved for future prediction integration. · `frontend/src/pages/Predictions.tsx`
- [Predictions placeholder](https://github.com/retr0alfred/voltwise/blob/master/frontend/src/components/predictions/PredictionsPlaceholder.tsx): integration boundary · Future API or model outputs attach behind this UI boundary. · `frontend/src/components/predictions/PredictionsPlaceholder.tsx`
- [Reserved backend directory](https://github.com/retr0alfred/voltwise/blob/master/backend/.gitkeep): placeholder · Contains no implemented API, model-serving, or persistence runtime. · `backend/.gitkeep`

## Connections

- Frontend dependencies → Vite build and static host: defines runtime dependencies
- Vite build and static host → Browser entry: serves
- Browser entry → React bootstrap: loads
- React bootstrap → App router and shell: mounts
- App router and shell → Shared navigation: composes
- App router and shell → Theme state: provides shared state
- App router and shell → Global design styles: uses
- App router and shell → Dashboard page: routes to
- App router and shell → Predictions page: routes to
- App router and shell → About page: routes to
- Predictions page → Predictions placeholder: renders
- Dashboard page → CSV ingestion hook: loads datasets through
- Static CSV datasets → CSV ingestion hook: browser fetches
- CSV ingestion hook → Data normalization: normalizes parsed rows with
- Data normalization → Dashboard page: supplies typed data
- Dashboard page → Charts, KPIs, and summary: passes analytics props
- Reserved backend directory → Predictions placeholder: future API/model integration
- Reserved backend directory → CSV ingestion hook: potential future data-source replacement
