blockbom
A Python library to generate hierarchical Bills of Materials (BOMs) from Mermaid flowchart diagrams.
Installation
# Using uv
uv add blockbom
# Using pip
pip install blockbom
Quick Start
from blockbom import generate_bom
# Generate a BOM from a Mermaid diagram
items = generate_bom("diagram.mmd", "output.csv")
# With part metadata
items = generate_bom("diagram.mmd", "output.csv", "parts.yaml")
Usage
Input: Mermaid Flowchart
Create a Mermaid flowchart file (.mmd):
flowchart LR
subgraph enclosure["Main Enclosure"]
A["Power Supply"]
B["Controller"]
C["Sensor"]
end
A --> B
B --> C
C --> D["External Display"]
Optional: Part Metadata
Create a YAML file to enrich your BOM with part numbers, links, and costs:
# parts.yaml
A:
part_number: "PS-12V-5A"
link: "https://example.com/power-supply"
cost: 25.99
B:
part_number: "MCU-ARM-01"
link: "https://example.com/controller"
cost: 15.00
Output: CSV BOM
Level,Qty,Description,Part Number,Purchase Link,Cost
0,1,Main Enclosure,,,
1,1,Power Supply,PS-12V-5A,https://example.com/power-supply,25.99
1,1,Controller,MCU-ARM-01,https://example.com/controller,15.00
1,1,Sensor,,,
0,1,External Display,,,
The Level column indicates hierarchy:
- Level 0: Top-level assemblies or standalone components
- Level 1+: Components nested within subgraphs
API Reference
generate_bom(mermaid_file, output_file, metadata_file=None)
Generate a BOM CSV from a Mermaid flowchart.
Parameters:
mermaid_file: Path to the.mmdfileoutput_file: Path for the output CSVmetadata_file: Optional path to.yamlmetadata file
Returns: List of BOMItem objects
parse_mermaid(content)
Parse Mermaid flowchart content into a structured format.
from blockbom import parse_mermaid
diagram = parse_mermaid('''
flowchart LR
A["Component 1"] --> B["Component 2"]
''')
for node_id, node in diagram.nodes.items():
print(f"{node_id}: {node.label}")
Returns: ParsedDiagram with nodes, edges, subgraphs, and root_node_ids
Supported Mermaid Syntax
- Diagram types:
flowchartandgraph(TD, LR, TB, BT, RL) - Node shapes:
[],(),{},(()),[[]],[()],{{}}, and@{}extended syntax - Edges:
-->,-- label -->,-->|label| - Multiple targets:
A --> B & C & D - Subgraphs:
subgraph id["Title"] ... end - YAML frontmatter (stripped automatically)
Development
# Clone and install
git clone https://github.com/keen/blockbom.git
cd blockbom
uv sync --dev
# Run tests
uv run pytest -v
# Type checking
uv run mypy src/blockbom
# Linting
uv run ruff check src/blockbom
License
MIT
Metadata
Release files for blockbom 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blockbom-0.1.0.tar.gz | 46.0 kB | Without provenance | Details for blockbom-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blockbom-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for blockbom-0.1.0-py3-none-any.whl |
Total release size: 58.1 kB
Release files / blockbom-0.1.0.tar.gz
| Download URL | blockbom-0.1.0.tar.gz |
|---|---|
| Size | 46.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4be9f1f9761f8846608bd72204cd9c304318213918f1c8c5ce5036dec5c88cd
|
|
BLAKE2b-256 checksum How to use checksums |
30e6631c658fb44b009e88c9d5ffeff8d5800064d5cf0f4a0fac07f692bcd58f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / blockbom-0.1.0-py3-none-any.whl
| Download URL | blockbom-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c18391b195a6a369a68f16401104534bffbb69fd904488f645d78396f23d3177
|
|
BLAKE2b-256 checksum How to use checksums |
803ac6d100129676113eb39ad26336b3763e65df1ae7fca6ba81fe2f2668966b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for blockbom 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.