# egldgn/circuitengine architecture

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

- Interactive diagram: https://gitdiagram.com/egldgn/circuitengine
- Repository: https://github.com/egldgn/circuitengine

## Overview

Circuit Engine is a desktop logic-circuit editor and simulator. The visible workflow starts with a .CESL script or .CEC circuit file: the application parses or loads it, constructs circuit elements and a breadboard connection map, then initializes the interactive artist for visualization and editing. Gate logic computes circuit behavior. The code excerpts show parsing/loading, construction, and rendering entry points; details of most interaction callbacks and persistence are only partially sampled, so those links are omitted or limited to documented calls.

Main entry points: [`CEngine.cpp`](https://github.com/egldgn/circuitengine/blob/master/CEngine.cpp) (Application startup), [`CEngine.h`](https://github.com/egldgn/circuitengine/blob/master/CEngine.h) (Circuit manager), [`Gate.h`](https://github.com/egldgn/circuitengine/blob/master/Gate.h) (Logic gates), [`CircuitElement.h`](https://github.com/egldgn/circuitengine/blob/master/CircuitElement.h) (Circuit elements)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_runtime["Application startup<br/>[CEngine.cpp]"]
end

subgraph group_circuit["Circuit model"]
  node_commander["Circuit manager<br/>[CEngine.h]"]
  node_elements["Circuit elements<br/>[CircuitElement.h]"]
  node_gates["Logic gates<br/>[Gate.h]"]
  node_bitsets["Bit-state arrays<br/>[Binary.h]"]
end

subgraph group_board["Board connectivity"]
  node_breadboard[("Breadboard map<br/>[BreadBoard.h]")]
  node_boardnodes["Board connection nodes<br/>[BBNode.h]"]
end

subgraph group_visual["Visualization"]
  node_artist["Interactive artist<br/>[Artist.h]"]
end

node_user(("Circuit user"))
node_files["Circuit files"]

node_user -->|"opens circuit"| node_runtime
node_user -->|"provides input"| node_files
node_files -->|"supplies path"| node_runtime
node_runtime -->|"parses or loads"| node_commander
node_runtime -->|"initializes and starts"| node_artist
node_commander -->|"constructs board"| node_breadboard
node_commander -->|"creates elements"| node_elements
node_elements -->|"adds gates"| node_gates
node_gates -.->|"uses bit arrays"| node_bitsets
node_breadboard -->|"creates connection nodes"| node_boardnodes
node_boardnodes -->|"references gate"| node_gates
node_artist -.->|"reads circuit state"| node_commander

click node_runtime "https://github.com/egldgn/circuitengine/blob/master/CEngine.cpp"
click node_commander "https://github.com/egldgn/circuitengine/blob/master/CEngine.h"
click node_elements "https://github.com/egldgn/circuitengine/blob/master/CircuitElement.h"
click node_gates "https://github.com/egldgn/circuitengine/blob/master/Gate.h"
click node_bitsets "https://github.com/egldgn/circuitengine/blob/master/Binary.h"
click node_breadboard "https://github.com/egldgn/circuitengine/blob/master/BreadBoard.h"
click node_boardnodes "https://github.com/egldgn/circuitengine/blob/master/BBNode.h"
click node_artist "https://github.com/egldgn/circuitengine/blob/master/Artist.h"

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_runtime,node_user toneBlue
class node_commander,node_elements,node_gates,node_bitsets toneAmber
class node_breadboard,node_boardnodes toneMint
class node_artist toneRose
class node_files toneIndigo
```

## Components

### Application entry

- [Application startup](https://github.com/egldgn/circuitengine/blob/master/CEngine.cpp): `CEngine.cpp`

### Circuit model

- [Circuit manager](https://github.com/egldgn/circuitengine/blob/master/CEngine.h): `CEngine.h`
- [Circuit elements](https://github.com/egldgn/circuitengine/blob/master/CircuitElement.h): `CircuitElement.h`
- [Logic gates](https://github.com/egldgn/circuitengine/blob/master/Gate.h): `Gate.h`
- [Bit-state arrays](https://github.com/egldgn/circuitengine/blob/master/Binary.h): `Binary.h`

### Board connectivity

- [Breadboard map](https://github.com/egldgn/circuitengine/blob/master/BreadBoard.h): `BreadBoard.h`
- [Board connection nodes](https://github.com/egldgn/circuitengine/blob/master/BBNode.h): `BBNode.h`

### Visualization

- [Interactive artist](https://github.com/egldgn/circuitengine/blob/master/Artist.h): `Artist.h`

### Other components

- **Circuit user**
- **Circuit files**

## Connections

- Circuit user → Application startup: opens circuit (evidence: `CEngine.cpp`)
- Circuit user → Circuit files: provides input
- Circuit files → Application startup: supplies path (evidence: `CEngine.cpp`)
- Application startup → Circuit manager: parses or loads (evidence: `CEngine.cpp`)
- Application startup → Interactive artist: initializes and starts (evidence: `CEngine.cpp`)
- Circuit manager → Breadboard map: constructs board (evidence: `CEngine.h`)
- Circuit manager → Circuit elements: creates elements (evidence: `CEngine.h`)
- Circuit elements → Logic gates: adds gates (evidence: `CircuitElement.h`)
- Logic gates → Bit-state arrays: uses bit arrays (evidence: `Gate.h`)
- Breadboard map → Board connection nodes: creates connection nodes (evidence: `BreadBoard.h`)
- Board connection nodes → Logic gates: references gate (evidence: `BBNode.h`)
- Interactive artist → Circuit manager: reads circuit state (evidence: `Artist.h`)
