# funaturalstone/egat-workspace-v4 architecture

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

- Interactive diagram: https://gitdiagram.com/funaturalstone/egat-workspace-v4
- Repository: https://github.com/funaturalstone/egat-workspace-v4

## Overview

EGAT Energy Feasibility Platform helps users assess Solar PPA, Solar + Battery PPA, and Battery PPA projects. The main workflow is to enter bill and questionnaire details, convert them into product-specific model inputs, calculate project cash flows and investment metrics, then review savings, charts, and a recommendation in the workspace. Users can manage multiple projects and save them in demo/browser or signed-in cloud mode. The source excerpts establish the core calculation and workspace links; some UI and persistence details are documented but not sampled.

Main entry points: [`app.js`](https://github.com/funaturalstone/egat-workspace-v4/blob/main/app.js) (Project Workspace), [`store.js`](https://github.com/funaturalstone/egat-workspace-v4/blob/main/store.js) (Workspace Persistence), [`projects.js`](https://github.com/funaturalstone/egat-workspace-v4/blob/main/projects.js) (Project Management), [`charts.js`](https://github.com/funaturalstone/egat-workspace-v4/blob/main/charts.js) (Dashboards & Charts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace &amp; Projects"]
  node_landing["Product Selection<br/>[landing.js]"]
  node_app["Project Workspace<br/>[app.js]"]
  node_projects["Project Management<br/>[projects.js]"]
end

subgraph group_inputs["Customer Inputs"]
  node_rawentry["Bill &amp; Questionnaire Entry<br/>[raw-inputs.js]"]
  node_inputderive["Input Conversion<br/>[inputs.js]"]
  node_customerdata["Factory Case Data<br/>[khunTonData.js]"]
  node_caseanalysis["Case &amp; Sensitivity<br/>[khunTon.js]"]
  node_demodata["Demo Scenarios<br/>[demoData.js]"]
end

subgraph group_engine["Feasibility Engine"]
  node_bess["Battery Scenarios<br/>[bess.js]"]
  node_model["Cash-Flow Model<br/>[model.js]"]
  node_finance["Finance Metrics<br/>[finance.js]"]
end

subgraph group_results["Results &amp; Visuals"]
  node_charts["Dashboards &amp; Charts<br/>[charts.js]"]
  node_explain["Input Explanations<br/>[explain.js]"]
  node_productscene["3D Product Models<br/>[product-scene.js]"]
end

subgraph group_identity["Identity &amp; Storage"]
  node_auth["Sign-in &amp; Demo Gate<br/>[auth.js]"]
  node_store["Workspace Persistence<br/>[store.js]"]
  node_sync["Workspace Sync<br/>[workspace-sync.js]"]
  node_profile["User Profile<br/>[profile.js]"]
end

node_customer(("Factory Customer"))
node_supabase[("Supabase Cloud")]
node_browserstore[("Browser Storage")]

node_customer -->|"selects product"| node_landing
node_landing -->|"opens workspace"| node_app
node_customer -->|"enters bill data"| node_rawentry
node_rawentry -->|"converts inputs"| node_inputderive
node_customerdata -->|"supplies case data"| node_caseanalysis
node_caseanalysis -->|"derives case inputs"| node_inputderive
node_app -->|"uses raw inputs"| node_rawentry
node_app -->|"selects projects"| node_projects
node_projects -->|"loads scenarios"| node_demodata
node_projects -->|"builds battery template"| node_bess
node_projects -->|"derives sample projects"| node_inputderive
node_app -->|"computes scenarios"| node_model
node_model -->|"calculates metrics"| node_finance
node_app -->|"formats results"| node_charts
node_charts -->|"computes chart data"| node_model
node_charts -->|"reads case bill"| node_caseanalysis
node_app -->|"shows explanations"| node_explain
node_app -->|"renders product models"| node_productscene
node_app -->|"opens and saves"| node_store
node_store -.->|"checks identity"| node_auth
node_store -.->|"syncs workspace"| node_sync
node_store -.->|"loads profile"| node_profile
node_auth -->|"authenticates"| node_supabase
node_store -.->|"stores cloud projects"| node_supabase
node_store -.->|"stores demo projects"| node_browserstore
node_profile -.->|"uses welcome flow"| node_auth

click node_landing "https://github.com/funaturalstone/egat-workspace-v4/blob/main/landing.js"
click node_app "https://github.com/funaturalstone/egat-workspace-v4/blob/main/app.js"
click node_projects "https://github.com/funaturalstone/egat-workspace-v4/blob/main/projects.js"
click node_rawentry "https://github.com/funaturalstone/egat-workspace-v4/blob/main/raw-inputs.js"
click node_inputderive "https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/inputs.js"
click node_customerdata "https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/khunTonData.js"
click node_caseanalysis "https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/khunTon.js"
click node_demodata "https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/demoData.js"
click node_bess "https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/bess.js"
click node_model "https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/model.js"
click node_finance "https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/finance.js"
click node_charts "https://github.com/funaturalstone/egat-workspace-v4/blob/main/charts.js"
click node_explain "https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/explain.js"
click node_auth "https://github.com/funaturalstone/egat-workspace-v4/blob/main/auth.js"
click node_store "https://github.com/funaturalstone/egat-workspace-v4/blob/main/store.js"
click node_sync "https://github.com/funaturalstone/egat-workspace-v4/blob/main/workspace-sync.js"
click node_profile "https://github.com/funaturalstone/egat-workspace-v4/blob/main/profile.js"
click node_productscene "https://github.com/funaturalstone/egat-workspace-v4/blob/main/product-scene.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_landing,node_app,node_projects toneBlue
class node_rawentry,node_inputderive,node_customerdata,node_caseanalysis,node_demodata,node_supabase,node_browserstore toneAmber
class node_bess,node_model,node_finance toneMint
class node_charts,node_explain,node_productscene toneRose
class node_auth,node_store,node_sync,node_profile,node_customer toneIndigo
```

## Components

### Workspace & Projects

- [Product Selection](https://github.com/funaturalstone/egat-workspace-v4/blob/main/landing.js): `landing.js`
- [Project Workspace](https://github.com/funaturalstone/egat-workspace-v4/blob/main/app.js): `app.js`
- [Project Management](https://github.com/funaturalstone/egat-workspace-v4/blob/main/projects.js): `projects.js`

### Customer Inputs

- [Bill & Questionnaire Entry](https://github.com/funaturalstone/egat-workspace-v4/blob/main/raw-inputs.js): `raw-inputs.js`
- [Input Conversion](https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/inputs.js): `domain/inputs.js`
- [Factory Case Data](https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/khunTonData.js): `domain/khunTonData.js`
- [Case & Sensitivity](https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/khunTon.js): `domain/khunTon.js`
- [Demo Scenarios](https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/demoData.js): `domain/demoData.js`

### Feasibility Engine

- [Battery Scenarios](https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/bess.js): `domain/bess.js`
- [Cash-Flow Model](https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/model.js): `domain/model.js`
- [Finance Metrics](https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/finance.js): `domain/finance.js`

### Results & Visuals

- [Dashboards & Charts](https://github.com/funaturalstone/egat-workspace-v4/blob/main/charts.js): `charts.js`
- [Input Explanations](https://github.com/funaturalstone/egat-workspace-v4/blob/main/domain/explain.js): `domain/explain.js`
- [3D Product Models](https://github.com/funaturalstone/egat-workspace-v4/blob/main/product-scene.js): `product-scene.js`

### Identity & Storage

- [Sign-in & Demo Gate](https://github.com/funaturalstone/egat-workspace-v4/blob/main/auth.js): `auth.js`
- [Workspace Persistence](https://github.com/funaturalstone/egat-workspace-v4/blob/main/store.js): `store.js`
- [Workspace Sync](https://github.com/funaturalstone/egat-workspace-v4/blob/main/workspace-sync.js): `workspace-sync.js`
- [User Profile](https://github.com/funaturalstone/egat-workspace-v4/blob/main/profile.js): `profile.js`

### Other components

- **Factory Customer**
- **Supabase Cloud**
- **Browser Storage**

## Connections

- Factory Customer → Product Selection: selects product (evidence: `README.md`)
- Product Selection → Project Workspace: opens workspace (evidence: `README.md`)
- Factory Customer → Bill & Questionnaire Entry: enters bill data (evidence: `README.md`)
- Bill & Questionnaire Entry → Input Conversion: converts inputs (evidence: `README.md`)
- Factory Case Data → Case & Sensitivity: supplies case data (evidence: `domain/khunTon.js`)
- Case & Sensitivity → Input Conversion: derives case inputs (evidence: `domain/khunTon.js`)
- Project Workspace → Bill & Questionnaire Entry: uses raw inputs (evidence: `app.js`)
- Project Workspace → Project Management: selects projects (evidence: `app.js`)
- Project Management → Demo Scenarios: loads scenarios (evidence: `projects.js`)
- Project Management → Battery Scenarios: builds battery template (evidence: `projects.js`)
- Project Management → Input Conversion: derives sample projects (evidence: `projects.js`)
- Project Workspace → Cash-Flow Model: computes scenarios (evidence: `app.js`)
- Cash-Flow Model → Finance Metrics: calculates metrics (evidence: `domain/model.js`)
- Project Workspace → Dashboards & Charts: formats results (evidence: `app.js`)
- Dashboards & Charts → Cash-Flow Model: computes chart data (evidence: `charts.js`)
- Dashboards & Charts → Case & Sensitivity: reads case bill (evidence: `charts.js`)
- Project Workspace → Input Explanations: shows explanations (evidence: `app.js`)
- Project Workspace → 3D Product Models: renders product models (evidence: `app.js`)
- Project Workspace → Workspace Persistence: opens and saves (evidence: `app.js`)
- Workspace Persistence → Sign-in & Demo Gate: checks identity (evidence: `store.js`)
- Workspace Persistence → Workspace Sync: syncs workspace (evidence: `store.js`)
- Workspace Persistence → User Profile: loads profile (evidence: `store.js`)
- Sign-in & Demo Gate → Supabase Cloud: authenticates (evidence: `auth.js`)
- Workspace Persistence → Supabase Cloud: stores cloud projects (evidence: `README.md`)
- Workspace Persistence → Browser Storage: stores demo projects (evidence: `README.md`)
- User Profile → Sign-in & Demo Gate: uses welcome flow (evidence: `profile.js`)
