# sowbyspencer/circuitsimulator architecture

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

- Interactive diagram: https://gitdiagram.com/sowbyspencer/circuitsimulator
- Repository: https://github.com/sowbyspencer/circuitsimulator

## Overview

Circuit Simulator is a client-side diagramming app for building electrical circuits and viewing their simulated behavior. A user adds source and load cards, edits their settings, connects or rearranges wires, and the canvas app solves the DC circuit and updates displayed readings. The app also advances load temperature over time and shows overvoltage or burnout state. The README documents additional simulation features and local JSON persistence; those subsystems are represented, but their implementation and wiring were not shown in the sampled source.

Main entry points: [`src/App.jsx`](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/App.jsx) (Canvas app), [`src/engine/circuit.js`](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/engine/circuit.js) (DC circuit solver), [`src/main.jsx`](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/main.jsx) (Browser entry), [`src/engine`](https://github.com/sowbyspencer/circuitsimulator/tree/main/src/engine) (Additional physics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_canvas["Diagram canvas"]
  node_entry["Browser entry<br/>[main.jsx]"]
  node_app["Canvas app<br/>[App.jsx]"]
  node_source_card["DC source card<br/>[DcSourceNode.jsx]"]
  node_load_card["DC load card<br/>[DcLoadNode.jsx]"]
end

subgraph group_editing["Circuit editing"]
  node_node_actions["Node actions<br/>[appActions.js]"]
  node_wire_actions["Wire actions<br/>[wireActions.js]"]
end

subgraph group_simulation["Simulation engine"]
  node_dc_solver["DC circuit solver<br/>[circuit.js]"]
  node_thermal["Load thermal model<br/>[loadThermal.js]"]
  node_extended_physics["Additional physics"]
  node_advanced_protection["Protection and conversion"]
end

subgraph group_persistence["Persistence"]
  node_json_files["Local JSON files"]
end

node_user(("Circuit designer"))

node_user -->|"opens app"| node_entry
node_entry -->|"renders"| node_app
node_user -->|"edits diagram"| node_app
node_app -->|"renders"| node_source_card
node_app -->|"renders"| node_load_card
node_app -->|"delegates edits"| node_node_actions
node_app -->|"delegates wiring"| node_wire_actions
node_app -->|"solves circuit"| node_dc_solver
node_dc_solver -->|"returns readings"| node_app
node_app -->|"steps heating"| node_thermal
node_app -.->|"uses physics"| node_extended_physics
node_app -.->|"persists diagram"| node_json_files
node_app -.->|"simulates features"| node_advanced_protection
node_dc_solver -.->|"models limits"| node_extended_physics

click node_entry "https://github.com/sowbyspencer/circuitsimulator/blob/main/src/main.jsx"
click node_app "https://github.com/sowbyspencer/circuitsimulator/blob/main/src/App.jsx"
click node_source_card "https://github.com/sowbyspencer/circuitsimulator/blob/main/src/components/DcSourceNode.jsx"
click node_load_card "https://github.com/sowbyspencer/circuitsimulator/blob/main/src/components/DcLoadNode.jsx"
click node_node_actions "https://github.com/sowbyspencer/circuitsimulator/blob/main/src/appActions.js"
click node_wire_actions "https://github.com/sowbyspencer/circuitsimulator/blob/main/src/engine/wireActions.js"
click node_dc_solver "https://github.com/sowbyspencer/circuitsimulator/blob/main/src/engine/circuit.js"
click node_thermal "https://github.com/sowbyspencer/circuitsimulator/blob/main/src/engine/loadThermal.js"
click node_extended_physics "https://github.com/sowbyspencer/circuitsimulator/tree/main/src/engine"
click node_json_files "https://github.com/sowbyspencer/circuitsimulator/tree/main/src"
click node_advanced_protection "https://github.com/sowbyspencer/circuitsimulator/tree/main/src/engine"

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_entry,node_app,node_source_card,node_load_card toneBlue
class node_node_actions,node_wire_actions toneAmber
class node_dc_solver,node_thermal,node_extended_physics,node_advanced_protection toneMint
class node_json_files toneRose
class node_user toneIndigo
```

## Components

### Diagram canvas

- [Browser entry](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/main.jsx): `src/main.jsx`
- [Canvas app](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/App.jsx): `src/App.jsx`
- [DC source card](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/components/DcSourceNode.jsx): `src/components/DcSourceNode.jsx`
- [DC load card](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/components/DcLoadNode.jsx): `src/components/DcLoadNode.jsx`

### Circuit editing

- [Node actions](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/appActions.js): `src/appActions.js`
- [Wire actions](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/engine/wireActions.js): `src/engine/wireActions.js`

### Simulation engine

- [DC circuit solver](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/engine/circuit.js): `src/engine/circuit.js`
- [Load thermal model](https://github.com/sowbyspencer/circuitsimulator/blob/main/src/engine/loadThermal.js): `src/engine/loadThermal.js`
- [Additional physics](https://github.com/sowbyspencer/circuitsimulator/tree/main/src/engine): `src/engine`
- [Protection and conversion](https://github.com/sowbyspencer/circuitsimulator/tree/main/src/engine): `src/engine`

### Persistence

- [Local JSON files](https://github.com/sowbyspencer/circuitsimulator/tree/main/src): `src`

### Other components

- **Circuit designer**

## Connections

- Circuit designer → Browser entry: opens app (evidence: `README.md`)
- Browser entry → Canvas app: renders (evidence: `src/main.jsx`)
- Circuit designer → Canvas app: edits diagram (evidence: `README.md`)
- Canvas app → DC source card: renders (evidence: `src/App.jsx`)
- Canvas app → DC load card: renders (evidence: `src/App.jsx`)
- Canvas app → Node actions: delegates edits (evidence: `src/App.jsx`)
- Canvas app → Wire actions: delegates wiring (evidence: `src/App.jsx`)
- Canvas app → DC circuit solver: solves circuit (evidence: `src/App.jsx`)
- DC circuit solver → Canvas app: returns readings (evidence: `src/App.jsx`)
- Canvas app → Load thermal model: steps heating (evidence: `src/App.jsx`)
- Canvas app → Additional physics: uses physics (evidence: `src/App.jsx`)
- Canvas app → Local JSON files: persists diagram (evidence: `README.md`)
- Canvas app → Protection and conversion: simulates features (evidence: `README.md`)
- DC circuit solver → Additional physics: models limits
