# pbtamarona/openpytea architecture

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

- Interactive diagram: https://gitdiagram.com/pbtamarona/openpytea
- Repository: https://github.com/pbtamarona/openpytea

## Overview

OpenPyTEA is a Python techno-economic assessment toolkit with an optional desktop GUI backed by a local API. The principal workflow is to configure equipment and plant assumptions, calculate plant economics, then inspect results or run sensitivity and Monte Carlo analyses; projects can also hold and compare multiple plants. The graph preserves the documented JSON workflow and plotting capability as well. Backend routing and several frontend pages are represented at their source paths, but their internal implementations were not all sampled, so uncertain links are omitted.

Main entry points: [`frontend/src/App.tsx`](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/App.tsx) (Desktop application), [`backend/app/main.py`](https://github.com/pbtamarona/openpytea/blob/main/backend/app/main.py) (HTTP API), [`frontend/src/api/client.ts`](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/api/client.ts) (API client), [`src/openpytea/io.py`](https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/io.py) (JSON workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gui["Desktop interface"]
  node_app["Desktop application<br/>[App.tsx]"]
  node_equipment_ui["Equipment costing<br/>[EquipmentPage.tsx]"]
  node_plant_ui["Plant configuration"]
  node_results_ui["Economic results<br/>[ResultsPage.tsx]"]
  node_analysis_ui["Sensitivity analysis<br/>[AnalysisPage.tsx]"]
  node_mc_ui["Monte Carlo<br/>[MonteCarloPage.tsx]"]
  node_compare_ui["Plant comparison<br/>[ComparePage.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
end

subgraph group_api["Application backend"]
  node_api_app["HTTP API<br/>[main.py]"]
  node_plant_routes["Plant endpoints<br/>[plant.py]"]
  node_equipment_routes["Equipment endpoints<br/>[equipment.py]"]
  node_analysis_routes["Analysis endpoints<br/>[analysis.py]"]
  node_plot_routes["Plot endpoints<br/>[plots.py]"]
  node_io_routes["JSON endpoints<br/>[io.py]"]
  node_project_routes["Project endpoints<br/>[project.py]"]
  node_session["Session state<br/>[state.py]"]
  node_factory["Plant factory<br/>[plant_factory.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_model["TEA model"]
  node_equipment["Equipment costing<br/>[equipment.py]"]
  node_plant["Plant economics<br/>[plant.py]"]
  node_helpers["Model helpers<br/>[helpers.py]"]
end

subgraph group_analysis["Analysis and plots"]
  node_analysis_lib["Sensitivity and uncertainty<br/>[analysis.py]"]
  node_plotting["Visualization<br/>[plotting.py]"]
end

subgraph group_workflow["Project data"]
  node_project_store["Project store<br/>[project_store.py]"]
  node_io_lib["JSON workflow<br/>[io.py]"]
end

node_user(("TEA user"))

node_user -->|"uses"| node_app
node_app -->|"shows"| node_equipment_ui
node_app -->|"shows"| node_plant_ui
node_app -->|"shows"| node_results_ui
node_app -->|"shows"| node_analysis_ui
node_app -->|"shows"| node_mc_ui
node_app -->|"shows"| node_compare_ui
node_equipment_ui -->|"requests"| node_api_client
node_plant_ui -->|"requests"| node_api_client
node_results_ui -->|"requests"| node_api_client
node_analysis_ui -->|"requests"| node_api_client
node_mc_ui -->|"requests"| node_api_client
node_api_client -->|"HTTP requests"| node_api_app
node_api_app -->|"routes to"| node_plant_routes
node_api_app -->|"routes to"| node_equipment_routes
node_api_app -->|"routes to"| node_analysis_routes
node_api_app -->|"routes to"| node_plot_routes
node_api_app -->|"routes to"| node_io_routes
node_api_app -->|"routes to"| node_project_routes
node_equipment_routes -->|"builds via"| node_factory
node_plant_routes -->|"builds via"| node_factory
node_analysis_routes -->|"runs"| node_analysis_lib
node_plot_routes -->|"renders with"| node_plotting
node_plot_routes -->|"uses results from"| node_analysis_lib
node_io_routes -->|"uses"| node_io_lib
node_project_routes -.->|"manages"| node_project_store
node_plant_routes -->|"manages"| node_project_store
node_project_store -->|"parks and restores"| node_session
node_plant_routes -->|"reads and updates"| node_session
node_factory -->|"creates"| node_equipment
node_factory -->|"creates"| node_plant
node_plant -->|"aggregates"| node_equipment
node_analysis_lib -->|"analyzes"| node_plant
node_analysis_lib -->|"uses"| node_helpers
node_plant -->|"uses"| node_helpers
node_io_lib -->|"loads"| node_equipment
node_io_lib -->|"runs TEA for"| node_plant
node_io_lib -->|"runs analysis"| node_analysis_lib
node_io_lib -->|"exports plots with"| node_plotting
node_plotting -->|"uses"| node_helpers

click node_app "https://github.com/pbtamarona/openpytea/blob/main/frontend/src/App.tsx"
click node_equipment_ui "https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/EquipmentPage.tsx"
click node_plant_ui "https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/PlantConfigPage.tsx"
click node_results_ui "https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/ResultsPage.tsx"
click node_analysis_ui "https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/AnalysisPage.tsx"
click node_mc_ui "https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/MonteCarloPage.tsx"
click node_compare_ui "https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/ComparePage.tsx"
click node_api_client "https://github.com/pbtamarona/openpytea/blob/main/frontend/src/api/client.ts"
click node_api_app "https://github.com/pbtamarona/openpytea/blob/main/backend/app/main.py"
click node_plant_routes "https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/plant.py"
click node_equipment_routes "https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/equipment.py"
click node_analysis_routes "https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/analysis.py"
click node_plot_routes "https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/plots.py"
click node_io_routes "https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/io.py"
click node_project_routes "https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/project.py"
click node_session "https://github.com/pbtamarona/openpytea/blob/main/backend/app/state.py"
click node_project_store "https://github.com/pbtamarona/openpytea/blob/main/backend/app/project_store.py"
click node_factory "https://github.com/pbtamarona/openpytea/blob/main/backend/app/plant_factory.py"
click node_schemas "https://github.com/pbtamarona/openpytea/blob/main/backend/app/schemas.py"
click node_equipment "https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/equipment.py"
click node_plant "https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/plant.py"
click node_analysis_lib "https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/analysis.py"
click node_plotting "https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/plotting.py"
click node_io_lib "https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/io.py"
click node_helpers "https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/helpers.py"

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_app,node_equipment_ui,node_plant_ui,node_results_ui,node_analysis_ui,node_mc_ui,node_compare_ui,node_api_client,node_user toneBlue
class node_api_app,node_plant_routes,node_equipment_routes,node_analysis_routes,node_plot_routes,node_io_routes,node_project_routes,node_session,node_factory,node_schemas toneAmber
class node_equipment,node_plant,node_helpers toneMint
class node_analysis_lib,node_plotting toneRose
class node_project_store,node_io_lib toneIndigo
```

## Components

### Desktop interface

- [Desktop application](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Equipment costing](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/EquipmentPage.tsx): `frontend/src/pages/EquipmentPage.tsx`
- [Plant configuration](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/PlantConfigPage.tsx): `frontend/src/pages/PlantConfigPage.tsx`
- [Economic results](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/ResultsPage.tsx): `frontend/src/pages/ResultsPage.tsx`
- [Sensitivity analysis](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/AnalysisPage.tsx): `frontend/src/pages/AnalysisPage.tsx`
- [Monte Carlo](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/MonteCarloPage.tsx): `frontend/src/pages/MonteCarloPage.tsx`
- [Plant comparison](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/pages/ComparePage.tsx): `frontend/src/pages/ComparePage.tsx`
- [API client](https://github.com/pbtamarona/openpytea/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### Application backend

- [HTTP API](https://github.com/pbtamarona/openpytea/blob/main/backend/app/main.py): `backend/app/main.py`
- [Plant endpoints](https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/plant.py): `backend/app/routers/plant.py`
- [Equipment endpoints](https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/equipment.py): `backend/app/routers/equipment.py`
- [Analysis endpoints](https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/analysis.py): `backend/app/routers/analysis.py`
- [Plot endpoints](https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/plots.py): `backend/app/routers/plots.py`
- [JSON endpoints](https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/io.py): `backend/app/routers/io.py`
- [Project endpoints](https://github.com/pbtamarona/openpytea/blob/main/backend/app/routers/project.py): `backend/app/routers/project.py`
- [Session state](https://github.com/pbtamarona/openpytea/blob/main/backend/app/state.py): `backend/app/state.py`
- [Plant factory](https://github.com/pbtamarona/openpytea/blob/main/backend/app/plant_factory.py): `backend/app/plant_factory.py`
- [API schemas](https://github.com/pbtamarona/openpytea/blob/main/backend/app/schemas.py): `backend/app/schemas.py`

### TEA model

- [Equipment costing](https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/equipment.py): `src/openpytea/equipment.py`
- [Plant economics](https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/plant.py): `src/openpytea/plant.py`
- [Model helpers](https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/helpers.py): `src/openpytea/helpers.py`

### Analysis and plots

- [Sensitivity and uncertainty](https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/analysis.py): `src/openpytea/analysis.py`
- [Visualization](https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/plotting.py): `src/openpytea/plotting.py`

### Project data

- [Project store](https://github.com/pbtamarona/openpytea/blob/main/backend/app/project_store.py): `backend/app/project_store.py`
- [JSON workflow](https://github.com/pbtamarona/openpytea/blob/main/src/openpytea/io.py): `src/openpytea/io.py`

### Other components

- **TEA user**

## Connections

- TEA user → Desktop application: uses
- Desktop application → Equipment costing: shows (evidence: `frontend/src/App.tsx`)
- Desktop application → Plant configuration: shows (evidence: `frontend/src/App.tsx`)
- Desktop application → Economic results: shows (evidence: `frontend/src/App.tsx`)
- Desktop application → Sensitivity analysis: shows (evidence: `frontend/src/App.tsx`)
- Desktop application → Monte Carlo: shows (evidence: `frontend/src/App.tsx`)
- Desktop application → Plant comparison: shows (evidence: `frontend/src/App.tsx`)
- Equipment costing → API client: requests (evidence: `frontend/src/pages/EquipmentPage.tsx`)
- Plant configuration → API client: requests (evidence: `frontend/src/App.tsx`)
- Economic results → API client: requests (evidence: `frontend/src/pages/ResultsPage.tsx`)
- Sensitivity analysis → API client: requests (evidence: `frontend/src/pages/AnalysisPage.tsx`)
- Monte Carlo → API client: requests (evidence: `frontend/src/pages/MonteCarloPage.tsx`)
- API client → HTTP API: HTTP requests
- HTTP API → Plant endpoints: routes to (evidence: `backend/app/main.py`)
- HTTP API → Equipment endpoints: routes to (evidence: `backend/app/main.py`)
- HTTP API → Analysis endpoints: routes to (evidence: `backend/app/main.py`)
- HTTP API → Plot endpoints: routes to (evidence: `backend/app/main.py`)
- HTTP API → JSON endpoints: routes to (evidence: `backend/app/main.py`)
- HTTP API → Project endpoints: routes to (evidence: `backend/app/main.py`)
- Equipment endpoints → Plant factory: builds via (evidence: `backend/app/routers/equipment.py`)
- Plant endpoints → Plant factory: builds via (evidence: `backend/app/routers/plant.py`)
- Analysis endpoints → Sensitivity and uncertainty: runs (evidence: `backend/app/routers/analysis.py`)
- Plot endpoints → Visualization: renders with (evidence: `backend/app/routers/plots.py`)
- Plot endpoints → Sensitivity and uncertainty: uses results from (evidence: `backend/app/routers/plots.py`)
- JSON endpoints → JSON workflow: uses (evidence: `backend/app/routers/io.py`)
- Project endpoints → Project store: manages
- Plant endpoints → Project store: manages (evidence: `backend/app/routers/plant.py`)
- Project store → Session state: parks and restores (evidence: `backend/app/project_store.py`)
- Plant endpoints → Session state: reads and updates (evidence: `backend/app/routers/plant.py`)
- Plant factory → Equipment costing: creates (evidence: `backend/app/plant_factory.py`)
- Plant factory → Plant economics: creates (evidence: `backend/app/plant_factory.py`)
- Plant economics → Equipment costing: aggregates (evidence: `src/openpytea/plant.py`)
- Sensitivity and uncertainty → Plant economics: analyzes (evidence: `src/openpytea/analysis.py`)
- Sensitivity and uncertainty → Model helpers: uses (evidence: `src/openpytea/analysis.py`)
- Plant economics → Model helpers: uses (evidence: `src/openpytea/plant.py`)
- JSON workflow → Equipment costing: loads (evidence: `src/openpytea/io.py`)
- JSON workflow → Plant economics: runs TEA for (evidence: `src/openpytea/io.py`)
- JSON workflow → Sensitivity and uncertainty: runs analysis (evidence: `src/openpytea/io.py`)
- JSON workflow → Visualization: exports plots with (evidence: `src/openpytea/io.py`)
- Visualization → Model helpers: uses (evidence: `src/openpytea/plotting.py`)
