Skip to content

szymontex/codeyourpcb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

299 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeYourPCB

Code-first PCB design. Describe your circuit board in a simple DSL — get a deterministic, git-friendly, AI-editable design.

// blink.cypcb — 555 timer LED blink circuit
version 1

board blink {
    size 60mm x 40mm
    layers 2
}

component J1 connector "PIN-HDR-1x2" { value "5V PWR"; at 5mm, 20mm }
component U1 ic "SOIC-8" { value "NE555"; at 28mm, 20mm }
component R1 resistor "0402" { value "10k"; at 35mm, 30mm }
component C1 capacitor "1206" { value "10uF"; at 43mm, 20mm }
component LED1 led "0805" { value "RED"; at 55mm, 20mm }

net VCC [width 0.5mm  current 2A] { J1.1; U1.8; U1.4; R1.1 }
net GND { J1.2; U1.1; C1.2; LED1.K }

// Routed traces saved in the file — survives reload, diffs cleanly
trace VCC {
    layer Top
    width 0.5mm
    path 5mm,20mm -> 15mm,20mm -> 28mm,20mm -> 35mm,30mm
}

Split view — code editor + live board preview

Save the file, board updates instantly. No compile step, no refresh.

New here? Syntax reference | Getting started | Examples


Why?

Traditional PCB tools (KiCad, Altium, Eagle) are GUI-first. The project file is a binary/XML side-effect of clicking. This makes:

  • Git diffs unreadable
  • AI assistance impractical
  • Team review painful
  • Automation fragile

CodeYourPCB flips the model: the source file is the design. Text in, board out.

The LLM angle

The core idea: give AI coding assistants like Claude Code, Copilot, or Cursor the ability to design real PCBs through declarative code — the same way they write software.

Traditional PCB formats are opaque to LLMs. A KiCad .kicad_pcb file is thousands of lines of coordinate soup. No LLM can reason about that meaningfully.

.cypcb is different — the semantics are declarative and human-readable:

component U1 ic "SOIC-8" { value "NE555"; at 28mm, 20mm }
net VCC [width 0.5mm  current 2A] { U1.8; U1.4; R1.1 }

trace VCC {
    layer Top
    width 0.5mm
    path 5mm,20mm -> 28mm,20mm -> 35mm,30mm
}

An LLM can generate this, review it, refactor it, and catch mistakes — just like source code. Even routed traces are human-readable path blocks that diff cleanly in git.

3D board view with JLCPCB parts search


Features

Feature Status
.cypcb DSL with Tree-sitter parser Done
Live preview — save file, board updates instantly Done
2D renderer (KiCad-style) Done
3D viewer — extruded copper, solder mask, round trace caps Done
Interactive trace routing (45° constraint, obstacle dodge) Done
Trace segment & corner editing (drag to reshape) Done
Trace persistence — routed traces saved as path blocks, survive reload Done
Bidirectional sync — edit trace code ↔ board updates in real-time Done
Net constraints — [width 0.5mm], [current 2A] per net Done
IPC-2221 auto-width from current rating Done
DRC — clearance, drill, connectivity, trace width vs current Done
Gerber / Excellon / BOM / pick-and-place export Done
Monaco editor with context-aware completions Done
JLCPCB parts search & placement Done
Custom footprint definitions in DSL Done
Project manager with templates Done
Dark / Light theme Done
Web app (WASM) + Desktop app (Tauri v2) Done
KiCad component library import Done
Copper pour / ground planes Planned
Module system — reusable circuit blocks, packages Planned
KiCad interop — import/export .kicad_pcb Planned
Parts engine — auto component picking from JLCPCB/LCSC Planned
Schematic generation from .cypcb Planned
Autorouter rewrite Planned
Differential pair routing Planned
CI/CD — cypcb check + cypcb export in GitHub Actions Planned

555 timer blink circuit — board view with routed traces

Project manager — templates and recent projects


Quick Start

Web (development)

# Prerequisites: Rust, Node.js 18+, wasm-pack
cargo install wasm-pack

# Clone and start
git clone https://github.com/szymontex/codeyourpcb.git
cd codeyourpcb/viewer
npm install
npm start          # builds WASM + starts dev server

Open http://localhost:5173 — pick a template or open a .cypcb file.

Desktop app (Tauri)

# Linux prerequisites
sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev pkg-config

npm run dev:desktop   # dev mode
npm run build:desktop # release installer

CLI

cargo run -p cypcb-cli -- check examples/blink.cypcb   # DRC
cargo run -p cypcb-cli -- export examples/blink.cypcb  # Gerber + Excellon

IDE workflow

Edit .cypcb files in your editor (VS Code, Neovim, etc.). Run npm run dev:watch in a terminal — the board preview updates on every save via WebSocket hot reload.


Keyboard Shortcuts

Key Action
Ctrl+E Toggle code editor
Ctrl+S Save file
Ctrl+O Open file / project manager
Ctrl+J JLCPCB parts search
Ctrl+Z / Ctrl+Shift+Z Undo / Redo
F Fit board to view
3 Toggle 3D view
R / Shift+R Rotate component CW / CCW
? Keyboard shortcuts help

During trace routing: F flip layer, / flip posture, Q toggle corner mode, A toggle angle snap.


Project Structure

codeyourpcb/
├── crates/
│   ├── cypcb-core         # Types, coordinates, units
│   ├── cypcb-parser       # Tree-sitter grammar + AST
│   ├── cypcb-world        # ECS board state (hecs)
│   ├── cypcb-drc          # Design rule checks
│   ├── cypcb-autoroute    # A*-based autorouter (WIP)
│   ├── cypcb-router       # FreeRouting DSN bridge
│   ├── cypcb-calc         # Electrical calculations (IPC-2221)
│   ├── cypcb-export       # Gerber / Excellon / CPL export
│   ├── cypcb-kicad        # KiCad format import
│   ├── cypcb-library      # Component library (SQLite + FTS5)
│   ├── cypcb-lsp          # Language server (tower-lsp)
│   ├── cypcb-render       # Board engine (WASM)
│   ├── cypcb-rules        # Design rules & manufacturer presets
│   ├── cypcb-platform     # Native/web abstraction layer
│   ├── cypcb-watcher      # File system watcher
│   └── cypcb-cli          # CLI entry point
├── viewer/                # TypeScript frontend (Vite + Canvas 2D + Three.js)
├── src-tauri/             # Tauri v2 desktop shell
├── examples/              # Sample .cypcb files
└── docs/                  # User guide, syntax, API reference

Landscape

CodeYourPCB sits in the emerging "PCB as code" space alongside a few other tools:

  • JITX — commercial, most mature code-first EDA. Constraint-driven routing, signal integrity, VS Code integration. Proprietary.
  • atopile — open-source .ato language with compiler, reusable modules, component picking. Uses KiCad for layout. MIT.
  • tscircuit — open-source React/TypeScript PCB framework. Very LLM-friendly (TypeScript is natural for models). MIT.

Where CodeYourPCB differs: own rendering engine (no KiCad dependency), runs in browser via WASM, interactive routing built-in, traces persist as readable DSL code. Where it's behind: no module/package system yet, no schematic capture, smaller component library.


Documentation


Status

Experimental. The DSL and file format may change between versions.

The core loop works: write .cypcb → see board → route traces → save → reload. Traces are deterministic (bit-exact round-trip). The main gaps are copper pour, module system, and autorouter.

PRs welcome.


License

Licensed under either of:

at your option.

About

code-first PCB design. Write circuits as text, get autorouted boards, Gerber exports, and DRC validation.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors