# a-shojaei/constructdrawingai architecture

> Architecture diagram of the GitHub repository a-shojaei/constructdrawingai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/a-shojaei/constructdrawingai
- Repository: https://github.com/a-shojaei/constructdrawingai

## Overview

ConstructDrawingAI turns construction drawings into structured CIR data, then supports detection, connectivity, ontology grounding, quantity takeoff, Q&A and RFI drafting. The principal route is drawing ingestion → CIR → perception → grounding/takeoff or agent outputs; the backend exposes these workflows. Synthetic generation and evaluation are substantial supporting capabilities. Documented layer flow and shown imports/calls support the relationships below; some subsystem internals were not sampled, so those relationships are omitted rather than inferred.

Main entry points: [`cir/schema.py`](https://github.com/a-shojaei/constructdrawingai/blob/main/cir/schema.py) (CIR schema), [`backend/app.py`](https://github.com/a-shojaei/constructdrawingai/blob/main/backend/app.py) (Backend API), [`synthetic/render.py`](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/render.py) (Drawing renderer), [`synthetic/generate.py`](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/generate.py) (Sample generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared data"]
  node_cir["CIR schema<br/>[schema.py]"]
end

subgraph group_extract["Drawing extraction"]
  node_ingest["Drawing ingest"]
  node_perception["Detection<br/>[detector.py]"]
  node_connectivity["Connectivity graph<br/>[connectivity.py]"]
end

subgraph group_decision["Decision outputs"]
  node_grounding["Ontology grounding<br/>[ontology.py]"]
  node_takeoff["Quantity takeoff<br/>[takeoff.py]"]
  node_qa["Drawing Q&amp;A<br/>[qa.py]"]
  node_rfi["RFI drafting<br/>[rfi.py]"]
  node_api["Backend API<br/>[app.py]"]
  node_detect_api["Image detection adapter<br/>[detect.py]"]
end

subgraph group_support["Data and evaluation"]
  node_realsets[("Real drawing sets<br/>[realsets.py]")]
  node_dataset_prep["Dataset preparation"]
  node_evaluation["Model evaluation<br/>[metrics.py]"]
  node_eval_tasks["Evaluation tasks<br/>[tasks.py]"]
end

subgraph group_synthetic["Synthetic engine"]
  node_synthetic_model["Electrical model<br/>[model.py]"]
  node_synthetic_scene["Scene layout<br/>[scene.py]"]
  node_synthetic_render["Drawing renderer<br/>[render.py]"]
  node_synthetic_generate["Sample generation<br/>[generate.py]"]
  node_synthetic_layout["Layout rules<br/>[layout.py]"]
  node_synthetic_provenance["Sample provenance<br/>[provenance.py]"]
  node_synthetic_style["Drawing style<br/>[style.py]"]
  node_synthetic_symbols["Symbol catalog<br/>[symbols.py]"]
  node_synthetic_canvas["Render canvas<br/>[canvas.py]"]
end

node_user(("Engineer"))

node_user -->|"submits drawing"| node_api
node_ingest -->|"produces CIR"| node_cir
node_cir -->|"feeds detection"| node_perception
node_perception -->|"writes detections"| node_cir
node_perception -.->|"extracts connections"| node_connectivity
node_cir -->|"supplies entities"| node_grounding
node_cir -->|"supplies quantities"| node_takeoff
node_cir -->|"grounds answers"| node_qa
node_cir -->|"informs drafts"| node_rfi
node_api -->|"calls grounding"| node_grounding
node_api -->|"calls takeoff"| node_takeoff
node_api -->|"calls Q&amp;A"| node_qa
node_api -->|"calls drafting"| node_rfi
node_api -->|"routes image"| node_detect_api
node_detect_api -->|"returns CIR"| node_cir
node_realsets -->|"rasterizes sheets"| node_ingest
node_dataset_prep -->|"writes CIR data"| node_cir
node_cir -->|"scores predictions"| node_evaluation
node_eval_tasks -->|"holds ground truth"| node_cir
node_synthetic_generate -->|"builds model"| node_synthetic_model
node_synthetic_generate -->|"renders samples"| node_synthetic_render
node_synthetic_generate -->|"builds scenes"| node_synthetic_scene
node_synthetic_render -->|"reads model"| node_synthetic_model
node_synthetic_scene -->|"uses layout"| node_synthetic_layout
node_synthetic_render -->|"draws on canvas"| node_synthetic_canvas
node_synthetic_render -->|"uses style"| node_synthetic_style
node_synthetic_render -->|"draws symbols"| node_synthetic_symbols
node_synthetic_render -->|"records provenance"| node_synthetic_provenance

click node_cir "https://github.com/a-shojaei/constructdrawingai/blob/main/cir/schema.py"
click node_ingest "https://github.com/a-shojaei/constructdrawingai/tree/main/ingest"
click node_perception "https://github.com/a-shojaei/constructdrawingai/blob/main/perception/detector.py"
click node_connectivity "https://github.com/a-shojaei/constructdrawingai/blob/main/perception/connectivity.py"
click node_grounding "https://github.com/a-shojaei/constructdrawingai/blob/main/grounding/ontology.py"
click node_takeoff "https://github.com/a-shojaei/constructdrawingai/blob/main/engines/takeoff.py"
click node_qa "https://github.com/a-shojaei/constructdrawingai/blob/main/agent/qa.py"
click node_rfi "https://github.com/a-shojaei/constructdrawingai/blob/main/agent/rfi.py"
click node_api "https://github.com/a-shojaei/constructdrawingai/blob/main/backend/app.py"
click node_detect_api "https://github.com/a-shojaei/constructdrawingai/blob/main/backend/detect.py"
click node_realsets "https://github.com/a-shojaei/constructdrawingai/blob/main/datasets/realsets.py"
click node_dataset_prep "https://github.com/a-shojaei/constructdrawingai/tree/main/datasets/preparers"
click node_evaluation "https://github.com/a-shojaei/constructdrawingai/blob/main/eval/metrics.py"
click node_eval_tasks "https://github.com/a-shojaei/constructdrawingai/blob/main/eval/tasks.py"
click node_synthetic_model "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/model.py"
click node_synthetic_scene "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/scene.py"
click node_synthetic_render "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/render.py"
click node_synthetic_generate "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/generate.py"
click node_synthetic_layout "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/layout.py"
click node_synthetic_provenance "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/provenance.py"
click node_synthetic_style "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/style.py"
click node_synthetic_symbols "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/symbols.py"
click node_synthetic_canvas "https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/canvas.py"

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_cir toneBlue
class node_ingest,node_perception,node_connectivity toneAmber
class node_grounding,node_takeoff,node_qa,node_rfi,node_api,node_detect_api toneMint
class node_realsets,node_dataset_prep,node_evaluation,node_eval_tasks toneRose
class node_synthetic_model,node_synthetic_scene,node_synthetic_render,node_synthetic_generate,node_synthetic_layout,node_synthetic_provenance,node_synthetic_style,node_synthetic_symbols,node_synthetic_canvas,node_user toneIndigo
```

## Components

### Shared data

- [CIR schema](https://github.com/a-shojaei/constructdrawingai/blob/main/cir/schema.py): `cir/schema.py`

### Drawing extraction

- [Drawing ingest](https://github.com/a-shojaei/constructdrawingai/tree/main/ingest): `ingest`
- [Detection](https://github.com/a-shojaei/constructdrawingai/blob/main/perception/detector.py): `perception/detector.py`
- [Connectivity graph](https://github.com/a-shojaei/constructdrawingai/blob/main/perception/connectivity.py): `perception/connectivity.py`

### Decision outputs

- [Ontology grounding](https://github.com/a-shojaei/constructdrawingai/blob/main/grounding/ontology.py): `grounding/ontology.py`
- [Quantity takeoff](https://github.com/a-shojaei/constructdrawingai/blob/main/engines/takeoff.py): `engines/takeoff.py`
- [Drawing Q&A](https://github.com/a-shojaei/constructdrawingai/blob/main/agent/qa.py): `agent/qa.py`
- [RFI drafting](https://github.com/a-shojaei/constructdrawingai/blob/main/agent/rfi.py): `agent/rfi.py`
- [Backend API](https://github.com/a-shojaei/constructdrawingai/blob/main/backend/app.py): `backend/app.py`
- [Image detection adapter](https://github.com/a-shojaei/constructdrawingai/blob/main/backend/detect.py): `backend/detect.py`

### Data and evaluation

- [Real drawing sets](https://github.com/a-shojaei/constructdrawingai/blob/main/datasets/realsets.py): `datasets/realsets.py`
- [Dataset preparation](https://github.com/a-shojaei/constructdrawingai/tree/main/datasets/preparers): `datasets/preparers`
- [Model evaluation](https://github.com/a-shojaei/constructdrawingai/blob/main/eval/metrics.py): `eval/metrics.py`
- [Evaluation tasks](https://github.com/a-shojaei/constructdrawingai/blob/main/eval/tasks.py): `eval/tasks.py`

### Synthetic engine

- [Electrical model](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/model.py): `synthetic/model.py`
- [Scene layout](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/scene.py): `synthetic/scene.py`
- [Drawing renderer](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/render.py): `synthetic/render.py`
- [Sample generation](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/generate.py): `synthetic/generate.py`
- [Layout rules](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/layout.py): `synthetic/layout.py`
- [Sample provenance](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/provenance.py): `synthetic/provenance.py`
- [Drawing style](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/style.py): `synthetic/style.py`
- [Symbol catalog](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/symbols.py): `synthetic/symbols.py`
- [Render canvas](https://github.com/a-shojaei/constructdrawingai/blob/main/synthetic/canvas.py): `synthetic/canvas.py`

### Other components

- **Engineer**

## Connections

- Engineer → Backend API: submits drawing (evidence: `README.md`)
- Drawing ingest → CIR schema: produces CIR (evidence: `README.md`)
- CIR schema → Detection: feeds detection (evidence: `README.md`)
- Detection → CIR schema: writes detections (evidence: `README.md`)
- Detection → Connectivity graph: extracts connections
- CIR schema → Ontology grounding: supplies entities (evidence: `README.md`)
- CIR schema → Quantity takeoff: supplies quantities (evidence: `engines/takeoff.py`)
- CIR schema → Drawing Q&A: grounds answers (evidence: `agent/qa.py`)
- CIR schema → RFI drafting: informs drafts (evidence: `agent/rfi.py`)
- Backend API → Ontology grounding: calls grounding (evidence: `backend/app.py`)
- Backend API → Quantity takeoff: calls takeoff (evidence: `backend/app.py`)
- Backend API → Drawing Q&A: calls Q&A (evidence: `backend/app.py`)
- Backend API → RFI drafting: calls drafting (evidence: `backend/app.py`)
- Backend API → Image detection adapter: routes image (evidence: `backend/app.py`)
- Image detection adapter → CIR schema: returns CIR (evidence: `backend/detect.py`)
- Real drawing sets → Drawing ingest: rasterizes sheets (evidence: `datasets/realsets.py`)
- Dataset preparation → CIR schema: writes CIR data (evidence: `datasets/preparers/graphml_cir.py`)
- CIR schema → Model evaluation: scores predictions (evidence: `eval/metrics.py`)
- Evaluation tasks → CIR schema: holds ground truth (evidence: `eval/tasks.py`)
- Sample generation → Electrical model: builds model (evidence: `synthetic/generate.py`)
- Sample generation → Drawing renderer: renders samples (evidence: `synthetic/generate.py`)
- Sample generation → Scene layout: builds scenes (evidence: `synthetic/generate.py`)
- Drawing renderer → Electrical model: reads model (evidence: `synthetic/render.py`)
- Scene layout → Layout rules: uses layout (evidence: `synthetic/scene.py`)
- Drawing renderer → Render canvas: draws on canvas (evidence: `synthetic/render.py`)
- Drawing renderer → Drawing style: uses style (evidence: `synthetic/render.py`)
- Drawing renderer → Symbol catalog: draws symbols (evidence: `synthetic/render.py`)
- Drawing renderer → Sample provenance: records provenance (evidence: `synthetic/render.py`)
