// system design
Project Architecture
Eidolon is a fully local Arduino emulator using official Wokwi repositories for maximum compatibility. It features real AVR8 CPU emulation, 48+ interactive electronic components, a comprehensive wire system, and a build-time component discovery pipeline.
High-Level Overview
Browser (React + Vite)
├── Monaco Editor ──► useEditorStore (Zustand)
├── SimulatorCanvas ──► useSimulatorStore (Zustand)
│ ├── AVRSimulator (avr8js) 16 MHz AVR8 CPU
│ ├── RP2040Simulator (rp2040js)
│ ├── PinManager pin → component mapping
│ ├── PartSimulationRegistry 16 interactive parts
│ └── 48+ wokwi-elements Lit Web Components
└── HTTP (Axios) ──► eidolon-server (port 8001)
└── eidolon-firmware ──► arduino-cli subprocessData Flows
1. Compilation
Click "Compile"
→ EditorToolbar reads all workspace files
→ POST /api/compile/ { files, board_fqbn }
→ eidolon-firmware writes the sketch to a build directory
→ arduino-cli compile --fqbn <board> --output-dir build/
→ Returns hex_content (Intel HEX string)
→ useSimulatorStore.setCompiledHex() → loadHex()2. Simulation Loop
Click "Run"
→ AVRSimulator.start()
→ requestAnimationFrame loop @ ~60 FPS
→ Each frame: Math.floor(267 000 × speed) cycles
├── avrInstruction(cpu) — decode + execute one AVR instruction
└── cpu.tick() — advance Timer0/1/2, USART, ADC
→ PORTB/C/D write listeners fire
→ PinManager.updatePort() → per-pin callbacks
→ PartSimulationRegistry.onPinStateChange()
→ wokwi-elements update visually3. Input Components
User presses button on canvas
→ wokwi web component fires 'button-press' event
→ DynamicComponent catches event
→ PartSimulationRegistry.attachEvents() handler
→ AVRSimulator.setPinState(arduinoPin, LOW)
→ AVRIOPort.setPin() injects external pin state
→ CPU reads pin in next instructionKey Frontend Stores (Zustand)
| Store | Key State | Purpose |
|---|---|---|
useEditorStore | files[], activeFileId | Multi-file Monaco workspace |
useSimulatorStore | simulator, components, wires, running | Simulation + canvas state |
useProjectStore | projectId, slug | Currently open project |
Backend Routes
| Route | Description |
|---|---|
POST /api/compile/ | Compile sketch files - Intel HEX / UF2 |
GET /api/compile/boards | List available boards |
GET /api/libraries/* | Arduino Library Manager integration |
GET /health | Health check endpoint |
Wire System
Wires are stored as objects with start/end endpoints tied to component pin positions:
1{
2 id: string
3 start: { componentId, pinName, x, y }
4 end: { componentId, pinName, x, y }
5 color: string
6 signalType: 'digital' | 'analog' | 'power-vcc' | 'power-gnd'
7}- Orthogonal routing, no diagonal segments
- Segment drag, drag perpendicular to segment orientation
- Auto-update, wire positions recalculate when components move
- Grid snapping, 20 px grid for all wire endpoints
Full details: See docs/ARCHITECTURE.md in the repository.