How weekendeboy/logicgrid works
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: App.tsx Application Shell · CanvasWorkspace.tsx Circuit Canvas · NetEngine.ts Net Resolution · LogicEngine.ts Logic Evaluation
Components 19
Browser Runtime
- HTML Entry
index.html - React Mount
src/main.tsx - Global Styling
src/index.css - Vite Toolchain
vite.config.ts - Deployment Automation
.github/workflows/deploy.yml
Editor UI
- Application Shell
src/App.tsx - Navigation
src/components/Navbar.tsx - Circuit Canvas · Owns placement, selection, drawing, and wiring interaction.
src/components/CanvasWorkspace.tsx - Tool Sidebar
src/components/LeftSidebar.tsx - Inspector Sidebar · Shows selected-item properties and simulation state.
src/components/RightSidebar.tsx - Modal Workflows
src/components/Modals.tsx
Connectivity Pipeline
- Wire Routing
src/engine/Pathfinding.ts - Wire Operations
src/engine/WiringEngine.ts - Net Resolution · Derives electrical nets independently of wire geometry.
src/engine/NetEngine.ts - Connected Components
src/engine/DisjointSet.ts
Simulation
- Logic Evaluation
src/engine/LogicEngine.ts - Electronic Evaluation
src/engine/ElectronicEngine.ts - Truth Table Check
src/engine/truthTableCheck.ts
Other components
- Circuit Model · Defines components, terminals, wires, nets, and derived outputs.
src/types.ts
Connections 23
- 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