Architecture Overview¶
This page gives a high-level map of how Filare fits together. For visual cheatsheets, see the Mermaid diagrams in docs/graphs/architecture.md, docs/graphs/data_flow.md, and docs/graphs/models.md.
Main entry points¶
- CLI:
src/filare/cli.py(exposed asfilareviauv run --no-sync filare ...). - Example/tutorial builder:
src/filare/tools/build_examples.pydrives the CLI over the example and tutorial sets.
Visual map¶
flowchart TD
subgraph Models
A1[models: metadata/options]
A2[models: connector/cable/component]
A3[models: bom/types]
A4[models: document representation]
end
subgraph Parser
P1[yaml_loader]
P2[harness_parser]
end
subgraph Flows
F1[build_harness]
F2[render_outputs]
F3[shared_bom]
F4[index_pages]
F5[document representation yaml]
end
subgraph Render
R1[graphviz]
R2["output (HTML/PDF/assets)"]
R3[templates/html_utils]
end
subgraph CLI
C1[cli]
end
Parser --> Flows
Models --> Flows
Flows --> F5
F5 --> Render
Render --> Outputs["SVG, HTML, TSV, PDF"]
CLI --> Parser
CLI --> Flows
CLI --> F5
End-to-end flow¶
- Input ingestion
YAML harness files (plus optional metadata) are loaded and merged via
parser/yaml_loader.pyand parsed into Python structures byparser/harness_parser.py. - Model construction
flows/build_harness.pyturns parsed data into the core models infilare.models(Harness,Connector,Cable,Component, BOM entries, page options, metadata). - Rendering
flows/render_outputs.pyhands the assembledHarnessto renderers: - Graph output:
render/graphviz.pybuilds DOT nodes/edges (including node images) and invokes GraphViz for SVG/PNG. - Tabular/text output:
render/output.pywrites BOM/TSV and HTML wrappers;render/templates.pyprovides the Jinja templates and HTML helpers. - Document representation
flows/build_harness.pynow emits a pre-renderDocumentRepresentation(YAML) capturing metadata, page stubs, notes, and BOM (if enabled). Hash tracking prevents overwriting user-edited documents. - Aggregate artifacts
flows/shared_bom.pyemits a combinedshared_bom.tsv.flows/index_pages.pybuilds title pages and PDF bundles.- Outputs SVG/PNG diagrams, HTML pages (diagram + title block), TSV BOMs, shared BOM, and optional PDF bundles end up under the requested output directory.
Extending/operating¶
- Update metadata/templates: tweak the per-folder metadata files (e.g.,
examples/basic/metadata.yml) or the templates undersrc/filare/templates/. - Add formats or post-processing: extend
render/output.pyand, if needed,flows/render_outputs.py. - Batch generation: call
uv run --no-sync python src/filare/tools/build_examples.py(uses the same pipeline as the CLI). - Build document YAML only (no render):
uv run --no-sync filare examples/basic/basic01.yml -d examples/basic/metadata.yml -f "" -o outputs(document YAML and hashes are emitted alongside outputs). - Force a document YAML refresh: remove
*.document.yamlanddocument_hashes.yamlbefore rerun, or edit the YAML to keep your changes (hash guard prevents overwrite). - Page types: see
docs/pages.mdfor the list of page types (title, harness, bom, cut, termination) and their roles; enable cut/termination viaoptions.include_cut_diagram/options.include_termination_diagram.
Document representation and hash guard¶
Filare writes a pre-render document snapshot (<output_name>.document.yaml) before producing SVG/HTML/TSV assets. It captures:
metadata: merged metadata for the harnesspages: page definitions (title/harness/bom/cut/termination) with names and format hintsnotesandextras: freeform blocks carried into the final renderbom: tabular data if BOM generation is enabled
A registry file document_hashes.yaml sits next to the outputs and tracks SHA-256 hashes of each generated document along with an allow_override flag:
demo01.document.yaml:
hash: 123abc...
allow_override: true
Workflow:
- On each run, Filare computes a hash of the generated document representation.
- If
allow_overrideisfalseand the stored hash differs, Filare warns and keeps the existing*.document.yaml(assumes manual edits). - If
allow_overrideistrue(default) or the file is new, Filare overwrites the document YAML and updates the hash registry.
To freeze a document after manual edits, set allow_override: false for that entry in document_hashes.yaml. Delete the entry (or the entire file) to allow regeneration.