# mf4633/opencad-storm-sewer-plugin architecture

> Architecture diagram of the GitHub repository mf4633/opencad-storm-sewer-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mf4633/opencad-storm-sewer-plugin
- Repository: https://github.com/mf4633/opencad-storm-sewer-plugin

## Overview

This repository is an Open CAD Studio storm-sewer design plugin backed by a separate, headless hydraulics engine. The main workflow is issuing an SS_* command, reconstructing a network from drawing XDATA, running hydrology and hydraulic analysis, and returning reports or drawing updates. Other branches cover network placement and editing, LandXML import, validation, pipe sizing, inlet criteria, and Pro licensing. Edges reflect explicit README statements, excerpts, or SOURCE INDEX references; unsampled subsystem internals are not inferred.

Main entry points: [`src/dispatch.rs`](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/dispatch.rs) (SS Command Router), [`crates/stormsewer/src/network.rs`](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/network.rs) (Storm Network Analysis), [`src/data.rs`](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/data.rs) (XDATA Network Bridge), [`src/analysis.rs`](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/analysis.rs) (Engine Bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin["CAD Plugin"]
  node_commands["SS Command Router<br/>[dispatch.rs]"]
  node_interactive["Interactive Placement<br/>[interactive.rs]"]
  node_placement["Automation Placement<br/>[placement.rs]"]
  node_state["Analysis Parameters<br/>[state.rs]"]
end

subgraph group_network["Network Data"]
  node_drawing[("CAD Drawing XDATA")]
  node_xdata["XDATA Network Bridge<br/>[data.rs]"]
  node_edit["Network Editing<br/>[edit.rs]"]
  node_xmlimport["LandXML Import<br/>[landxml_import.rs]"]
end

subgraph group_engine["Analysis Engine"]
  node_enginebridge["Engine Bridge<br/>[analysis.rs]"]
  node_networkmodel["Storm Network Analysis<br/>[network.rs]"]
  node_hydraulics["Manning Hydraulics<br/>[hydraulics.rs]"]
  node_idf["Rainfall IDF<br/>[idf.rs]"]
  node_parameters["Engine Parameters<br/>[params.rs]"]
  node_format["Network File Parsing<br/>[parse.rs]"]
end

subgraph group_features["Design Features"]
  node_report["Analysis Reports<br/>[report.rs]"]
  node_htmlreport["HTML KaTeX Report<br/>[report_html.rs]"]
  node_inlets["HEC-22 Inlets<br/>[inlets.rs]"]
  node_sizing["Pipe Sizing<br/>[sizing.rs]"]
  node_review["Criteria Review<br/>[review.rs]"]
  node_validation["Drawing Validation<br/>[validation.rs]"]
  node_styling["Analysis Styling<br/>[style.rs]"]
end

subgraph group_access["Pro Access"]
  node_licensecmd["License Commands<br/>[license_cmd.rs]"]
  node_license["License Activation<br/>[license.rs]"]
end

node_designer(("CAD Designer"))
node_ocs["Open CAD Studio"]
node_license_service["License Service"]

node_designer -->|"uses commands"| node_ocs
node_ocs -->|"dispatches commands"| node_commands
node_commands -->|"reconstructs network"| node_xdata
node_xdata -->|"reads and writes XDATA"| node_drawing
node_commands -->|"starts picks"| node_interactive
node_commands -->|"places entities"| node_placement
node_interactive -->|"uses network data"| node_xdata
node_placement -->|"uses network data"| node_xdata
node_commands -->|"routes edits"| node_edit
node_edit -->|"reads drawing data"| node_xdata
node_commands -->|"routes imports"| node_xmlimport
node_commands -->|"runs analysis"| node_enginebridge
node_enginebridge -->|"reconstructs network"| node_xdata
node_enginebridge -->|"runs engine analysis"| node_networkmodel
node_networkmodel -->|"uses hydraulics"| node_hydraulics
node_networkmodel -->|"uses rainfall curve"| node_idf
node_networkmodel -->|"uses parameters"| node_parameters
node_commands -->|"loads parameters"| node_state
node_commands -.->|"routes reports"| node_report
node_commands -->|"routes HTML reports"| node_htmlreport
node_commands -->|"routes sizing"| node_sizing
node_commands -->|"routes validation"| node_validation
node_commands -->|"routes styling"| node_styling
node_networkmodel -->|"supports network files"| node_format
node_commands -->|"routes activation"| node_licensecmd
node_licensecmd -->|"activates key"| node_license
node_license -.->|"validates online"| node_license_service
node_commands -.->|"configures inlet criteria"| node_inlets
node_networkmodel -->|"supports criteria review"| node_review

click node_commands "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/dispatch.rs"
click node_interactive "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/interactive.rs"
click node_placement "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/placement.rs"
click node_state "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/state.rs"
click node_xdata "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/data.rs"
click node_edit "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/edit.rs"
click node_xmlimport "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/landxml_import.rs"
click node_enginebridge "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/analysis.rs"
click node_networkmodel "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/network.rs"
click node_hydraulics "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/hydraulics.rs"
click node_idf "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/idf.rs"
click node_parameters "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/params.rs"
click node_format "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/parse.rs"
click node_report "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/report.rs"
click node_htmlreport "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/report_html.rs"
click node_inlets "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/design/inlets.rs"
click node_sizing "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/design/sizing.rs"
click node_review "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/design/review.rs"
click node_validation "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/validation.rs"
click node_styling "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/style.rs"
click node_licensecmd "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/license_cmd.rs"
click node_license "https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/license.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_commands,node_interactive,node_placement,node_state toneBlue
class node_drawing,node_xdata,node_edit,node_xmlimport toneAmber
class node_enginebridge,node_networkmodel,node_hydraulics,node_idf,node_parameters,node_format toneMint
class node_report,node_htmlreport,node_inlets,node_sizing,node_review,node_validation,node_styling toneRose
class node_licensecmd,node_license,node_designer,node_ocs,node_license_service toneIndigo
```

## Components

### CAD Plugin

- [SS Command Router](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/dispatch.rs): `src/dispatch.rs`
- [Interactive Placement](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/interactive.rs): `src/interactive.rs`
- [Automation Placement](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/placement.rs): `src/placement.rs`
- [Analysis Parameters](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/state.rs): `src/state.rs`

### Network Data

- **CAD Drawing XDATA**
- [XDATA Network Bridge](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/data.rs): `src/data.rs`
- [Network Editing](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/edit.rs): `src/edit.rs`
- [LandXML Import](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/landxml_import.rs): `src/landxml_import.rs`

### Analysis Engine

- [Engine Bridge](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/analysis.rs): `src/analysis.rs`
- [Storm Network Analysis](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/network.rs): `crates/stormsewer/src/network.rs`
- [Manning Hydraulics](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/hydraulics.rs): `crates/stormsewer/src/hydraulics.rs`
- [Rainfall IDF](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/idf.rs): `crates/stormsewer/src/idf.rs`
- [Engine Parameters](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/params.rs): `crates/stormsewer/src/params.rs`
- [Network File Parsing](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/parse.rs): `crates/stormsewer/src/parse.rs`

### Design Features

- [Analysis Reports](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/report.rs): `crates/stormsewer/src/report.rs`
- [HTML KaTeX Report](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/report_html.rs): `crates/stormsewer/src/report_html.rs`
- [HEC-22 Inlets](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/design/inlets.rs): `crates/stormsewer/src/design/inlets.rs`
- [Pipe Sizing](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/design/sizing.rs): `crates/stormsewer/src/design/sizing.rs`
- [Criteria Review](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/crates/stormsewer/src/design/review.rs): `crates/stormsewer/src/design/review.rs`
- [Drawing Validation](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/validation.rs): `src/validation.rs`
- [Analysis Styling](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/style.rs): `src/style.rs`

### Pro Access

- [License Commands](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/license_cmd.rs): `src/license_cmd.rs`
- [License Activation](https://github.com/mf4633/opencad-storm-sewer-plugin/blob/main/src/license.rs): `src/license.rs`

### Other components

- **CAD Designer**
- **Open CAD Studio**
- **License Service**

## Connections

- CAD Designer → Open CAD Studio: uses commands (evidence: `README.md`)
- Open CAD Studio → SS Command Router: dispatches commands
- SS Command Router → XDATA Network Bridge: reconstructs network (evidence: `src/dispatch.rs`)
- XDATA Network Bridge → CAD Drawing XDATA: reads and writes XDATA (evidence: `src/data.rs`)
- SS Command Router → Interactive Placement: starts picks (evidence: `src/dispatch.rs`)
- SS Command Router → Automation Placement: places entities (evidence: `src/dispatch.rs`)
- Interactive Placement → XDATA Network Bridge: uses network data (evidence: `src/interactive.rs`)
- Automation Placement → XDATA Network Bridge: uses network data (evidence: `src/placement.rs`)
- SS Command Router → Network Editing: routes edits (evidence: `src/dispatch.rs`)
- Network Editing → XDATA Network Bridge: reads drawing data (evidence: `src/edit.rs`)
- SS Command Router → LandXML Import: routes imports (evidence: `src/dispatch.rs`)
- SS Command Router → Engine Bridge: runs analysis (evidence: `src/dispatch.rs`)
- Engine Bridge → XDATA Network Bridge: reconstructs network (evidence: `src/analysis.rs`)
- Engine Bridge → Storm Network Analysis: runs engine analysis (evidence: `src/analysis.rs`)
- Storm Network Analysis → Manning Hydraulics: uses hydraulics (evidence: `crates/stormsewer/src/network.rs`)
- Storm Network Analysis → Rainfall IDF: uses rainfall curve (evidence: `crates/stormsewer/src/network.rs`)
- Storm Network Analysis → Engine Parameters: uses parameters (evidence: `crates/stormsewer/src/network.rs`)
- SS Command Router → Analysis Parameters: loads parameters (evidence: `src/dispatch.rs`)
- SS Command Router → Analysis Reports: routes reports
- SS Command Router → HTML KaTeX Report: routes HTML reports (evidence: `src/dispatch.rs`)
- SS Command Router → Pipe Sizing: routes sizing (evidence: `src/dispatch.rs`)
- SS Command Router → Drawing Validation: routes validation (evidence: `src/dispatch.rs`)
- SS Command Router → Analysis Styling: routes styling (evidence: `src/dispatch.rs`)
- Storm Network Analysis → Network File Parsing: supports network files (evidence: `crates/stormsewer/src/lib.rs`)
- SS Command Router → License Commands: routes activation (evidence: `src/dispatch.rs`)
- License Commands → License Activation: activates key (evidence: `src/license_cmd.rs`)
- License Activation → License Service: validates online
- SS Command Router → HEC-22 Inlets: configures inlet criteria
- Storm Network Analysis → Criteria Review: supports criteria review (evidence: `crates/stormsewer/src/design/review.rs`)
