# weekendeboy/logicgrid architecture

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

- Interactive diagram: https://gitdiagram.com/weekendeboy/logicgrid
- Repository: https://github.com/weekendeboy/logicgrid

## Overview

#### Purpose and entry points
This is a Vite-based React/TypeScript browser application for building and simulating electronic/logic circuits on a visual workspace. The runtime starts at `index.html`, mounts React through `src/main.tsx`, and composes the application in `src/App.tsx`.

#### Application shell and interaction surfaces
The UI is divided into a navigation layer, a central circuit canvas, sidebars, and modal workflows:
- `src/components/Navbar.tsx`
- `src/components/CanvasWorkspace.tsx`
- `src/components/LeftSidebar.tsx`
- `src/components/RightSidebar.tsx`
- `src/components/Modals.tsx`

`CanvasWorkspace` is the primary editing boundary: it likely owns placement, selection, drawing, and pointer-driven wiring interactions, while sidebars expose component/tool selection and properties or simulation state.

#### Circuit model and shared types
`src/types.ts` defines the shared contract between visual components and simulation engines: component identities, placement/state, pins or terminals, wires/nets, and derived outputs. This type boundary is central because UI edits must be translated into engine-readable topology, then simulation results returned for rendering.

#### Connectivity and wiring pipeline
Physical circuit connectivity is separated into dedicated engine stages:
- `src/engine/WiringEngine.ts`
- `src/engine/NetEngine.ts`
- `src/engine/DisjointSet.ts`
- `src/engine/Pathfinding.ts`

The expected flow is editor actions → wire/path creation → terminal connectivity grouping. `Pathfinding` supports routed wire geometry; `WiringEngine` manages wire-level operations; `NetEngine` resolves electrically connected nets; and `DisjointSet` provides efficient connected-component grouping. This separation prevents rendering geometry from being the sole source of electrical connectivity.

#### Simulation engines
Simulation is split by concern:
- `src/engine/ElectronicEngine.ts`
- `src/engine/LogicEngine.ts`
- `src/engine/truthTableCheck.ts`

`ElectronicEngine` is the likely analog/electrical evaluation layer, while `LogicEngine` evaluates digital gate or signal behavior. `truthTableCheck` provides a verification-oriented path for validating logical behavior against expected truth-table outcomes. Net resolution should form the handoff into these engines; calculated values then feed component appearance and right-sidebar inspection.

#### Control and rendering flow
Primary control flow is bidirectional:
1. User actions in `CanvasWorkspace` or `LeftSidebar` alter circuit model state.
2. Wiring/connectivity engines derive nets from components and wires.
3. Logic/electronic engines evaluate the resulting topology.
4. `CanvasWorkspace` redraws components, wires, and active states; `RightSidebar` presents selected-item or simulation details.

`src/components/RightSidebar.tsx` is therefore an important inspection/configuration boundary, rather than part of low-level simulation.

#### Runtime, delivery, and external dependencies
The repository uses the Vite toolchain (`vite.config.ts`) with both npm and Bun lockfiles (`package-lock.json`, `bun.lock`). Styling is centralized in `src/index.css`. Deployment automation is defined in `.github/workflows/deploy.yml`. No backend, database, API integration, or external runtime service is evidenced by the tree; simulation appears client-side.

Main entry points: [`src/App.tsx`](https://github.com/weekendeboy/logicgrid/blob/main/src/App.tsx) (Application Shell), [`src/components/CanvasWorkspace.tsx`](https://github.com/weekendeboy/logicgrid/blob/main/src/components/CanvasWorkspace.tsx) (Circuit Canvas), [`src/engine/NetEngine.ts`](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/NetEngine.ts) (Net Resolution), [`src/engine/LogicEngine.ts`](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/LogicEngine.ts) (Logic Evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Browser Runtime"]
  node_index["HTML Entry<br/>Vite entry<br/>[index.html]"]
  node_main["React Mount<br/>React bootstrap<br/>[main.tsx]"]
  node_styles["Global Styling<br/>CSS<br/>[index.css]"]
  node_vite["Vite Toolchain<br/>build configuration<br/>[vite.config.ts]"]
  node_deploy["Deployment Automation<br/>CI workflow<br/>[deploy.yml]"]
end

subgraph group_ui["Editor UI"]
  node_app["Application Shell<br/>React composition<br/>[App.tsx]"]
  node_navbar["Navigation<br/>UI surface<br/>[Navbar.tsx]"]
  node_canvas["Circuit Canvas<br/>editing boundary"]
  node_left_sidebar["Tool Sidebar<br/>component selection<br/>[LeftSidebar.tsx]"]
  node_right_sidebar["Inspector Sidebar<br/>inspection boundary<br/>[RightSidebar.tsx]"]
  node_modals["Modal Workflows<br/>UI surface<br/>[Modals.tsx]"]
end

subgraph group_connectivity["Connectivity Pipeline"]
  node_pathfinding["Wire Routing<br/>pathfinding engine<br/>[Pathfinding.ts]"]
  node_wiring["Wire Operations<br/>wiring engine<br/>[WiringEngine.ts]"]
  node_net_engine["Net Resolution<br/>connectivity engine<br/>[NetEngine.ts]"]
  node_disjoint_set["Connected Components<br/>union-find<br/>[DisjointSet.ts]"]
end

subgraph group_simulation["Simulation"]
  node_logic["Logic Evaluation<br/>digital simulator<br/>[LogicEngine.ts]"]
  node_electronic["Electronic Evaluation<br/>electrical simulator"]
  node_truth_table["Truth Table Check<br/>logic verification<br/>[truthTableCheck.ts]"]
end

node_types["Circuit Model<br/>shared contracts<br/>[types.ts]"]

node_index -->|"loads"| node_main
node_main -->|"mounts"| node_app
node_main -->|"applies"| node_styles
node_app -->|"composes"| node_navbar
node_app -->|"composes"| node_canvas
node_app -->|"composes"| node_left_sidebar
node_app -->|"composes"| node_right_sidebar
node_app -->|"composes"| node_modals
node_left_sidebar -->|"selects tools/components"| node_canvas
node_canvas -->|"edits model"| node_types
node_canvas -->|"routes wires"| node_pathfinding
node_pathfinding -->|"provides geometry"| node_wiring
node_wiring -->|"supplies wires"| node_net_engine
node_net_engine -->|"groups terminals"| node_disjoint_set
node_net_engine -->|"supplies nets"| node_logic
node_net_engine -->|"supplies nets"| node_electronic
node_logic -->|"validates behavior"| node_truth_table
node_logic -->|"renders signal state"| node_canvas
node_electronic -->|"renders evaluated state"| node_canvas
node_logic -->|"reports results"| node_right_sidebar
node_electronic -->|"reports results"| node_right_sidebar
node_vite -.->|"serves/builds"| node_index
node_deploy -.->|"deploys build"| node_vite

click node_index "https://github.com/weekendeboy/logicgrid/blob/main/index.html"
click node_main "https://github.com/weekendeboy/logicgrid/blob/main/src/main.tsx"
click node_app "https://github.com/weekendeboy/logicgrid/blob/main/src/App.tsx"
click node_navbar "https://github.com/weekendeboy/logicgrid/blob/main/src/components/Navbar.tsx"
click node_canvas "https://github.com/weekendeboy/logicgrid/blob/main/src/components/CanvasWorkspace.tsx"
click node_left_sidebar "https://github.com/weekendeboy/logicgrid/blob/main/src/components/LeftSidebar.tsx"
click node_right_sidebar "https://github.com/weekendeboy/logicgrid/blob/main/src/components/RightSidebar.tsx"
click node_modals "https://github.com/weekendeboy/logicgrid/blob/main/src/components/Modals.tsx"
click node_types "https://github.com/weekendeboy/logicgrid/blob/main/src/types.ts"
click node_pathfinding "https://github.com/weekendeboy/logicgrid/blob/main/src/engine/Pathfinding.ts"
click node_wiring "https://github.com/weekendeboy/logicgrid/blob/main/src/engine/WiringEngine.ts"
click node_net_engine "https://github.com/weekendeboy/logicgrid/blob/main/src/engine/NetEngine.ts"
click node_disjoint_set "https://github.com/weekendeboy/logicgrid/blob/main/src/engine/DisjointSet.ts"
click node_logic "https://github.com/weekendeboy/logicgrid/blob/main/src/engine/LogicEngine.ts"
click node_electronic "https://github.com/weekendeboy/logicgrid/blob/main/src/engine/ElectronicEngine.ts"
click node_truth_table "https://github.com/weekendeboy/logicgrid/blob/main/src/engine/truthTableCheck.ts"
click node_styles "https://github.com/weekendeboy/logicgrid/blob/main/src/index.css"
click node_vite "https://github.com/weekendeboy/logicgrid/blob/main/vite.config.ts"
click node_deploy "https://github.com/weekendeboy/logicgrid/blob/main/.github/workflows/deploy.yml"

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_index,node_main,node_styles,node_vite,node_deploy toneBlue
class node_app,node_navbar,node_canvas,node_left_sidebar,node_right_sidebar,node_modals toneAmber
class node_pathfinding,node_wiring,node_net_engine,node_disjoint_set toneMint
class node_logic,node_electronic,node_truth_table toneRose
class node_types toneNeutral
```

## Components

### Browser Runtime

- [HTML Entry](https://github.com/weekendeboy/logicgrid/blob/main/index.html): Vite entry · `index.html`
- [React Mount](https://github.com/weekendeboy/logicgrid/blob/main/src/main.tsx): React bootstrap · `src/main.tsx`
- [Global Styling](https://github.com/weekendeboy/logicgrid/blob/main/src/index.css): CSS · `src/index.css`
- [Vite Toolchain](https://github.com/weekendeboy/logicgrid/blob/main/vite.config.ts): build configuration · `vite.config.ts`
- [Deployment Automation](https://github.com/weekendeboy/logicgrid/blob/main/.github/workflows/deploy.yml): CI workflow · `.github/workflows/deploy.yml`

### Editor UI

- [Application Shell](https://github.com/weekendeboy/logicgrid/blob/main/src/App.tsx): React composition · `src/App.tsx`
- [Navigation](https://github.com/weekendeboy/logicgrid/blob/main/src/components/Navbar.tsx): UI surface · `src/components/Navbar.tsx`
- [Circuit Canvas](https://github.com/weekendeboy/logicgrid/blob/main/src/components/CanvasWorkspace.tsx): editing boundary · Owns placement, selection, drawing, and wiring interaction. · `src/components/CanvasWorkspace.tsx`
- [Tool Sidebar](https://github.com/weekendeboy/logicgrid/blob/main/src/components/LeftSidebar.tsx): component selection · `src/components/LeftSidebar.tsx`
- [Inspector Sidebar](https://github.com/weekendeboy/logicgrid/blob/main/src/components/RightSidebar.tsx): inspection boundary · Shows selected-item properties and simulation state. · `src/components/RightSidebar.tsx`
- [Modal Workflows](https://github.com/weekendeboy/logicgrid/blob/main/src/components/Modals.tsx): UI surface · `src/components/Modals.tsx`

### Connectivity Pipeline

- [Wire Routing](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/Pathfinding.ts): pathfinding engine · `src/engine/Pathfinding.ts`
- [Wire Operations](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/WiringEngine.ts): wiring engine · `src/engine/WiringEngine.ts`
- [Net Resolution](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/NetEngine.ts): connectivity engine · Derives electrical nets independently of wire geometry. · `src/engine/NetEngine.ts`
- [Connected Components](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/DisjointSet.ts): union-find · `src/engine/DisjointSet.ts`

### Simulation

- [Logic Evaluation](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/LogicEngine.ts): digital simulator · `src/engine/LogicEngine.ts`
- [Electronic Evaluation](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/ElectronicEngine.ts): electrical simulator · `src/engine/ElectronicEngine.ts`
- [Truth Table Check](https://github.com/weekendeboy/logicgrid/blob/main/src/engine/truthTableCheck.ts): logic verification · `src/engine/truthTableCheck.ts`

### Other components

- [Circuit Model](https://github.com/weekendeboy/logicgrid/blob/main/src/types.ts): shared contracts · Defines components, terminals, wires, nets, and derived outputs. · `src/types.ts`

## Connections

- HTML Entry → React Mount: loads
- React Mount → Application Shell: mounts
- React Mount → Global Styling: applies
- Application Shell → Navigation: composes
- Application Shell → Circuit Canvas: composes
- Application Shell → Tool Sidebar: composes
- Application Shell → Inspector Sidebar: composes
- Application Shell → Modal Workflows: composes
- Tool Sidebar → Circuit Canvas: selects tools/components
- Circuit Canvas → Circuit Model: edits model
- Circuit Canvas → Wire Routing: routes wires
- Wire Routing → Wire Operations: provides geometry
- Wire Operations → Net Resolution: supplies wires
- Net Resolution → Connected Components: groups terminals
- Net Resolution → Logic Evaluation: supplies nets
- Net Resolution → Electronic Evaluation: supplies nets
- Logic Evaluation → Truth Table Check: validates behavior
- Logic Evaluation → Circuit Canvas: renders signal state
- Electronic Evaluation → Circuit Canvas: renders evaluated state
- Logic Evaluation → Inspector Sidebar: reports results
- Electronic Evaluation → Inspector Sidebar: reports results
- Vite Toolchain → HTML Entry: serves/builds
- Deployment Automation → Vite Toolchain: deploys build
