How the system is put together today. Each area has a short summary here and a topical document with the mechanism detail. Where this page and a topical document disagree, the topical document is the more specific record.
| Area | Detail |
|---|---|
| File model and parser | kicad-format-and-parsing.md |
| Session, protocol, undo | session-and-protocol.md |
| Storage and revisions | storage-and-revisions.md |
| Schematic editor | schematic-editor.md |
Manufacturing output and kicad-cli |
manufacturing-and-batch-tooling.md |
| Frontend rendering and UI | frontend-rendering-and-ui.md |
browser (TypeScript, PixiJS) Go backend external
┌────────────────────────────┐ HTTP + WS ┌──────────────────────────┐
│ canvas engine (WebGL) │◀────────────▶│ session: parsed tree, │ Postgres (accounts, projects,
│ React shell, command bar │ envelope │ undo stacks, write lease │ revision metadata, patch log)
│ AI proposal review card │ (seq, version)│ view model projection │
└────────────────────────────┘ │ proposal overlay + AI │ kicad-cli in Docker
│ batch sandbox ───────────┼─▶ (DRC, ERC, export, import)
└──────────────────────────┘ LLM provider (optional)
The backend parses a .kicad_pcb or .kicad_sch file into a lossless syntax tree, streams a flat view model
to the browser, and applies edits as coordinate patches to that tree. A save writes a new revision file. The
frontend never holds the file; it holds a projection of it.
The parsed tree is a single []nodeRec slice of six integers per node with no pointers, so the garbage
collector skips it. Text is offset pairs into the original file plus an append-only pool for text that is not
in the file. Every byte of original whitespace is captured on some node's Leading or a list's Trailing,
so untouched content is written back byte-for-byte: round-trip is a property of the structure, not a
best-effort formatter.
Only nodes that are mutated have numbers parsed. Everything else stays a raw source string, which avoids
whole-file diffs on save. Objects are identified by UUID (or tstamp in older files). A reference designator
is a label, not an identity: duplicates and REF** are legal.
Where a node has no native identity (common in pre-KiCad-6 files) or shares one with a sibling, the backend derives a stable key from its position among the root's children. Those nodes are addressable, but older files remain the weakest corner of the model.
A WebSocket carries every command inside an envelope with a sequence number and the document version. The mutation order is fixed: validate, capture the inverse, patch, increment the version, append to the patch log, then acknowledge. Nothing is acknowledged before it is logged.
Commands: move, rotate and flip a component, undo and redo, and the object lifecycle (create trace, via,
footprint, zone, graphic and text; delete; edit). Rejections come from a closed set of reasons
(no_write_lease, stale_version, unknown_target, invalid_params, rate_limited, locked), each with a
defined client rollback.
Storage is content-addressed and deduplicated. Revisions are event-sourced and rebuilt from retained checkpoints, so reconstruction cost stays bounded however long the history grows. Sessions are cached per process with idle eviction. The deployment is single-instance by design: two instances behind a load balancer would each hold a valid-looking write lease over their own copy of a project.
A second editor for .kicad_sch: symbol search and placement from a hosted library, wires, junctions, net
labels and no-connect flags, move/rotate/mirror, undo, netlist generation and ERC through kicad-cli, and
schematic-to-PCB sync. Sync is forward-only: it adds footprints for new symbols but does not reassign nets on
placed pads or flag removed parts. There are no buses, no hierarchy and no schematic-side text or graphics.
All DRC, ERC, export and import runs through a sandboxed worker pool: a fixed number of workers, a scratch
directory per job that is wiped afterwards, a wall-clock timeout that kills the whole process group, and a
non-root container with no network. Two builds are registered (KiCad 7.0.11 and 9.0), and jobs are routed by
file version, because the versions differ in subcommands and in the newest format they can open. kicad-cli
is an arm's-length subprocess; nothing from KiCad is linked into the Go binary.
Exit codes only say whether kicad-cli ran: pcb drc exits 0 whether it finds 0 or 2,000 violations, so the
JSON report body is the only source of truth. Output is drained concurrently to avoid deadlocking on a large
report.
Export covers Gerbers, drill files, pick-and-place, BOM and a fabrication-drawing PDF, behind a pre-flight readiness check (DRC clean, ERC clean, footprints assigned, zones filled, zones not degraded, schematic and PCB in sync). A real EasyEDA importer runs through the same sandbox and emits a fidelity report. Unrecognized constructs become warnings, never silence.
PixiJS rendering with one Graphics per layer baked in world coordinates, a drag layer for the object being
moved, its own spatial grid for hit-testing, and chunked earcut triangulation for zone fills. React owns the
DOM shell and talks to the engine over an event bus at most 10 times a second; nothing in React re-renders
inside the render loop. The UI has a theme toggle, a command palette wired to real actions, a
connectivity-aware ratsnest and adaptive grid spacing.
Accounts with hashed sessions, tenant isolation checked in every handler and on WebSocket upgrade, and
storage and project quotas checked before bytes are accepted. There are separate rate limits for WebSocket
commands, kicad-cli jobs and LLM calls, because they have different cost profiles. There is no CSRF
protection yet, because no cookie-based session flow exists.
Enabled with ASSISTANT_ENABLED on the backend and VITE_ENABLE_AI_ASSISTANT on the frontend. With both off
the behavior is identical to a build without it.
A proposal is a fork, not a write path. The assistant works on an overlay over the immutable base: field patches keyed by node identity, tombstones, and created subtrees, with the whitespace of created nodes derived at serialization time so the same converged state always yields the same bytes. The human reviews the diff and merges it, which replays ordinary commands through the same validate-and-log path as a manual edit, so a merge is undone with the normal undo stack.
Closed operation vocabulary. move_component, rotate_component, flip_component, create_trace,
create_via, create_footprint, create_zone, create_graphic, create_text, delete_object and
edit_object. Objects are addressed by UUID, never by reference designator. The board outline and locked
items are not targetable, and edit_object can only change width, size, drill, text, height, thickness and
clearance.
Real DRC is the gate. A proposal is presented only if kicad-cli DRC on its exact serialized bytes shows
at least one targeted violation cleared and no new error. Violations are compared by fingerprint (type plus
sorted item UUIDs) as a multiset. DRC is never mocked.
Two ways to make proposals.
- A model loop (Gemini adapter, with retry and backoff on rate limits) that reads the board through query tools and edits through the operation tools, bounded by iteration, DRC-run, tool-call, time and token ceilings that are enforced, not just monitored.
- A deterministic solver with no model: copper narrowing for clearance and board-edge errors, via enlargement for annular-ring and via-diameter errors, and small footprint moves for clearance and short errors. Every candidate goes through the same gate.
Context is queried, not dumped. The model asks for the violation list, the detail of one violation, and the objects nearby. Connectivity comes from DRC, not the client ratsnest, which ignores zone fills.
Evaluation lives in backend/internal/assistant/eval and cmd/aieval: seeded perturbations of real
boards labelled by real DRC, with the exact revert as the oracle, plus a baseline mode that targets a board's
own errors. See status.md for results and limits.
- The backend is pure Go. No cgo, no WASM, no C++ bindings.
- The source file is never overwritten; saving writes a new revision via temp file, fsync and rename, then re-parses and verifies.
- The LLM key stays server-side, and no model call runs inside a session lock or on the WebSocket path.