# xecipher/rebaranalysis architecture

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

- Interactive diagram: https://gitdiagram.com/xecipher/rebaranalysis
- Repository: https://github.com/xecipher/rebaranalysis

## Overview

RebarAnalysis is a web-based rebar quality-control platform. A site engineer supplies site and design images; the Angular application extracts design specifications and rod points with Gemini, then sends measured points and calibration data to Flask for top- or side-view computer-vision analysis. The frontend scores the returned measurements, presents annotated results and downloadable reports/BIM JSON, and can request an authority alert for low scores. The README also documents Revit/Dynamo visualization. Backend routes and CV services are sampled; some frontend result and export details are based on the README because their implementation was not sampled.

Main entry points: [`frontend/src/app/app.component.ts`](https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/app.component.ts) (Inspection workflow), [`backend/src/app.py`](https://github.com/xecipher/rebaranalysis/blob/main/backend/src/app.py) (Flask API), [`frontend/src/app/services/gemini.service.ts`](https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/services/gemini.service.ts) (Gemini client), [`frontend/public/assets/downloads/rodlines.py`](https://github.com/xecipher/rebaranalysis/blob/main/frontend/public/assets/downloads/rodlines.py) (Rod-lines Dynamo script)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Inspection frontend"]
  node_app["Inspection workflow<br/>[app.component.ts]"]
  node_gemini_client["Gemini client<br/>[gemini.service.ts]"]
  node_scoring["Compliance scoring<br/>[scoring.service.ts]"]
  node_results["Reports and BIM JSON<br/>[app.component.ts]"]
end

subgraph group_analysis["Measurement analysis"]
  node_api["Flask API<br/>[app.py]"]
  node_top_cv["Top-view CV"]
  node_side_cv["Side-view CV"]
end

subgraph group_notifications["Authority alerts"]
  node_email_api{{"Brevo email service"}}
end

subgraph group_bim["BIM integration"]
  node_rod_lines["Rod-lines Dynamo script<br/>[rodlines.py]"]
  node_rod_highlight["Rod-highlight Dynamo script<br/>[rodhighlight.py]"]
end

node_engineer(("Site engineer"))
node_gemini_gateway{{"GemPrism Gateway"}}
node_authority(("Higher authority"))
node_revit["Autodesk Revit"]

node_engineer -->|"uploads images"| node_app
node_app -->|"requests extraction"| node_gemini_client
node_gemini_client -->|"sends image prompts"| node_gemini_gateway
node_gemini_gateway -->|"returns JSON"| node_gemini_client
node_app -->|"submits image and points"| node_api
node_api -->|"dispatches top analysis"| node_top_cv
node_api -->|"dispatches side analysis"| node_side_cv
node_api -->|"returns measurements"| node_app
node_app -->|"scores measurements"| node_scoring
node_app -->|"requests annotated analysis"| node_api
node_app -->|"prepares report and exports"| node_results
node_engineer -->|"downloads results"| node_results
node_app -->|"requests authority alert"| node_api
node_api -->|"dispatches email"| node_email_api
node_email_api -->|"sends alert"| node_authority
node_engineer -->|"runs Dynamo scripts"| node_revit
node_revit -->|"executes"| node_rod_lines
node_revit -->|"executes"| node_rod_highlight
node_rod_lines -->|"reads rod-lines JSON"| node_results
node_rod_highlight -->|"reads highlight JSON"| node_results

click node_app "https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/app.component.ts"
click node_gemini_client "https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/services/gemini.service.ts"
click node_scoring "https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/services/scoring.service.ts"
click node_api "https://github.com/xecipher/rebaranalysis/blob/main/backend/src/app.py"
click node_top_cv "https://github.com/xecipher/rebaranalysis/blob/main/backend/src/analysis_service.py"
click node_side_cv "https://github.com/xecipher/rebaranalysis/blob/main/backend/src/side_view_service.py"
click node_results "https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/app.component.ts"
click node_rod_lines "https://github.com/xecipher/rebaranalysis/blob/main/frontend/public/assets/downloads/rodlines.py"
click node_rod_highlight "https://github.com/xecipher/rebaranalysis/blob/main/frontend/public/assets/downloads/rodhighlight.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_app,node_gemini_client,node_scoring,node_results toneBlue
class node_api,node_top_cv,node_side_cv toneAmber
class node_email_api toneMint
class node_rod_lines,node_rod_highlight toneRose
class node_engineer,node_gemini_gateway,node_authority,node_revit toneIndigo
```

## Components

### Inspection frontend

- [Inspection workflow](https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/app.component.ts): `frontend/src/app/app.component.ts`
- [Gemini client](https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/services/gemini.service.ts): `frontend/src/app/services/gemini.service.ts`
- [Compliance scoring](https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/services/scoring.service.ts): `frontend/src/app/services/scoring.service.ts`
- [Reports and BIM JSON](https://github.com/xecipher/rebaranalysis/blob/main/frontend/src/app/app.component.ts): `frontend/src/app/app.component.ts`

### Measurement analysis

- [Flask API](https://github.com/xecipher/rebaranalysis/blob/main/backend/src/app.py): `backend/src/app.py`
- [Top-view CV](https://github.com/xecipher/rebaranalysis/blob/main/backend/src/analysis_service.py): `backend/src/analysis_service.py`
- [Side-view CV](https://github.com/xecipher/rebaranalysis/blob/main/backend/src/side_view_service.py): `backend/src/side_view_service.py`

### Authority alerts

- **Brevo email service**

### BIM integration

- [Rod-lines Dynamo script](https://github.com/xecipher/rebaranalysis/blob/main/frontend/public/assets/downloads/rodlines.py): `frontend/public/assets/downloads/rodlines.py`
- [Rod-highlight Dynamo script](https://github.com/xecipher/rebaranalysis/blob/main/frontend/public/assets/downloads/rodhighlight.py): `frontend/public/assets/downloads/rodhighlight.py`

### Other components

- **Site engineer**
- **GemPrism Gateway**
- **Higher authority**
- **Autodesk Revit**

## Connections

- Site engineer → Inspection workflow: uploads images
- Inspection workflow → Gemini client: requests extraction
- Gemini client → GemPrism Gateway: sends image prompts
- GemPrism Gateway → Gemini client: returns JSON
- Inspection workflow → Flask API: submits image and points
- Flask API → Top-view CV: dispatches top analysis
- Flask API → Side-view CV: dispatches side analysis
- Flask API → Inspection workflow: returns measurements
- Inspection workflow → Compliance scoring: scores measurements
- Inspection workflow → Flask API: requests annotated analysis
- Inspection workflow → Reports and BIM JSON: prepares report and exports
- Site engineer → Reports and BIM JSON: downloads results
- Inspection workflow → Flask API: requests authority alert
- Flask API → Brevo email service: dispatches email
- Brevo email service → Higher authority: sends alert
- Site engineer → Autodesk Revit: runs Dynamo scripts
- Autodesk Revit → Rod-lines Dynamo script: executes
- Autodesk Revit → Rod-highlight Dynamo script: executes
- Rod-lines Dynamo script → Reports and BIM JSON: reads rod-lines JSON
- Rod-highlight Dynamo script → Reports and BIM JSON: reads highlight JSON
