// systemdesign
Projektarchitektur
Eidolon ist ein vollständig lokaler Arduino-Emulator, der offizielle Wokwi-Repositories für maximale Kompatibilität verwendet. Es bietet echte AVR8-CPU-Emulation, 48+ interaktive elektronische Komponenten, ein umfassendes Leitungssystem und eine Build-Zeit-Komponentenerkennungspipeline.
Überblick auf hoher Ebene
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 subprocessDatenflüsse
1. Kompilierung
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. Simulationsschleife
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. Eingabekomponenten
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 instructionWichtige Frontend-Stores (Zustand)
| Store | Schlüsselzustand | Zweck |
|---|---|---|
useEditorStore | files[], activeFileId | Multi-Datei-Monaco-Arbeitsbereich |
useSimulatorStore | simulator, components, wires, running | Simulations- + Leinwandzustand |
useProjectStore | projectId, slug | Aktuell geöffnetes Projekt |
Backend-Routen
| Route | Beschreibung |
|---|---|
POST /api/compile/ | Sketch-Dateien kompilieren - Intel HEX / UF2 |
GET /api/compile/boards | Verfügbare Boards auflisten |
GET /api/libraries/* | Arduino-Bibliotheksverwaltungsintegration |
GET /health | Health-Check-Endpunkt |
Leitungssystem
Leitungen werden als Objekte mit Start-/Endpunkten gespeichert, die an Komponenten-Pin-Positionen gebunden sind:
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}- Orthogonale Führung, keine diagonalen Segmente
- Segment ziehen, senkrecht zur Segmentausrichtung ziehen
- Automatische Aktualisierung, Leitungspositionen werden neu berechnet, wenn Komponenten verschoben werden
- Rasterfang, 20 px Raster für alle Leitungsendpunkte
Vollständige Details: Siehe docs/ARCHITECTURE.md im Repository.