# krod7/modulo architecture

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

- Interactive diagram: https://gitdiagram.com/krod7/modulo
- Repository: https://github.com/krod7/modulo

## Overview

Modulo is a local web application that deterministically turns a single-page flowchart into traceable Python. The main journey is upload and normalize, recognize shapes/text, recover connectors into a graph, validate and repair flagged regions, translate to pseudocode for user approval, then generate syntax-checked code and source mappings. The README also documents constrained corrections, diagnostics, downloads, and highlighting. Edges use the pipeline and API excerpts or README statements; several later UI/API details are documented but their handlers were not sampled.

Main entry points: [`backend/pipeline.py`](https://github.com/krod7/modulo/blob/main/backend/pipeline.py) (Pipeline orchestration), [`frontend/js/app.js`](https://github.com/krod7/modulo/blob/main/frontend/js/app.js) (Review UI), [`backend/app.py`](https://github.com/krod7/modulo/blob/main/backend/app.py) (Flask API), [`backend/services/validation_service.py`](https://github.com/krod7/modulo/blob/main/backend/services/validation_service.py) (Structure validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser experience"]
  node_webui["Review UI<br/>[app.js]"]
  node_upload["Upload controls<br/>[upload.js]"]
  node_highlight["Source highlighter<br/>[highlighter.js]"]
end

subgraph group_api["Local API"]
  node_api["Flask API<br/>[app.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
  node_session[("Temporary analysis store<br/>[analysis_store.py]")]
  node_contracts["Analysis contracts<br/>[models.py]"]
  node_pipeline["Pipeline orchestration<br/>[pipeline.py]"]
end

subgraph group_recognition["Diagram analysis"]
  node_intake["File intake<br/>[intake_service.py]"]
  node_vision["Shape and OCR recognition<br/>[vision_service.py]"]
  node_geometry["Connector geometry"]
  node_graph["Flow graph recovery<br/>[graph_service.py]"]
  node_validation["Structure validation"]
  node_ocrvalidate["OCR text validation"]
end

subgraph group_translation["Deterministic translation"]
  node_notation["Safe notation rules<br/>[notation.py]"]
  node_logic["Control-flow IR<br/>[logic_service.py]"]
  node_pseudo["Pseudocode rendering"]
  node_codegen["Python generation<br/>[codegen_service.py]"]
  node_trace["Source trace mapping<br/>[trace_service.py]"]
end

node_user(("Flowchart author"))

node_user -->|"submits chart"| node_webui
node_webui -->|"uses upload"| node_upload
node_webui -->|"binds highlighting"| node_highlight
node_webui -->|"sends analysis"| node_api
node_api -->|"inspects upload"| node_intake
node_api -->|"runs analysis"| node_pipeline
node_api -->|"stores analysis"| node_session
node_api -->|"configures limits"| node_settings
node_pipeline -->|"runs first"| node_intake
node_pipeline -->|"runs recognition"| node_vision
node_pipeline -->|"runs recovery"| node_graph
node_pipeline -->|"runs checks"| node_validation
node_pipeline -->|"builds IR"| node_logic
node_pipeline -->|"renders pseudocode"| node_pseudo
node_pipeline -->|"generates code"| node_codegen
node_pipeline -->|"builds trace"| node_trace
node_vision -->|"uses geometry"| node_geometry
node_graph -->|"uses connector tools"| node_geometry
node_validation -->|"checks OCR"| node_ocrvalidate
node_validation -->|"validates notation"| node_notation
node_logic -->|"uses branch analysis"| node_validation
node_logic -->|"normalizes rules"| node_notation
node_codegen -->|"applies safe rules"| node_notation
node_user -->|"approves pseudocode"| node_webui
node_webui -->|"requests generation"| node_api
node_webui -->|"links chart and output"| node_highlight

click node_webui "https://github.com/krod7/modulo/blob/main/frontend/js/app.js"
click node_upload "https://github.com/krod7/modulo/blob/main/frontend/js/upload.js"
click node_highlight "https://github.com/krod7/modulo/blob/main/frontend/js/highlighter.js"
click node_api "https://github.com/krod7/modulo/blob/main/backend/app.py"
click node_settings "https://github.com/krod7/modulo/blob/main/backend/config.py"
click node_session "https://github.com/krod7/modulo/blob/main/backend/analysis_store.py"
click node_contracts "https://github.com/krod7/modulo/blob/main/backend/models.py"
click node_pipeline "https://github.com/krod7/modulo/blob/main/backend/pipeline.py"
click node_intake "https://github.com/krod7/modulo/blob/main/backend/services/intake_service.py"
click node_vision "https://github.com/krod7/modulo/blob/main/backend/services/vision_service.py"
click node_geometry "https://github.com/krod7/modulo/blob/main/backend/services/connector_geometry.py"
click node_graph "https://github.com/krod7/modulo/blob/main/backend/services/graph_service.py"
click node_validation "https://github.com/krod7/modulo/blob/main/backend/services/validation_service.py"
click node_ocrvalidate "https://github.com/krod7/modulo/blob/main/backend/services/programming_ocr_validation.py"
click node_notation "https://github.com/krod7/modulo/blob/main/backend/notation.py"
click node_logic "https://github.com/krod7/modulo/blob/main/backend/services/logic_service.py"
click node_pseudo "https://github.com/krod7/modulo/blob/main/backend/services/pseudocode_service.py"
click node_codegen "https://github.com/krod7/modulo/blob/main/backend/services/codegen_service.py"
click node_trace "https://github.com/krod7/modulo/blob/main/backend/services/trace_service.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_webui,node_upload,node_highlight toneBlue
class node_api,node_settings,node_session,node_contracts,node_pipeline toneAmber
class node_intake,node_vision,node_geometry,node_graph,node_validation,node_ocrvalidate toneMint
class node_notation,node_logic,node_pseudo,node_codegen,node_trace toneRose
class node_user toneIndigo
```

## Components

### Browser experience

- [Review UI](https://github.com/krod7/modulo/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [Upload controls](https://github.com/krod7/modulo/blob/main/frontend/js/upload.js): `frontend/js/upload.js`
- [Source highlighter](https://github.com/krod7/modulo/blob/main/frontend/js/highlighter.js): `frontend/js/highlighter.js`

### Local API

- [Flask API](https://github.com/krod7/modulo/blob/main/backend/app.py): `backend/app.py`
- [Runtime settings](https://github.com/krod7/modulo/blob/main/backend/config.py): `backend/config.py`
- [Temporary analysis store](https://github.com/krod7/modulo/blob/main/backend/analysis_store.py): `backend/analysis_store.py`
- [Analysis contracts](https://github.com/krod7/modulo/blob/main/backend/models.py): `backend/models.py`
- [Pipeline orchestration](https://github.com/krod7/modulo/blob/main/backend/pipeline.py): `backend/pipeline.py`

### Diagram analysis

- [File intake](https://github.com/krod7/modulo/blob/main/backend/services/intake_service.py): `backend/services/intake_service.py`
- [Shape and OCR recognition](https://github.com/krod7/modulo/blob/main/backend/services/vision_service.py): `backend/services/vision_service.py`
- [Connector geometry](https://github.com/krod7/modulo/blob/main/backend/services/connector_geometry.py): `backend/services/connector_geometry.py`
- [Flow graph recovery](https://github.com/krod7/modulo/blob/main/backend/services/graph_service.py): `backend/services/graph_service.py`
- [Structure validation](https://github.com/krod7/modulo/blob/main/backend/services/validation_service.py): `backend/services/validation_service.py`
- [OCR text validation](https://github.com/krod7/modulo/blob/main/backend/services/programming_ocr_validation.py): `backend/services/programming_ocr_validation.py`

### Deterministic translation

- [Safe notation rules](https://github.com/krod7/modulo/blob/main/backend/notation.py): `backend/notation.py`
- [Control-flow IR](https://github.com/krod7/modulo/blob/main/backend/services/logic_service.py): `backend/services/logic_service.py`
- [Pseudocode rendering](https://github.com/krod7/modulo/blob/main/backend/services/pseudocode_service.py): `backend/services/pseudocode_service.py`
- [Python generation](https://github.com/krod7/modulo/blob/main/backend/services/codegen_service.py): `backend/services/codegen_service.py`
- [Source trace mapping](https://github.com/krod7/modulo/blob/main/backend/services/trace_service.py): `backend/services/trace_service.py`

### Other components

- **Flowchart author**

## Connections

- Flowchart author → Review UI: submits chart (evidence: `README.md`)
- Review UI → Upload controls: uses upload (evidence: `frontend/js/app.js`)
- Review UI → Source highlighter: binds highlighting (evidence: `frontend/js/app.js`)
- Review UI → Flask API: sends analysis (evidence: `README.md`)
- Flask API → File intake: inspects upload (evidence: `backend/app.py`)
- Flask API → Pipeline orchestration: runs analysis (evidence: `backend/pipeline.py`)
- Flask API → Temporary analysis store: stores analysis (evidence: `backend/app.py`)
- Flask API → Runtime settings: configures limits (evidence: `backend/config.py`)
- Pipeline orchestration → File intake: runs first (evidence: `backend/pipeline.py`)
- Pipeline orchestration → Shape and OCR recognition: runs recognition (evidence: `backend/pipeline.py`)
- Pipeline orchestration → Flow graph recovery: runs recovery (evidence: `backend/pipeline.py`)
- Pipeline orchestration → Structure validation: runs checks (evidence: `backend/pipeline.py`)
- Pipeline orchestration → Control-flow IR: builds IR (evidence: `backend/pipeline.py`)
- Pipeline orchestration → Pseudocode rendering: renders pseudocode (evidence: `backend/pipeline.py`)
- Pipeline orchestration → Python generation: generates code (evidence: `backend/pipeline.py`)
- Pipeline orchestration → Source trace mapping: builds trace (evidence: `backend/pipeline.py`)
- Shape and OCR recognition → Connector geometry: uses geometry (evidence: `backend/services/vision_service.py`)
- Flow graph recovery → Connector geometry: uses connector tools (evidence: `backend/services/graph_service.py`)
- Structure validation → OCR text validation: checks OCR (evidence: `backend/services/validation_service.py`)
- Structure validation → Safe notation rules: validates notation (evidence: `backend/services/validation_service.py`)
- Control-flow IR → Structure validation: uses branch analysis (evidence: `backend/services/logic_service.py`)
- Control-flow IR → Safe notation rules: normalizes rules (evidence: `backend/services/logic_service.py`)
- Python generation → Safe notation rules: applies safe rules (evidence: `backend/services/codegen_service.py`)
- Flowchart author → Review UI: approves pseudocode (evidence: `README.md`)
- Review UI → Flask API: requests generation (evidence: `README.md`)
- Review UI → Source highlighter: links chart and output (evidence: `README.md`)
