FiberCAD Architecture Evolution Report

From prior art through concept to working MVP — April 17, 2026

1. Executive Summary

FiberCAD builds on lessons from a prior CAD patch pipeline (mattganzak/cad, 22,700 LOC) that took a fundamentally different approach — editing existing drawings rather than generating new designs. FiberCAD then started as a vision for a full cloud-native GIS platform, evolved through four major architectural pivots driven by timeline constraints, domain expertise extraction, and rigorous architecture review. The result is a focused design generator that complements the prior patch system and outperforms the original scope on every dimension that matters to the customer.

1
Prior system analyzed
4
Major architecture pivots
9
Critical rules discovered from videos
393
Tests passing
12,668
Lines of code

2. Prior Art: The CAD Patch Pipeline (mattganzak/cad)

Before FiberCAD, a separate system was built to automate fiber design work. This system (mattganzak/cad, 22,700 LOC across 3 modules) took a fundamentally different approach: patching existing drawings rather than generating new designs from scratch.

Architecture

Existing DWG ──► C# AutoCAD Plugin ──► JSON Snapshot ──► LLM (DeepSeek)
                  (EXPORTDWGFULLJSON)                      │
                                                     Design Understanding
                                                     Edit Brief
                                                     Patch JSON
                                                           │
                                                     ◄─────┘
Validated Patch ──► C# Plugin ──► Updated DWG ──► Integrity Check
                   (APPLYJSONPATCH)

What It Did

PhaseActionOutput
Phase 1Create working DWG from template + polygonoriginal/working.dwg
Phase 2Export full CAD snapshot via C# plugindesign_snapshot.json
Phase 3Build protection baseline (buildings, parcels, roads locked)protected_geometry_baseline.json
Phase 5LLM generates understanding → brief → patch JSONdesign_patch.json
Phase 4Validate patch ops against protection rulespatch_validation.json
Phase 6Apply patch to DWG, re-export, verify integrityupdated.dwg

Three Modules

ModuleLOCPurpose
cad_automation/~8,000Core pipeline: run.py, phase5_iterate.py, phase6_apply.py, LLM prompts, protection baseline, QA loop
backend/~6,000FastAPI web server: auth (JWT), Celery task queue, PostgreSQL, Docker compose, job submission API
demo/~5,000Prototyping: Ollama experiments, routing MVP, client rules registry, JSON design format exploration
frontend/skeletonReact/Next.js (not implemented)

Strengths of This Approach

Limitations Identified

LimitationImpact
Requires Windows + AutoCAD at runtimeCannot run on Linux/Mac, cannot run in CI, cannot demo without AutoCAD license
LLM is the core intelligenceDeepSeek generates patches; when it hallucinates targets or drifts off-domain, the system falls back to constrained recovery. Direct patch generation "not consistently strong enough yet"
Patch scale limitedBest proven output: 4-edit review bundle. "Current client-style output is still much smaller than a real large production patch set"
No network planningCannot generate boundary groups, splitter placement, conduit routing, or BOM. Assumes someone already designed the network.
No design validationNo rules engine checking conduit length, drop count, splitter separation. Validates patch ops, not design correctness.
No GIS data acquisitionCannot fetch building footprints, roads, or addresses from OSM. Relies on pre-existing DWG content.
Key insight: The prior system is a drawing editor — it takes a partially complete drawing and adds corrections. FiberCAD is a design generator — it creates the entire network plan from raw address data. These are complementary, not competing systems. FiberCAD generates the initial DXF design; the patch pipeline could then refine it with client-specific annotations inside AutoCAD.

What FiberCAD Adopted

What FiberCAD Changed

3. The Original Vision: Full Cloud-Native GIS Platform

The project started with a research phase: codebase review (14 AutoLISP scripts, Lumos V6 standards, Hampton Heights project files, 2.1GB training videos) and competitive analysis (3-GIS, VETRO FiberMap, IQGeo/Comsof, FibPlanner, OSPInsight). The initial architecture was designed as a full-scale 3-GIS replacement:

Original Architecture (Day 1 Proposal)

                     WEB CLIENT
  Map Canvas (MapLibre GL) + Design Canvas (Fabric.js)
  Real-time collaboration (WebSocket)
                        |
                    API LAYER
  REST + WebSocket + File I/O (DWG/PDF/GeoJSON)
     |       |       |       |       |       |
  GIS     Graph    Rule    Doc     LLM    Equipment
  Engine  Engine   Engine  Gen    Agent   Catalog
                        |
                   PostGIS DB
                 (Spatial + Network)

What This Entailed

LayerTechnologyScope
FrontendReact + MapLibre GL JS + Fabric.js/KonvaMap canvas + CAD-like drawing surface
BackendPython (FastAPI) or GoREST API + WebSocket server
DatabasePostgreSQL + PostGISSpatial queries, network topology storage
LLMClaude API (Anthropic)Design agent, QC review, documentation
File I/OOpen Design Alliance SDKDWG read/write (requires ODA licensing)
Real-timeWebSocket (Socket.io)Multi-user collaborative editing
HostingAWS/GCP with containersManaged PostGIS, compute for LLM pipelines
MobileReact Native or PWAField crew markup and as-built updates

The build sequence was planned across 5 phases over several months:

Problem: This was a 6-12 month engineering effort requiring a team. The customer needed to see working output in 3 days for continued funding. A login screen and empty map canvas would not secure the next milestone.

What Was Right About It

What Was Wrong About It

4. Pivot 1: Cloud Platform to Python CLI Engine

With the 3-day deadline established, the cloud platform was scoped down to a Python CLI engine (Approach C from brainstorming: engine + DXF output + HTML map report). This was the first working Python architecture:

First Python Architecture (Pre-Review)

fibercad/
├── cli.py                    # argparse entry point
├── ingest/
│   ├── osm.py                # Overpass API fetch
│   ├── geocode.py            # Nominatim geocoding
│   └── importers.py          # CSV/GeoJSON loaders
├── model/
│   ├── network.py            # Road graph + Dijkstra
│   ├── elements.py           # Equipment dataclasses
│   ├── geometry.py           # haversine, snap, centroid
│   └── schema.py             # Single FiberJSON schema
├── planning/
│   ├── boundary_groups.py    # Clustering algorithm
│   ├── splitter_placement.py # 1x8/1x4 placement
│   ├── routing.py            # Conduit routing
│   └── optimizer.py          # Cost optimization
├── rules/
│   ├── engine.py             # Rule checker
│   └── profiles/lumos_v6.py  # 12 rules from standards doc
├── output/
│   ├── fiberjson.py          # JSON serializer (SHA-256 only)
│   ├── dxf.py                # DXF with primitive shapes
│   ├── report_html.py        # Simple Leaflet map
│   └── workbook.py           # BOM Excel
└── llm/
    ├── client.py             # Claude API client
    └── design_review.py      # LLM sends/receives raw data

What This Version Had

What This Version Was Missing

GapRisk
No microkernel / plugin dispatchModules tightly coupled, hard to extend
No security moduleOSM input unsanitized, prompt injection possible
No integrity chainNo tamper detection, no audit trail
No rate limiterNominatim bans at >1 req/sec
No checkpoint/resume10K-address geocoding crashes = restart from zero
No baremetal toolsLLM processes raw geometry (slow, unreliable, expensive)
No planning orchestration layerCLI directly calls algorithms (no separation of concerns)
No sanity checksDegenerate outputs (zero-address groups, disconnected roads) go undetected
No standalone verifierThird-party can't audit without installing FiberCAD
Only 12 rulesMissing 9 critical rules that lived in tribal knowledge (videos)
Generic DXF shapesOutput doesn't match what designers expect in AutoCAD
This version would have worked for a demo but would have failed in production. No security, no resilience, no integrity verification, and missing rules that produce invalid designs (1x4/1x8 in same handhole, wrong handhole sizing, no 650ft hard limit).

Two things then happened that transformed this into the final architecture:

  1. Architecture review against Rapsody patterns — identified 21 specific gaps across consistency, reliability, security, performance, and transparency (Section 7)
  2. Video corpus analysis — 5 training videos transcribed, revealing 9 critical rules not in any written standard (Section 6)

5. Pivot 2: First Python to Production Architecture

The architecture review (informed by the Rapsody sister project's microkernel patterns) restructured the codebase from a flat script collection into a layered, production-grade engine.

First Python (Flat)

  • 5 packages, ~20 files
  • No kernel abstraction
  • Direct module coupling
  • 12 rules, no video knowledge
  • Monolithic JSON, SHA-256 only
  • Primitive DXF shapes
  • LLM processes raw data
  • No error enrichment

Production Architecture

  • 8 packages, 60+ files, 393 tests
  • Microkernel with plugin dispatch chain
  • HttpBackend protocol, dependency injection
  • 18 rules (15 implemented) from standards + videos
  • 5 layered files, Ed25519 signed, provenance chain
  • 33 real Lumos blocks, 81 layers, 23 text styles
  • 7 MCP tools, LLM calls tools only
  • Contextual error guidance without AI

What Was Added

ComponentPurposePattern Source
kernel/plugin.pyDispatch chain (Handled/NotHandled)Chain of responsibility
kernel/http.pyTestable, swappable HTTP backendStrategy pattern
kernel/errors.pyTyped errors with exit codes + guidanceError hierarchy
kernel/security.pyInput sanitization, injection defense, secret redactionInput filter chain
kernel/rate_limiter.pyToken bucket for API rate limitsToken bucket
kernel/checkpoint.pyResume batch operations after crashCheckpoint/resume
kernel/keys.pyEd25519 keypair management (mode 0600)Trust-on-first-use
tools/*.py7 MCP-compatible deterministic toolsTool-use protocol
verify/fibercad_verify.pyStandalone integrity verifier (no deps)Independent audit
planning/service.pyOrchestration layer for both CLI and LLM pathsService layer
planning/sanity.pyPost-planning degenerate output detectionDefensive checks

6. Pivot 4: Monolithic Schema to Layered Cake

4. Pivot 2: Monolithic Schema to Layered Cake

Initial Approach

Single monolithic JSON file containing the entire network design — addresses, GIS data, topology, physical layout, and validation results in one blob.

{
  "type": "FiberNetwork",
  "network": {
    "elements": [...],
    "boundary_groups": [...],
    "addresses": [...]
  },
  "validation": { ... }
}

What We Built

Five separate layer files, each building on the previous, with SHA-256 hashes and Ed25519 signatures forming an integrity chain.

L0_input.fiberjson      (what we're given)
L1_gis.fiberjson        (what exists there)
L2_topology.fiberjson   (network decisions)
L3_physical.fiberjson   (placed on ground)
L4_compliance.fiberjson (validated)

Why This Is Better

Insight from the user: "The schema should be like a layered cake, with gradational layers of enrichment — like math model → algorithm → program."
  • Reproducible. Re-run the routing algorithm (L3) without re-fetching GIS data (L1). Change a standards profile and only L4 regenerates.
  • Auditable. Customer asks "where did this boundary group come from?" — follow the provenance chain back to L0 raw addresses.
  • Tamper-evident. Each layer's hash references the previous layer. Change one coordinate in L1, every downstream hash breaks immediately.
  • Signed. Ed25519 signatures with per-project keys. The public key in L0 is the trust anchor. A standalone verifier (zero FiberCAD dependencies) can validate the entire chain.
  • LLM-friendly. Send L4 stats (~50 tokens) to the LLM, not the entire design. Tools drill into specific layers on demand.
PropertyMonolithicLayered
Selective regenerationImpossible — regenerate everythingChange one layer, keep others
Provenance trackingNone — all data mixedEach layer cites its input + hash
Integrity verificationOne hash for entire fileChain of hashes + signatures
File size per operationRead/write entire blob every timeTouch only the layer you need
Algorithm versioningOne version for everythingPer-layer algorithm versions

5. Pivot 3: LLM-First to Tools-First

Initial Approach

LLM as the primary intelligence layer — send network data to Claude, get back design decisions, optimization suggestions, and documentation.

  • LLM processes raw geometry
  • LLM makes planning decisions
  • LLM generates all documentation
  • Core dependency on API availability

What We Built

Baremetal deterministic tools as the intelligence layer. LLM is an optional review advisor that calls tools — never processes raw data or makes final decisions.

  • 7 MCP-compatible tools (spatial, validation, integrity)
  • LLM calls tools, receives structured summaries
  • LLM suggestions are ephemeral — never signed
  • Full functionality without any LLM API

Why This Is Better

Insight from architecture review: Build "an intelligent layer without actual LLMs under the hood" — smart, structured tools that make LLM interaction efficient when it happens, but don't require it.
  • Reliable. Deterministic tools give the same answer every time. "Is this conduit >500ft?" is a yes/no — not a probabilistic guess.
  • Token-efficient. The LLM sees "BG-03: 34 homes, 2847 ft conduit, 0 violations" (~30 tokens) instead of 3,000 tokens of GeoJSON coordinates.
  • Works offline. No API key? The tool still plans networks, validates designs, and generates all outputs. The LLM review is a bonus, not a requirement.
  • Auditable. LLM suggestions are ephemeral — they advise the operator but never appear in signed layers. The integrity chain records what the tool decided, not what an LLM hallucinated.
  • Portable. The tool layer becomes the Rust API later — same interface, same behavior, just faster.
OperationLLM-FirstTools-First
Measure distance~200 tokens + inference latencyhaversine_ft() in microseconds
Validate designSend entire design + rules as promptDeterministic rule engine, exact results
Count homes in areaParse GeoJSON, count, risk hallucinationSpatial index query, O(log n)
Verify integrityCannot verify cryptographic signaturesverify_chain() — exact math
API down?System brokenSystem works fine, just no review

6. Domain Knowledge: What the Videos Revealed

Five training videos (2.1 GB, 3,115 lines of transcription) were processed via speech-to-text. The extracted domain knowledge changed the rules engine significantly.

Critical Rules Discovered (Not in Written Standards)

RuleSourceImpact
1x4 and 1x8 cannot share a handhole1x4 & 1x8 Explanation [8:30], CAD Training [33:52]Splitter placement algorithm was generating invalid designs
Two-tier run length: 500ft warning, 650ft errorHLD Part 1 [61:06]Previous rule was binary 500ft — missed the exception allowance
Handhole sizing: MED for 1x8, SM for 3-way, SPLT for 1x4HLD Part 1 [24:01], CAD Training [39:20]All handholes were generic HH — wrong for construction
150ft bend ruleHLD Part 1 [50:41]Was placing handholes at every bend unnecessarily
Fiber numbering from back (highest first)1x4 & 1x8 Explanation [18:07], LLD [1:28]Required for correct LLD fiber assignment
Feeder/secondary ribbon separationLLD [25:17]Required for correct splice diagrams
Cul-de-sac routing prohibitionHLD Part 2 [14:27]Routing algorithm was circumnavigating dead-ends
Max 2 same-type splitters per handholeCAD Training [34:03], 1x4 & 1x8 [19:58]Was overpacking handholes
Cable naming conventionLLD [1:41-2:17]Required for correct callout annotations
Key finding: The written standards document (Lumos V6, 19 pages) covered drafting presentation rules well but was incomplete on network design constraints. The critical engineering rules — how equipment interacts, what can share a handhole, how fiber is numbered — lived in the training videos and tribal knowledge, not in any document.

Result: Rules Engine Growth

Before Video Analysis

12 rules from the written Lumos V6 standards document.

After Video Analysis

18 rules total (15 implemented, 3 planned). Plus complete naming conventions, equipment specs, handhole sizing matrix, and cable structure documentation.

7. Architecture Review Findings

A formal architecture review against the Rapsody sister project's patterns identified 21 specific findings across 5 dimensions. The key additions that resulted:

FindingWhat Was AddedWhy It Matters
No circuit breaker for OSM APIkernel/circuit_breaker.py (planned)Prevents hammering a flapping API with 10K geocoding requests
No checkpoint/resumekernel/checkpoint.py30-min geocoding job can resume after crash instead of restarting
No rate limitingkernel/rate_limiter.pyNominatim enforces 1 req/sec — violating gets you banned
GIS input unsanitizedkernel/security.pyOSM is publicly editable — attacker can inject path traversal in street names
No prompt injection defensestrip_prompt_injection() at dispatchTool results flowing to LLM context need sanitization
Two registries for same conceptMerged into dispatch chain patternOne dispatch system, not two competing registries
Layer corruption unhandledTyped verification results per layerStandalone verifier distinguishes hash mismatch vs signature failure vs missing file
LLM suggestions in signed layersEphemeral-only policyAudit trail must record tool decisions, not LLM suggestions
No standalone verifierverify/fibercad_verify.pyThird-party auditor can verify chain without installing FiberCAD

8. Lumos Block Integration

The DXF output initially used primitive shapes (squares for handholes, circles for loops). By extracting the real Lumos template blocks from the project DWG files, the output now uses production-standard symbols.

ElementBeforeAfter
HandholesSmall squareTELCO HANDHOLE_V2 block (10 entities)
1x4 SplittersTriangle1X4 SPLITTER_MODEL block (9 entities)
1x8 SplittersTriangle1X8 SPLITTER_MODEL block (9 entities)
SplicesCross (two lines)FIBER_SPLICE block (3 entities)
Slack LoopsCircleSLACK_LOOP_MODEL block (3 entities)
Layers14 generic layers81 Lumos-standard layers imported
Text StylesStandard only23 Lumos text styles (FTTH, CALLOUT, LOOP, ROMANS, etc.)
Method: Built libredwg from source to convert the Lumos template DWG to DXF. Stripped WIPEOUT entities (AutoCAD-proprietary masking) that caused compatibility issues. Result: clean block library that AutoCAD opens without errors.

9. What Ships Today vs. What's Planned

CapabilityStatusDetail
OSM data ingestionShippingBuildings, roads, addresses from any bounding box
CSV address importShipping--csv flag on CLI
Boundary group planningShippingConstrained geographic clustering, ~32 homes per group
Splitter placementShippingTwo-stage 1x8/1x4 hierarchy with separation enforcement
Conduit routingShippingMST on road network with auto handhole insertion at 500ft
Rules engine (15 rules)ShippingLumos V6 profile with video-derived rules
Ed25519 integrity chainShippingSigned layers, key management, standalone verifier
DXF with Lumos blocksShipping33 blocks, 81 layers, 23 text styles from template
HTML map reportShippingTabbed: Map (3 basemaps, layer controls) + Stats + BOM + Network Graph + Violations
DXF viewerShippingSVG vector rendering, pan/zoom, collapsible sidebar
BOM workbookShipping5-sheet Excel: Summary, Equipment, Conduit, Groups, Addresses
MCP tools (7 tools)Shippingproject_summary, validate_design, measure_distance, etc.
LLM design reviewShippingClaude tool_use agent with fallback mode
Rate limiter + checkpointShippingToken bucket + resumable batch operations
Security moduleShippingPath sanitization, prompt injection defense, secret redaction
150ft bend ruleShippingFrom video analysis
Cul-de-sac routingPlanned (Week 2)Routing heuristic for dead-end streets
Fiber strand assignmentPlanned (Week 2)LLD-level fiber numbering from back
Splice diagramsPlanned (Week 2)From network graph + fiber assignments
Multiple provider profilesPlanned (Week 2)Pluggable standards beyond Lumos
Rust portPlanned (future)Architecture designed for migration

10. The Numbers

60+
Source files
12,668
Lines of code
393
Tests passing
33
Commits
15
Rules implemented
7
MCP tools
5
Output formats
3
Areas tested
6s
Time to plan 460 homes
5
Videos transcribed
23
Text styles imported
33
CAD blocks extracted