Skip to content

Commit fde8218

Browse files
committed
feat: initial scaffold with datasheet extractor, QFN/QFP, SKiDL, KiCad integration and custom license
0 parents  commit fde8218

22 files changed

Lines changed: 975 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.11'
16+
- name: Install
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install -e .[test]
20+
- name: Run tests
21+
run: |
22+
pytest -q

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Python
2+
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
*.egg-info/
7+
.venv/
8+
.env
9+
10+
# Build
11+
build/
12+
dist/
13+
14+
# IDE
15+
.vscode/
16+
.idea/
17+
18+
# Tests
19+
.pytest_cache/
20+
.cache/

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Custom Non-Commercial License with Enterprise Authorization Requirement
2+
3+
Copyright (c) 2025, PCB Designer AI Agent Authors
4+
All rights reserved.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, publish, and distribute the Software for non-commercial purposes, subject to the following conditions:
7+
8+
1) Non-Commercial Use Only: The Software may be used solely for personal, educational, research, or non-profit purposes. Any use of the Software by a company, enterprise, organization, or for any commercial purpose requires prior written authorization from the copyright holder.
9+
10+
2) Attribution: You must retain the above copyright notice and this permission notice in all copies or substantial portions of the Software.
11+
12+
3) Notice of Modifications: If you modify the Software, you must include a prominent notice stating that you have changed the files.
13+
14+
4) No Warranty: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15+
16+
5) Enterprise/Commercial Authorization: Companies, enterprises, or any for-profit entities wishing to use the Software must obtain prior written authorization from the copyright holder. To request authorization, contact: YOUR_EMAIL_HERE. Terms may include licensing fees or additional conditions.
17+
18+
6) Contributions: By submitting a contribution to this project, you agree that your contribution is provided under the same terms as this license unless you explicitly state otherwise in the contribution.
19+
20+
7) Trademarks: This license does not grant permission to use the trade names, trademarks, service marks, or product names of the copyright holder, except as required for reasonable and customary use in describing the origin of the Software and reproducing the content of this notice.
21+
22+
END OF TERMS

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# PCB Designer AI Agent
2+
3+
An open-source agentic pipeline that turns a natural-language hardware description into a manufacturable PCB. The system automates:
4+
5+
1) Requirement → Component selection (BOM)
6+
2) Datasheet retrieval → Footprint extraction → Footprint generation (.kicad_mod)
7+
3) Schematic synthesis (netlist) from component reference designs and constraints
8+
4) PCB placement and routing (via KiCad + Freerouting or vendor tools adapters)
9+
5) Gerber generation via EDA tool backends (KiCad first-class; adapters for Altium/Cadence planned)
10+
11+
Status: early scaffold. Includes a working, parametric KiCad footprint generator for common packages and an extensible pipeline with clear interfaces for each step.
12+
13+
## Why
14+
- Speed up concept-to-board by automating tedious steps.
15+
- Keep humans-in-the-loop for safety while leveraging LLMs/CV for datasheet understanding.
16+
- Vendor-neutral core with adapters for popular EDA tools.
17+
18+
## Architecture
19+
- Core config + logging
20+
- Pluggable LLM providers (OpenAI/Ollama/etc.)
21+
- Steps:
22+
- requirements_parser → bom_generator → datasheet_fetcher → footprint_generator → schematic_synthesizer → pcb_router → gerber_exporter
23+
- Backends:
24+
- KiCad backend (first-class, CLI-friendly)
25+
- Adapters for Altium (COM/Script/PDN) and Cadence Allegro (SKILL/CLI) planned
26+
27+
```text
28+
pcb-designer-ai-agent/
29+
├─ README.md
30+
├─ LICENSE
31+
├─ pyproject.toml
32+
├─ .gitignore
33+
├─ src/pcbai/
34+
│ ├─ __init__.py
35+
│ ├─ core/
36+
│ │ ├─ config.py
37+
│ │ └─ logger.py
38+
│ ├─ llm/
39+
│ │ ├─ provider.py
40+
│ │ └─ providers/
41+
│ ├─ steps/
42+
│ │ ├─ requirements_parser.py
43+
│ │ ├─ bom_generator.py
44+
│ │ ├─ datasheet_fetcher.py
45+
│ │ ├─ footprint_generator.py <-- working generator for SMD R/C and SOIC
46+
│ │ ├─ schematic_synthesizer.py
47+
│ │ ├─ pcb_router.py
48+
│ │ └─ gerber_exporter.py
49+
│ └─ pipeline/
50+
│ └─ cli.py
51+
└─ tests/
52+
└─ test_footprint_generator.py
53+
```
54+
55+
## Quickstart
56+
- Python 3.10+
57+
- KiCad 7/8 recommended for future steps (not required to try the footprint generator)
58+
59+
Install:
60+
61+
```bash
62+
pip install -e .
63+
```
64+
65+
Generate a 0603 resistor footprint:
66+
67+
```bash
68+
pcbai footprint --type smd_rc --name R_0603 --body-l 1.6 --body-w 0.8 --pad-l 0.9 --pad-w 0.8 --gap 0.8 --out build/
69+
```
70+
71+
Generate a 14-pin SOIC footprint:
72+
73+
```bash
74+
pcbai footprint --type soic --name SOIC-14_3.9x8.7mm_P1.27mm \
75+
--pins 14 --pitch 1.27 --body-l 8.7 --body-w 3.9 --pad-l 1.5 --pad-w 0.6 --row-offset 2.3 --out build/
76+
```
77+
78+
You will find `.kicad_mod` files in `build/` to drop into a KiCad library.
79+
80+
## Vision + Datasheet extraction
81+
- Planned: PDF/image → text/structured extraction using OCR + LLM-Vision to infer package params when IPC tables are present.
82+
- Today: you can provide measured params directly to the generator.
83+
84+
## Schematic/Netlist synthesis
85+
- Planned: SKiDL-based netlist generation from component set + reference circuits.
86+
87+
## PCB routing and Gerbers
88+
- Planned: KiCad pcbnew and Freerouting integration; `kicad-cli` for Gerbers.
89+
- Adapters for Altium/Cadence will require respective licensed tool installations and API keys.
90+
91+
## Configuration
92+
- All runtime config via environment variables or a YAML file, see `src/pcbai/core/config.py`.
93+
94+
## Contributing
95+
- PRs welcome. Focus areas:
96+
- Datasheet parsers and CV feature extractors
97+
- More package generators (QFN/QFP/BGA)
98+
- SKiDL schematic templates
99+
- EDA tool adapters
100+
101+
## License
102+
Dual-licensed:
103+
- Non-commercial, open-source use granted under the Custom License in LICENSE.
104+
- Commercial/enterprise use requires prior written authorization from the author. Contact: set your email in LICENSE.

pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pcb-designer-ai-agent"
7+
version = "0.0.1"
8+
description = "Agentic pipeline from natural language to PCB (BOM → footprints → schematic → routing → Gerbers)"
9+
authors = [{ name = "PCB Designer AI Agent Contributors" }]
10+
readme = "README.md"
11+
requires-python = ">=3.10"
12+
license = { file = "LICENSE" }
13+
dependencies = [
14+
"pydantic>=2.6",
15+
"click>=8.1",
16+
"requests>=2.31",
17+
"python-dotenv>=1.0",
18+
]
19+
20+
[project.optional-dependencies]
21+
llm = ["openai>=1.0", "tiktoken>=0.6"]
22+
vision = [
23+
"pillow>=10.3",
24+
"pytesseract>=0.3.10",
25+
"pdfminer.six>=20221105",
26+
"camelot-py[cv]>=0.11.0",
27+
"opencv-python-headless>=4.8",
28+
"pypdf>=4.2"
29+
]
30+
eda = [
31+
"skidl>=0.1.0",
32+
]
33+
ki = [
34+
# KiCad's pcbnew is provided by KiCad; no pip package. This is a placeholder group.
35+
]
36+
37+
test = ["pytest>=8.2"]
38+
39+
[project.scripts]
40+
pcbai = "pcbai.pipeline.cli:main"
41+
42+
[tool.pytest.ini_options]
43+
pythonpath = ["src"]

src/pcbai/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__all__ = ["__version__"]
2+
__version__ = "0.0.1"

src/pcbai/core/config.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from __future__ import annotations
2+
3+
import os
4+
from dataclasses import dataclass
5+
from typing import Optional
6+
7+
8+
@dataclass
9+
class Settings:
10+
# General
11+
log_level: str = os.getenv("PCB_AI_LOG", "INFO")
12+
13+
# LLM
14+
llm_provider: str = os.getenv("PCB_AI_LLM_PROVIDER", "openai")
15+
openai_api_key: Optional[str] = os.getenv("OPENAI_API_KEY")
16+
ollama_host: str = os.getenv("OLLAMA_HOST", "http://localhost:11434")
17+
18+
# Paths
19+
workdir: str = os.getenv("PCB_AI_WORKDIR", os.path.abspath("build"))
20+
21+
# EDA tool backends
22+
kicad_cli: str = os.getenv("KICAD_CLI", "kicad-cli")
23+
altium_api_key: Optional[str] = os.getenv("ALTIUM_API_KEY")
24+
cadence_api_key: Optional[str] = os.getenv("CADENCE_API_KEY")
25+
26+
27+
settings = Settings()

src/pcbai/core/logger.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import logging
2+
import sys
3+
4+
5+
def get_logger(name: str = "pcbai", level: int = logging.INFO) -> logging.Logger:
6+
logger = logging.getLogger(name)
7+
if logger.handlers:
8+
return logger
9+
logger.setLevel(level)
10+
11+
handler = logging.StreamHandler(sys.stdout)
12+
fmt = logging.Formatter(
13+
fmt="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
14+
datefmt="%H:%M:%S",
15+
)
16+
handler.setFormatter(fmt)
17+
logger.addHandler(handler)
18+
logger.propagate = False
19+
return logger

src/pcbai/llm/provider.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import annotations
2+
3+
from abc import ABC, abstractmethod
4+
from typing import Dict, Any
5+
6+
7+
class LLMProvider(ABC):
8+
@abstractmethod
9+
def complete(self, prompt: str, **kwargs) -> str:
10+
...
11+
12+
13+
class DummyProvider(LLMProvider):
14+
def complete(self, prompt: str, **kwargs) -> str:
15+
return "TODO: implement real provider or configure via env"

0 commit comments

Comments
 (0)