Generate WireViz YAML files and manufacturing documentation from SQLite electrical design databases
Project description
WireViz YAML Generator
Transform electrical design databases into professional wiring diagrams automatically.
An automated pipeline tool that transforms electrical design data from SQLite databases into professional wiring diagrams using WireViz, complete with manufacturing documentation (BOMs, cable labels).
๐ Full Documentation | ๐ธ Examples
โจ Features
- ๐๏ธ Database Integration: Reads directly from SQLite (
master.db) with well-defined schema - ๐ง Intelligent Transformation:
- Aggregates individual wires into cable bundles
- Resolves point-to-point connections with via-pin assignments
- Enriches connectors with metadata (MPNs, images, pinouts)
- ๐ Documentation Generation:
- Wiring Diagrams: Visual harness diagrams (PNG/SVG)
- Bill of Materials: Excel-based BOMs with consolidated quantities
- Label Lists: Cable cut-lists and wire end-labels for manufacturing
- ๐๏ธ Clean Architecture: Pure functional core with imperative shell, dependency injection
- โ Tested: Comprehensive unit test coverage for transformations
๐ Quick Start
Prerequisites
- Python 3.13+
- GraphViz (required by WireViz)
- Windows: Download and install MSI, ensure
dotis in PATH - macOS:
brew install graphviz - Linux:
sudo apt-get install graphviz
- Windows: Download and install MSI, ensure
Installation
- Clone the repository:
git clone https://github.com/OleJBondahl/wireviz_yaml_generator.git
cd wireviz_yaml_generator
- Install dependencies (using
uv):
uv sync
Or install manually with pip:
pip install wireviz pyyaml pandas openpyxl
- Configure paths in
config.toml:
base_repo_path = "/path/to/your/project"
db_path = "data/master.db"
output_path = "output/"
drawings_path = "drawings/"
attachments_path = "attachments/"
Run
python src/main.py
The tool will:
- โ
Connect to your database (
master.db) - ๐ Generate BOM and labels in
attachments/ - ๐ Generate YAML files in
output/ - ๐ผ๏ธ Generate diagrams in
drawings/(requires WireViz)
๐ Example Usage
Input: Database
Your SQLite database defines connections between components:
-- NetTable: Point-to-point connections
INSERT INTO NetTable (cable_des, comp_des_1, conn_des_1, pin_1,
comp_des_2, conn_des_2, pin_2, net_name) VALUES
('W001', 'JB1', '', 'J1', 'BMU1', '', 'J3', 'SignalA'),
('W001', 'JB1', '', 'J2', 'BMU1', '', 'J6', '+24V');
See examples/DATABASE_SCHEMA.md for complete schema documentation.
Output: YAML
connectors:
JB1:
pins: [J1,J2,J3]
show_pincount: false
BMU1:
pins: [J3,J6,J11]
show_pincount: false
cables:
W001:
wirecount: 2
wirelabels: [SignalA, +24V]
connections:
- [JB1: J1, W001: 1, BMU1: J3]
- [JB1: J2, W001: 2, BMU1: J6]
Output: Visual Diagram
See examples/ for complete output samples including SVG, HTML, and BOM files.
โ๏ธ Configuration
Edit config.toml in the project root:
| Parameter | Description | Example |
|---|---|---|
base_repo_path |
Parent directory for relative paths | "C:/Projects/Electrical" |
db_path |
Relative path to SQLite database | "data/master.db" |
output_path |
Where to save generated YAML files | "output/" |
drawings_path |
Where WireViz saves diagram images | "drawings/" |
attachments_path |
Where to save BOM/Labels | "attachments/" |
Workflow Configuration
Edit constants in src/main.py to control what gets generated:
CREATE_BOM = True # Generate Bill of Materials
CREATE_LABELS = True # Generate cable/wire labels
CREATE_DRAWINGS = True # Generate diagram images
FROM_CABLE_NR = 0 # Start of cable range
TO_CABLE_NR = 50 # End of cable range
DONT_INCLUDE_FILTER = [] # Cables to skip (list of numbers)
๐๏ธ Architecture
This project follows Clean Architecture principles:
โโโโโโโโโโโโโโโ
โ main.py โ Entry Point (Imperative Shell)
โ (I/O Boundary)
โโโโโโโโฌโโโโโโโ
โ
โโโบworkflow_manager.py (Orchestration)
โ โ
โ โโโบdata_access.py (Repository Pattern)
โ โ โ
โ โ โโโบSQLite Database
โ โ
โ โโโบtransformations.py (Pure Functions)
โ โ โ
โ โ โโโบmodels.py (Domain Objects)
โ โ
โ โโโบOutput Layer
โ โโโบBuildYaml.py (YAML Writer)
โ โโโบexcel_writer.py (Excel Writer)
โ
โโโบWireViz CLI (External Tool)
Key Principles
- Pure Core: Business logic in
transformations.pyis pure functions (no I/O) - Imperative Shell: I/O, subprocess calls, error handling in
main.py - Repository Pattern:
data_access.pyisolates SQL from business logic - Dependency Injection:
WorkflowManagerreceivesDataSourcevia constructor - Data-Oriented: Immutable domain models (
@dataclass(frozen=True))
See docs/ for detailed architecture diagrams.
๐งช Testing
Run the test suite:
pytest tests/ -v
Run with coverage report:
pytest tests/ --cov=src --cov-report=term
Test Structure
tests/test_buildyaml.py: Tests YAML conversion functionstests/test_transformations.py: Tests core business logic transformations
All tests focus on pure function testing without database dependencies.
๐ Project Structure
wireviz_yaml_generator/
โโโ src/ # Source code
โ โโโ main.py # Entry point
โ โโโ models.py # Domain models (immutable dataclasses)
โ โโโ transformations.py # Pure transformation functions
โ โโโ workflow_manager.py # Orchestration
โ โโโ data_access.py # Database repository
โ โโโ BuildYaml.py # YAML output layer
โ โโโ excel_writer.py # Excel output layer
โ โโโ ReadConfig.py # Configuration loader
โ โโโ exceptions.py # Custom exceptions
โโโ tests/ # Unit tests
โโโ docs/ # Architecture documentation
โโโ examples/ # Example outputs and schema
โ โโโ README.md
โ โโโ DATABASE_SCHEMA.md
โ โโโ output_sample.* # Sample outputs (YAML, PNG, SVG, etc.)
โโโ config.toml # Configuration file
โโโ pyproject.toml # Project metadata
โโโ README.md # This file
๐ค Contributing
Contributions are welcome! Please follow these guidelines:
- Code Style: Follow existing patterns (functional core, immutable data)
- Documentation: Update pydoc docstrings for all functions/classes
- Testing: Add unit tests for new functionality
- Architecture: Respect the clean architecture boundaries
Development Setup
# Install development dependencies
uv sync --dev
# Run tests
pytest tests/ -v
# Check code complexity
complexipy src/
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
๐ฌ Contact
Ole Johan Bondahl
- GitHub: @OleJBondahl
๐บ๏ธ Roadmap
- Add support for multi-sheet Excel BOMs
- Implement database validation checks
- Add interactive CLI with progress bars
- Support for custom connector images per-project
- Web UI for database editing
โญ If you find this tool helpful, please star the repository!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wireviz_yaml_generator-0.1.0.tar.gz.
File metadata
- Download URL: wireviz_yaml_generator-0.1.0.tar.gz
- Upload date:
- Size: 30.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7b791885b7a59f4470499cb09ffa70be9b5777e813a7794ffe7a5f434397124
|
|
| MD5 |
744f6c72890178aa5cc3f8de4e3ef2f8
|
|
| BLAKE2b-256 |
afe1897a119afc43acd5129aefa935f0c01a3d49378756b51a425bc8d4f3daba
|
File details
Details for the file wireviz_yaml_generator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wireviz_yaml_generator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e50e855580a790d86c525a16fdc9068f89bebc4cb34b8fa0372b4f3e9ee1584a
|
|
| MD5 |
7246d51c9b2d96ac453f43fa59cd59fb
|
|
| BLAKE2b-256 |
6a64e306f10250825640898dd1f1d50ecb08d7f2f911a21297830bf821f4c753
|