# indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach architecture

> Architecture diagram of the GitHub repository indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach, 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/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach
- Repository: https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach

## Overview

This Flask application lets a user upload a piping-and-instrumentation drawing, stores a resized copy, and requests OCR-based PDF conversion. A separate prediction endpoint accepts image data, preprocesses it, and uses a loaded Keras model to return a symbol label and confidence. The graph shows these as distinct workflows; template-side interactions are inferred from the routes and are marked unverified because the templates were not sampled.

Main entry points: [`app.py`](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py) (Flask routes), [`templates/results.html`](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/templates/results.html) (Results page), [`templates/index.html`](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/templates/index.html) (Upload page), [`static/uploads`](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/tree/main/static/uploads) (Uploaded images)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_flask["Flask routes<br/>[app.py]"]
  node_upload_ui["Upload page<br/>[index.html]"]
  node_results_ui["Results page<br/>[results.html]"]
end

subgraph group_upload["Upload and OCR"]
  node_upload_handler["Image upload<br/>[app.py]"]
  node_image_store[("Uploaded images")]
  node_image_resize["Image resizing<br/>[app.py]"]
  node_ocr["OCR PDF service"]
  node_pdf_store[("Generated PDFs")]
end

subgraph group_prediction["Symbol prediction"]
  node_prediction_handler["Prediction endpoint<br/>[app.py]"]
  node_image_preprocess["Image preprocessing<br/>[app.py]"]
  node_model_definition["Model definition<br/>[model.json]"]
  node_model_weights["Model weights<br/>[model.h5]"]
  node_classifier["Symbol classifier<br/>[app.py]"]
end

node_user(("User"))

node_user -.->|"submits image"| node_upload_ui
node_flask -->|"renders"| node_upload_ui
node_flask -->|"routes upload"| node_upload_handler
node_upload_handler -->|"saves original"| node_image_store
node_upload_handler -->|"requests OCR"| node_ocr
node_ocr -->|"writes PDF"| node_pdf_store
node_upload_handler -->|"resizes image"| node_image_resize
node_image_resize -->|"saves resized"| node_image_store
node_flask -->|"renders results"| node_results_ui
node_results_ui -.->|"displays result"| node_user
node_user -.->|"sends image data"| node_prediction_handler
node_flask -->|"routes prediction"| node_prediction_handler
node_prediction_handler -->|"calls prediction"| node_image_preprocess
node_image_preprocess -->|"predicts image"| node_classifier
node_classifier -->|"loads architecture"| node_model_definition
node_classifier -->|"loads weights"| node_model_weights
node_prediction_handler -->|"returns JSON"| node_user

click node_flask "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py"
click node_upload_ui "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/templates/index.html"
click node_results_ui "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/templates/results.html"
click node_upload_handler "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py"
click node_image_store "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/tree/main/static/uploads"
click node_image_resize "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py"
click node_pdf_store "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/tree/main/static/pdf"
click node_prediction_handler "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py"
click node_image_preprocess "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py"
click node_model_definition "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/model.json"
click node_model_weights "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/model.h5"
click node_classifier "https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.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_flask,node_upload_ui,node_results_ui,node_user toneBlue
class node_upload_handler,node_image_store,node_image_resize,node_ocr,node_pdf_store toneAmber
class node_prediction_handler,node_image_preprocess,node_model_definition,node_model_weights,node_classifier toneMint
```

## Components

### Web interface

- [Flask routes](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py): `app.py`
- [Upload page](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/templates/index.html): `templates/index.html`
- [Results page](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/templates/results.html): `templates/results.html`

### Upload and OCR

- [Image upload](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py): `app.py`
- [Uploaded images](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/tree/main/static/uploads): `static/uploads`
- [Image resizing](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py): `app.py`
- **OCR PDF service**
- [Generated PDFs](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/tree/main/static/pdf): `static/pdf`

### Symbol prediction

- [Prediction endpoint](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py): `app.py`
- [Image preprocessing](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py): `app.py`
- [Model definition](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/model.json): `model.json`
- [Model weights](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/model.h5): `model.h5`
- [Symbol classifier](https://github.com/indrajithekanayake/reverse-engineering-piping-and-instrumentation-drawings-a-deep-learning-approach/blob/main/app.py): `app.py`

### Other components

- **User**

## Connections

- User → Upload page: submits image
- Flask routes → Upload page: renders (evidence: `app.py`)
- Flask routes → Image upload: routes upload (evidence: `app.py`)
- Image upload → Uploaded images: saves original (evidence: `app.py`)
- Image upload → OCR PDF service: requests OCR (evidence: `app.py`)
- OCR PDF service → Generated PDFs: writes PDF
- Image upload → Image resizing: resizes image (evidence: `app.py`)
- Image resizing → Uploaded images: saves resized (evidence: `app.py`)
- Flask routes → Results page: renders results (evidence: `app.py`)
- Results page → User: displays result
- User → Prediction endpoint: sends image data
- Flask routes → Prediction endpoint: routes prediction (evidence: `app.py`)
- Prediction endpoint → Image preprocessing: calls prediction (evidence: `app.py`)
- Image preprocessing → Symbol classifier: predicts image (evidence: `app.py`)
- Symbol classifier → Model definition: loads architecture (evidence: `app.py`)
- Symbol classifier → Model weights: loads weights (evidence: `app.py`)
- Prediction endpoint → User: returns JSON (evidence: `app.py`)
