# shawneetz/luzon-gridsim-project architecture

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

- Interactive diagram: https://gitdiagram.com/shawneetz/luzon-gridsim-project
- Repository: https://github.com/shawneetz/luzon-gridsim-project

## Overview

Luzon GridSim is a web interface over an R electricity-dispatch optimizer. Users choose plant groups and an optional daily CO₂ cap, submit a solve, then inspect cost, dispatch, prices, or simplex iterations. The frontend’s page owns UI state and requests; the R API calculates the plan. README documents plant data and the API/solver split, but the R implementation was not excerpted, so internal solver relationships are shown only as unverified dashed links.

Main entry points: [`src/app/page.tsx`](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/app/page.tsx) (App page), [`api/R/solve.R`](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/solve.R) (Solve workflow), [`src/components/ResultsTab.tsx`](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/ResultsTab.tsx) (Results view), [`src/lib/api.ts`](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web app"]
  node_page["App page<br/>[page.tsx]"]
  node_controls["Plant controls<br/>[ControlPanel.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_results["Results view<br/>[ResultsTab.tsx]"]
  node_dispatch["Dispatch chart<br/>[DispatchChart.tsx]"]
  node_data_table["Data table<br/>[DataTable.tsx]"]
  node_tableau["Tableau viewer<br/>[TableauTab.tsx]"]
  node_format["Number formatting<br/>[format.ts]"]
end

subgraph group_solver["R solver"]
  node_api_routes["HTTP endpoints<br/>[plumber.R]"]
  node_input_check["Input checks<br/>[check.R]"]
  node_initial["Initial tableau<br/>[initial.R]"]
  node_primal["Primal solver<br/>[primal.R]"]
  node_simplex["Simplex operations<br/>[simplex.R]"]
  node_solve["Solve workflow<br/>[solve.R]"]
  node_solver_results["Result assembly<br/>[results.R]"]
end

subgraph group_shared["Shared data"]
  node_plant_styles["Plant styles<br/>[plants.ts]"]
  node_api_types["API data types<br/>[types.ts]"]
  node_solver_data["Plant data and limits<br/>[data.R]"]
end

node_user(("Grid planner"))

node_user -->|"sets choices"| node_page
node_page -->|"renders controls"| node_controls
node_page -->|"fetches and solves"| node_api_client
node_api_client -->|"HTTP requests"| node_api_routes
node_page -->|"renders results"| node_results
node_page -->|"renders iterations"| node_tableau
node_results -->|"renders chart"| node_dispatch
node_results -->|"renders dispatch"| node_data_table
node_tableau -->|"renders tableau"| node_data_table
node_results -->|"formats cost"| node_format
node_data_table -->|"formats values"| node_format
node_controls -->|"reads styles"| node_plant_styles
node_dispatch -->|"reads styles"| node_plant_styles
node_api_client -->|"uses types"| node_api_types
node_api_routes -.->|"validates input"| node_input_check
node_api_routes -.->|"dispatches solve"| node_solve
node_solve -.->|"uses limits"| node_solver_data
node_solve -.->|"builds tableau"| node_initial
node_solve -.->|"runs optimization"| node_primal
node_primal -.->|"uses operations"| node_simplex
node_solve -.->|"assembles output"| node_solver_results

click node_page "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/app/page.tsx"
click node_controls "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/ControlPanel.tsx"
click node_api_client "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/api.ts"
click node_results "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/ResultsTab.tsx"
click node_dispatch "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/DispatchChart.tsx"
click node_data_table "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/DataTable.tsx"
click node_tableau "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/TableauTab.tsx"
click node_format "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/format.ts"
click node_plant_styles "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/plants.ts"
click node_api_types "https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/types.ts"
click node_api_routes "https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/plumber.R"
click node_input_check "https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/check.R"
click node_solver_data "https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/data.R"
click node_initial "https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/initial.R"
click node_primal "https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/primal.R"
click node_simplex "https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/simplex.R"
click node_solve "https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/solve.R"
click node_solver_results "https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/results.R"

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_page,node_controls,node_api_client,node_results,node_dispatch,node_data_table,node_tableau,node_format toneBlue
class node_api_routes,node_input_check,node_initial,node_primal,node_simplex,node_solve,node_solver_results toneAmber
class node_plant_styles,node_api_types,node_solver_data toneMint
class node_user toneIndigo
```

## Components

### Web app

- [App page](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/app/page.tsx): `src/app/page.tsx`
- [Plant controls](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/ControlPanel.tsx): `src/components/ControlPanel.tsx`
- [API client](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/api.ts): `src/lib/api.ts`
- [Results view](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/ResultsTab.tsx): `src/components/ResultsTab.tsx`
- [Dispatch chart](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/DispatchChart.tsx): `src/components/DispatchChart.tsx`
- [Data table](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/DataTable.tsx): `src/components/DataTable.tsx`
- [Tableau viewer](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/components/TableauTab.tsx): `src/components/TableauTab.tsx`
- [Number formatting](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/format.ts): `src/lib/format.ts`

### R solver

- [HTTP endpoints](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/plumber.R): `api/plumber.R`
- [Input checks](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/check.R): `api/R/check.R`
- [Initial tableau](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/initial.R): `api/R/initial.R`
- [Primal solver](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/primal.R): `api/R/primal.R`
- [Simplex operations](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/simplex.R): `api/R/simplex.R`
- [Solve workflow](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/solve.R): `api/R/solve.R`
- [Result assembly](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/results.R): `api/R/results.R`

### Shared data

- [Plant styles](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/plants.ts): `src/lib/plants.ts`
- [API data types](https://github.com/shawneetz/luzon-gridsim-project/blob/master/src/lib/types.ts): `src/lib/types.ts`
- [Plant data and limits](https://github.com/shawneetz/luzon-gridsim-project/blob/master/api/R/data.R): `api/R/data.R`

### Other components

- **Grid planner**

## Connections

- Grid planner → App page: sets choices (evidence: `src/app/page.tsx`)
- App page → Plant controls: renders controls (evidence: `src/app/page.tsx`)
- App page → API client: fetches and solves (evidence: `src/app/page.tsx`)
- API client → HTTP endpoints: HTTP requests (evidence: `src/lib/api.ts`)
- App page → Results view: renders results (evidence: `src/app/page.tsx`)
- App page → Tableau viewer: renders iterations (evidence: `src/app/page.tsx`)
- Results view → Dispatch chart: renders chart (evidence: `src/components/ResultsTab.tsx`)
- Results view → Data table: renders dispatch (evidence: `src/components/ResultsTab.tsx`)
- Tableau viewer → Data table: renders tableau (evidence: `src/components/TableauTab.tsx`)
- Results view → Number formatting: formats cost (evidence: `src/components/ResultsTab.tsx`)
- Data table → Number formatting: formats values (evidence: `src/components/DataTable.tsx`)
- Plant controls → Plant styles: reads styles (evidence: `src/components/ControlPanel.tsx`)
- Dispatch chart → Plant styles: reads styles (evidence: `src/components/DispatchChart.tsx`)
- API client → API data types: uses types (evidence: `src/lib/api.ts`)
- HTTP endpoints → Input checks: validates input
- HTTP endpoints → Solve workflow: dispatches solve
- Solve workflow → Plant data and limits: uses limits
- Solve workflow → Initial tableau: builds tableau
- Solve workflow → Primal solver: runs optimization
- Primal solver → Simplex operations: uses operations
- Solve workflow → Result assembly: assembles output
