Skip to main content

Generate WireViz YAML files and manufacturing documentation from SQLite electrical design databases

Project description

WireViz YAML Generator

License: MIT Python 3.13+

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 dot is in PATH
    • macOS: brew install graphviz
    • Linux: sudo apt-get install graphviz

Installation

  1. Clone the repository:
git clone https://github.com/OleJBondahl/wireviz_yaml_generator.git
cd wireviz_yaml_generator
  1. Install dependencies (using uv):
uv sync

Or install manually with pip:

pip install wireviz pyyaml pandas openpyxl
  1. 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:

  1. โœ… Connect to your database (master.db)
  2. ๐Ÿ“ Generate BOM and labels in attachments/
  3. ๐Ÿ“„ Generate YAML files in output/
  4. ๐Ÿ–ผ๏ธ 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

Example Wiring 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.py is pure functions (no I/O)
  • Imperative Shell: I/O, subprocess calls, error handling in main.py
  • Repository Pattern: data_access.py isolates SQL from business logic
  • Dependency Injection: WorkflowManager receives DataSource via 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 functions
  • tests/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:

  1. Code Style: Follow existing patterns (functional core, immutable data)
  2. Documentation: Update pydoc docstrings for all functions/classes
  3. Testing: Add unit tests for new functionality
  4. 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

  • WireViz - The excellent diagram generation tool
  • uv - Fast Python package and project manager

๐Ÿ“ฌ Contact

Ole Johan Bondahl


๐Ÿ—บ๏ธ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wireviz_yaml_generator-0.1.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wireviz_yaml_generator-0.1.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

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

Hashes for wireviz_yaml_generator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7b791885b7a59f4470499cb09ffa70be9b5777e813a7794ffe7a5f434397124
MD5 744f6c72890178aa5cc3f8de4e3ef2f8
BLAKE2b-256 afe1897a119afc43acd5129aefa935f0c01a3d49378756b51a425bc8d4f3daba

See more details on using hashes here.

File details

Details for the file wireviz_yaml_generator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wireviz_yaml_generator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e50e855580a790d86c525a16fdc9068f89bebc4cb34b8fa0372b4f3e9ee1584a
MD5 7246d51c9b2d96ac453f43fa59cd59fb
BLAKE2b-256 6a64e306f10250825640898dd1f1d50ecb08d7f2f911a21297830bf821f4c753

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page