How We Built the Wiring Engine
A deep dive into the constraint solver that powers Schematik's automatic wiring — and the three rewrites it took to get it right.

#The Problem
Automatic wiring sounds simple: connect point A to point B. In practice, it's a constraint satisfaction problem that has to account for signal integrity, power distribution, physical clearances, and user intent — all in real time.
#Attempt One: Rule-Based
Our first approach was a rule engine. If the user places a sensor, connect VCC to the power rail, GND to ground, and data pins to the nearest available GPIO. It worked for simple circuits but collapsed under complexity.
#Attempt Two: Graph-Based
We modeled the schematic as a directed graph and used shortest-path algorithms to find optimal connections. Better, but it couldn't handle constraints like "this signal needs a pull-up resistor" or "these traces can't run parallel."
#Attempt Three: Constraint Solver
The breakthrough came when we reframed wiring as a constraint satisfaction problem. Each connection has requirements (voltage levels, current capacity, impedance matching) and the solver finds valid assignments that satisfy all constraints simultaneously.
#Where We Are Now
The current engine handles circuits with hundreds of components in under 200ms. It's not perfect — analog circuits still need manual tweaking — but it's fast enough to feel interactive.