

ThinkerAFE
A browser sandbox testing if LLMs can optimize KiCad board layouts by treating the AI as an untrusted proposal generator for low-noise biosignal PCBs
- Size
- 28.1 × 32.6 mm
- Copper layers
- 4
- Thickness
- 1.6 mm
- Parts
- 57
- Nets
- 64
- Pads
- 214
- Tracks, vias
- 389, 57
- Pours
- 6
- Routed
- Yes
- KiCad
- KiCad 4
- Created
- 10 Aug 2026
- Updated
- 11 Aug 2026
Overview
ThinkerAFE is an open-source printed circuit board by yelabb, from the yelabb/pcbfork repository on GitHub. It is a 4-layer board of 28.1 × 32.6 mm with 57 parts on 64 nets, routed with 389 tracks and 57 vias.
It is built around the TPD4E1B06DCK, LM2664M6 and TLV70025DDCR, with the TPS72325DBV among its other parts. Its parts include 37 capacitors, 11 resistors, 7 ICs and 2 connectors.
Main components
4TPD4E1B06DCK
SC-70-6-40℃~+125℃ 0.7pF 14.5V 3A@8/20us 45W@8/20us 5.5V 500pA 7V Bidirectional ESD Four channels IEC 61000-4-2、IEC 61000-4-5 SC-70-6 ESD and Surge Protection (TVS/ESD) ROHSTexas InstrumentsESD And Surge Protection (TVS/ESD)LM2664M6
SOT-23-6-40℃~+85℃ -5.5V~-1.8V 1.8V~5.5V 12Ω 40mA 500uA 80kHz 91% Inverted Not supported SOT-23-6 Charge Pumps ROHSTexas InstrumentsCharge PumpsTLV70025DDCR
SOT-23-5-40℃~+125℃ 1 2.5V 200mA 250mV@(200mA) 31uA 48uVrms 5.5V 68dB@(1kHz) Fixed Over Current Protection、Thermal Shutdown Positive SOT-23-5 Voltage Regulators - Linear, Low Drop Out (LDO) Regulators ROHSTexas InstrumentsVoltage Regulators - Linear, Low Drop Out (LDO) RegulatorsTPS72325DBV
SOT-23-5-40℃~+125℃ 1 2.5V 2.7V 200mA 48dB@(10kHz)、65dB@(1kHz) 500mV@(200mA) 60uVrms Fixed Negative Over Current Protection、Over Temperature Protection、Enable SOT-23-5 Voltage Regulators - Linear, Low Drop Out (LDO) Regulators ROHSTexas InstrumentsVoltage Regulators - Linear, Low Drop Out (LDO) Regulators
README
README.mdpcbFork
pcbFork is an experiment in AI-assisted component placement for low-noise biosignal PCBs. It asks a narrow question: can a language model, treated as an untrusted proposal generator, improve the physical placement of components on an EEG/BCI front-end when its output is constrained, validated, and scored deterministically in the browser?
It is not an EDA tool and it is not a design authority. It is a harness for studying that question on real KiCad boards, entirely client-side.
How it works
The tool separates two things that are usually conflated when people talk about "AI PCB design":
- Proposal — a stochastic step that suggests where components could go. This is the language model's only job. It is assumed to be unreliable.
- Judgement — deterministic, inspectable code that decides whether a proposal is structurally valid and whether it is geometrically better or worse than the original.
The model never edits the board directly. It returns a placement patch (a list of ref x y [rot] moves), which is applied textually to the original KiCad source. Nets, pads, tracks, and zones are preserved by construction, so the model cannot silently corrupt connectivity regardless of board size. Everything the model produces is then re-parsed, validated, and re-scored by the same code path that judges the original.
KiCad .kicad_pcb → parse → summarise → model proposes placement patch
→ apply patch → re-parse → validate → score → compare → iterateWhat is measured
All metrics are geometric heuristics computed from placement and routing geometry. They are proxies for electrical behaviour, not measurements of it. They exist to (a) give the optimisation loop a differentiable-enough objective and (b) let a human compare two layouts on the same axes.
BCIAnalyzer locates the analog front-end (ADS1299 / ADS129x / RHD families, by value/footprint markers) and derives, among others:
| Metric | Definition | Proxy for |
|---|---|---|
| AFE↔radio distance | mm from AFE to nearest radio component | RF ingress into analog inputs |
| Decoupling proximity | mean/max distance from AFE power-pad decoupling caps to the AFE | supply loop area / bypass effectiveness |
| Channel symmetry | 0–1 regularity of the differential input channel layout | matched channel behaviour |
| Analog/digital separation | mean gap between analog and digital-categorised parts | digital noise coupling |
| Vias on sensitive nets | count of vias on IN*, CH*, SRB*, BIAS, REF nets | impedance discontinuity / stub pickup on high-impedance inputs |
| Analog input track length | total routed length on sensitive-input nets | antenna length / noise pickup |
Net classification is name-based (e.g. IN1P, AIN3, SRB1, BIAS → sensitive; SCLK, MOSI, DRDY → digital; AVDD, DGND, 3V3 → power). This is a heuristic and will misclassify boards that use unconventional net names.
Scoring
BoardScorer maps the heuristic metrics to a transparent 0–100 score with a per-axis breakdown. Every sub-score exposes the number that produced it and the reason (e.g. "AFE↔radio 18.4 mm (target ≥ 25 mm)"). Sub-score weights are set by the user's optimisation-priority sliders (signal integrity, separation, compactness, routing simplicity, symmetry, manufacturability).
Structural validity is a hard gate: a board that fails deterministic validation has its score multiplied by 0.3, so an invalid layout can never outrank a valid one on aggregate.
The score is a relative comparison instrument, not an absolute quality rating. A score of 82 means "better on these weighted geometric axes than a board that scores 74," nothing more.
Deterministic validation
Before a candidate is scored it passes BoardValidator, a browser-side preflight that catches regressions detectable without KiCad itself:
- balanced parentheses and a
(kicad_pcb …)root - component / net / pad preservation against the original
- duplicate reference designators
- changed footprints, added/removed components
- out-of-bounds placement and bounding-box overlap approximations
This is not DRC/ERC. It cannot check clearances, impedance, or electrical rules. It only rejects proposals that are structurally broken or that mutate more than placement.
Adversarial evaluation (src/redblue/)
A separate, fully deterministic red-team / blue-team layer tests whether the geometric metrics are sensitive enough to notice a deliberate regression. No language model is involved.
- Red injects one plausible physical-design defect into a parsed board and records hidden ground truth. Defect families: extra via on a sensitive net, degraded decoupling loop, radio moved into the analog keep-out, clock routed parallel to an input, differential-pair length imbalance, lengthened sensitive route.
- Blue independently recomputes metrics, detects and localises the regression to a component or net, explains the mechanism via a causal interference graph (aggressor → coupling → victim), attempts a minimal-intervention repair, and re-scores to demonstrate the effect.
- Counterfactual search finds the smallest change (
|ΔPCB|) that improves the score by at least a margin, ranked by improvement per unit change. - Benchmark runs Red against Blue across all applicable defects and reports detection rate, localisation rate, and repair recovery.
Known limitation: the repair "proof" only closes for defects the current BoardScorer actually measures (vias, radio distance). Coupling and small route-length changes are detected and localised but are not yet reflected in the aggregate score, so their repairs cannot be numerically proven by this harness.
Autonomous loop (src/agent/)
An optional closed-loop mode that runs generation → validation → adversarial testing → counterfactual critique → improvement until it converges. All control logic is client-side; the model is called only for the propose and improve steps.
- Objective parsing — natural-language goal → structured config (weights, constraints, robustness threshold, generation budget, convergence delta, batch size) via the model, with schema validation.
- Generation — N candidates per generation, each validated and scored.
- Robustness — top candidates undergo Red/Blue testing; the loop records detection rate and specific vulnerabilities.
- Counterfactual critique — the best candidate's minimal-intervention opportunities are turned into concrete instructions ("move C5 3.2 mm closer to U1 for +4.5 pts") rather than vague feedback.
- Improvement — the model refines the best candidate using that concrete critique.
- Convergence — stops on score plateau (avg Δ over 3 generations below threshold), constraint + robustness satisfaction, or budget exhaustion.
The loop reports total AI calls, candidates generated, wall-clock time, and a rough cost estimate.
Limitations
This section is the point of the tool, not a disclaimer.
- Heuristics are not electrical signoff. Every metric is geometry. None model impedance, current return paths, coupling coefficients, stackup, or noise numerically. A layout that scores well can still be electrically wrong.
- Net classification is name-based and will misread boards with unconventional naming.
- The preview is a legibility aid, not a rendering of the real board. The authoritative artifact is always the KiCad source.
- No DRC/ERC. The browser preflight does not replace KiCad's rule checks.
- The AFE detector is marker-based and targets ADS129x / RHD-class parts; other front-ends may not be recognised.
- Every generated design requires human review and a full KiCad DRC/ERC before fabrication.
Data flow and secrets
- The app runs entirely in the browser. There is no backend, no account, and no server-side storage.
- PCB contents leave the browser only in the request you explicitly send to the AI provider you configured.
- API keys are persisted in browser
localStoragefor convenience (keypcbFork:credentials). They are never logged and never included in any exported artifact. Use Clear credentials in the UI, or clear site data, to remove them. - No CORS bypass. If a provider blocks direct browser access, the app surfaces a clear message rather than attempting to work around it. Providers are pluggable: OpenAI-compatible, Anthropic-compatible, or a custom endpoint behind one
callAI()interface.
Running
npm install
npm run dev # http://localhost:5173 (or next free port)A bundled ADS1299 demo board loads automatically, so parsing, metrics, preview, and scoring are explorable with no API key. Additional real open-hardware boards ship under public/boards/ (VolksEEG, an OpenBCI-style 8-channel AFE, and ADS1299-based designs).
To generate candidates:
- Open AI Connection, pick a provider, set endpoint/model, paste your API key, and test the connection.
- Write an objective (optionally set constraints and priority sliders).
- Generate 1 / 3 / 5 candidates.
- Select a candidate to compare against the original, then Improve to iterate or Download to export.
npm run build # tsc + vite build → docs/ (static, host anywhere)
npm run preview # preview the production buildType-checking must pass clean: npx tsc --noEmit.
Architecture
Everything is client-side. The analysis, scoring, validation, and AI modules are pure and never touch the DOM; AppController is the only module that does.
src/
parser/
sexpr.ts S-expression tokenizer/parser + tree queries
KiCadParser.ts .kicad_pcb → Board (components, nets, tracks, vias, zones, bounds)
placementPatch.ts parse + apply `ref x y [rot]` patches onto original source
analysis/
geometry.ts distance / stats / bbox helpers
BoardAnalyzer.ts semantic categorisation (analog/digital/power/radio/…)
BCIAnalyzer.ts biosignal placement heuristics + derived metrics
scoring/
BoardScorer.ts transparent 0–100 score, slider-weighted
validation/
BoardValidator.ts deterministic browser preflight
ai/
AIProvider.ts provider adapters behind one callAI(); live model listing
PromptBuilder.ts system + user + critique prompt construction
candidates/
CandidateManager.ts patch → parse → analyse → validate → score, keeps history
redblue/
RedTeam.ts defect injectors with hidden ground truth
BlueTeam.ts detect → localise → explain → repair → re-score
CausalGraph.ts aggressor → coupling → victim hypotheses
Counterfactual.ts minimal-intervention (|ΔPCB|) search
Benchmark.ts Red vs Blue harness + summaryThe AI contract
The model must return only the components it wants to move, never a whole board. Echoing a full .kicad_pcb does not scale — a large board exceeds the model's output-token budget and returns truncated (corrupted). The expected response is exactly:
<reasoning_summary>
brief engineering rationale
</reasoning_summary>
<placement>
U1 84.30 62.10 90
C3 78.00 55.50
</placement>Each placement line is ref x y [rot] (absolute mm; rotation optional). A full <kicad_pcb> board is still accepted as a fallback. Candidates that cannot be parsed are rejected; structural failures hard-cap the score.
Stack
Vite · TypeScript · vanilla DOM · SVG. No server, no database, no framework. Geometric heuristics only — no numerical field solver, no DRC engine, no persistence of secrets beyond the localStorage credential entry described above.
Parts
57| Qty | Value | Footprint | References |
|---|---|---|---|
| 11 | 0.01uF | Capacitors_SMD:C_0402 | C9, C18, C19, C20, C21, C22, C28, C29, C30, C31, C32 |
| 10 | 2.2k | Resistors_SMD:R_0402 | R1, R2, R3, R4, R5, R7, R8, R9, R10, R11 |
| 9 | 1uF | Capacitors_SMD:C_0402 | C2, C4, C11, C13, C24, C26, C27, C34, C35 |
| 6 | 0.1uF | Capacitors_SMD:C_0402 | C3, C5, C12, C14, C23, C37 |
| 5 | 10uF | Capacitors_SMD:C_0402 | C1, C7, C10, C17, C33 |
| 4 | 2.2uF | Capacitors_SMD:C_0402 | C6, C8, C15, C16 |
| 3 | TPD4E1B06 | ThinkerHeadset:SC70 | U4, U5, U7 |
| 1 | 100uF | Capacitors_SMD:C_0805 | C36 |
| 1 | 1M | Resistors_SMD:R_0402 | R6 |
| 1 | 1nF | Capacitors_SMD:C_0402 | C25 |
| 1 | ADS1299 | Housings_QFP:TQFP-64_10x10mm_Pitch0.5mm | U6 |
| 1 | CONN_01X10 | Socket_Strips:Socket_Strip_Angled_1x10 | P1 |
| 1 | CONN_01X10 | Socket_Strips:Socket_Strip_Straight_1x10 | P2 |
| 1 | LM2664 | TO_SOT_Packages_SMD:SOT-23-6 | U2 |
| 1 | TLV70025DDC | TO_SOT_Packages_SMD:SOT-23-5 | U3 |
| 1 | TPS72325 | TO_SOT_Packages_SMD:SOT-23-5 | U1 |
Questions
How big is the ThinkerAFE PCB?
It measures 28.1 × 32.6 mm and has 4 copper layers, 1.6 mm thick.
What parts does the ThinkerAFE use?
57 parts, built around the TPD4E1B06DCK, LM2664M6, TLV70025DDCR and TPS72325DBV. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
Where can I download the ThinkerAFE KiCad files?
From the yelabb/pcbfork repository on GitHub, at the commit this page was made from: the board is docs/boards/ThinkerAFE.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.
Can I use the ThinkerAFE design in my own project?
Its repository states no licence, so its author keeps all rights: ask yelabb before reusing the design.
Similar boards
- 4 layers50.8 × 22.9 mm

- 2 layers38.6 × 90.3 mm

BioElectricalSensor
CGrassin/biosignals
Board for the acquisition of bio-potentials (EMG, ECG, EEG, etc.).
107 parts15MIT - 2 layers89.9 × 42.7 mm

Monolith
Monolith-BCI/Trillium-PCB
We're a group of teens working on creating a BCI PCB to start running our own experiments on noise filtering, signal processing speed, and data collection.
89 parts5 - 2 layers66.9 × 41.5 mm

EEG v2.kicad Auto pcb
aaronadamski/brainsolutions-eegboard
EEG Prototype Board for UCI Senior Design
115 parts - 2 layers25.4 × 68.6 mm

- 4 layers100 × 100 mm

- 4 layers61.2 × 61.2 mm

Ganglion 01
OpenBCI/Ganglion_Hardware_Design_Files
General repo for Ganglion hardware files
141 parts91 - 4 layers69.8 × 69.8 mm

FreeEEG32
neuroidss/FreeEEG32-alpha1.0
ALPHA1.0 TEST FAILED, USE NEW VERSION INSTEAD FreeEEG32 alpha1.0 32 channels mobile electroencephalography under GNU AGPL 24 bits, 4kSPS ADCs 4x AD7770 MCU STM32F427ZI WIFI ESP-12F (ESP8266) USB CP2102N Accel & hyro…
217 parts39AGPL-3.0