# joshika-06/gestureflow architecture

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

- Interactive diagram: https://gitdiagram.com/joshika-06/gestureflow
- Repository: https://github.com/joshika-06/gestureflow

## Overview

1. **High-level shape**  
   This is a **single Flask application** that combines a Python computer-vision backend with a browser-based UI. The architecture is not split into separate services: `app.py` serves pages, owns the camera/gesture pipeline, and exposes the drawing stream and config endpoints.

2. **Backend as the system core**  
   `app.py` is the main subsystem. It likely contains:
   - Flask routes for the landing page and canvas page
   - a webcam capture loop
   - MediaPipe-based hand/gesture detection
   - drawing state management for the board
   - an MJPEG or similar streaming response for the live camera preview
   - API endpoints for changing colors/settings from the UI

3. **Browser UI split into two screens**  
   The front end is divided into two HTML templates:
   - `templates/index.html`: onboarding / splash / picker flow
   - `templates/canvas.html`: the actual dual-panel drawing interface  
   This makes the UX a staged flow: configure first, then enter the live canvas.

4. **Static client assets are simple and self-contained**  
   There is no build pipeline or SPA framework. The UI is implemented with:
   - `static/css/landing.css` and `static/js/landing.js`
   - `static/css/canvas.css` and `static/js/canvas.js`  
   This means rendering and interaction logic live in plain browser assets, with Flask only serving them.

5. **Gesture-to-drawing pipeline**  
   The main data flow is: **webcam frames → hand landmark detection → gesture interpretation → drawing actions**.  
   The readme defines the gesture contract:
   - index finger up = draw
   - index + middle finger up = color select
   - fist = pause/reposition  
   This gesture layer is the architectural boundary between physical input and canvas state.

6. **Dual-panel visualization model**  
   The canvas page presents two views of the same session:
   - a **live webcam panel with overlays**
   - a **board-only clean preview**  
   Architecturally, this means the backend is producing or composing two visual outputs from the same underlying drawing state.

7. **Configuration flow from landing to canvas**  
   `landing.js` is responsible for the animated onboarding experience and the color picker flow. It pushes the chosen board and pen configuration into the backend before the user enters the drawing screen. That makes the landing page a setup phase rather than just a marketing page.

8. **Runtime interaction on the canvas page**  
   `canvas.js` manages live UI controls such as:
   - topbar color chips
   - settings panel
   - MJPEG reconnect behavior  
   This suggests the browser actively maintains the stream connection and can update session settings without a full page reload.

9. **State boundary: server-owned drawing session**  
   The drawing board appears to live on the server side rather than purely in the browser. That matters because:
   - camera input is local hardware input
   - drawing state must persist across streamed frames
   - palette/pen settings must be shared with the backend gesture engine  
   In other words, the browser is a control and display surface; the Python process is the source of truth.

10. **Technology constraints that affect deployment**  
   The repo depends on **Flask**, **OpenCV**, and **MediaPipe**. The readme notes Python 3.9–3.11 because MediaPipe is version-sensitive. The webcam requirement also means this is best run on a machine with real camera access; cloud deployment is possible only if camera access is available on the host.

11. **Deployment model**  
   `Procfile` indicates PaaS-style deployment support such as Render or Railway, with `gunicorn` as the web server. Even so, the app is still architecturally a stateful camera application, not a stateless web API.

12. **What to draw in an architecture diagram**  
   The diagram should show:
   - browser landing page → config selection → canvas page
   - Flask app as the central backend
   - webcam input feeding the vision pipeline
   - gesture detection producing draw/select/pause actions
   - server-side board state feeding the streamed canvas views
   - client JS handling UI controls and reconnect/config updates  
   The main boundary is between **physical camera + vision processing** on the server and **interactive presentation** in the browser.

Main entry points: [`app.py`](https://github.com/joshika-06/gestureflow/blob/main/app.py) (Flask app), [`static/js/landing.js`](https://github.com/joshika-06/gestureflow/blob/main/static/js/landing.js) (Landing JS), [`static/js/canvas.js`](https://github.com/joshika-06/gestureflow/blob/main/static/js/canvas.js) (Canvas JS), [`templates/canvas.html`](https://github.com/joshika-06/gestureflow/blob/main/templates/canvas.html) (Canvas view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser UI"]
  node_index_html["Index view<br/>template<br/>[index.html]"]
  node_canvas_html["Canvas view<br/>template<br/>[canvas.html]"]
  node_landing_js["Landing JS<br/>client script<br/>[landing.js]"]
  node_canvas_js["Canvas JS<br/>client script<br/>[canvas.js]"]
  node_landing_css["Landing CSS<br/>styles<br/>[landing.css]"]
  node_canvas_css["Canvas CSS<br/>styles<br/>[canvas.css]"]
end

subgraph group_server["Flask Backend"]
  node_app["Flask app<br/>backend core<br/>[app.py]"]
  node_webcam(("Webcam<br/>camera input"))
  node_vision{{"Hand tracking<br/>cv pipeline<br/>[app.py]"}}
  node_gestures{{"Gesture logic<br/>input mapping<br/>[app.py]"}}
  node_board[("Drawing state<br/>session state<br/>[app.py]")]
  node_stream["Video stream<br/>mjpeg response<br/>[app.py]"]
  node_landing_route["Landing page<br/>flask route<br/>[app.py]"]
  node_canvas_route["Canvas page<br/>flask route<br/>[app.py]"]
  node_config_api["Config API<br/>settings endpoint<br/>[app.py]"]
end

subgraph group_deploy["Deployment"]
  node_procfile["Procfile<br/>runtime entry"]
end

node_procfile -->|"starts"| node_app
node_app -->|"serves"| node_landing_route
node_app -->|"serves"| node_canvas_route
node_landing_route -->|"renders"| node_index_html
node_canvas_route -->|"renders"| node_canvas_html
node_landing_route -->|"loads"| node_landing_css
node_landing_route -->|"loads"| node_landing_js
node_canvas_route -->|"loads"| node_canvas_css
node_canvas_route -->|"loads"| node_canvas_js
node_landing_js -->|"submits config"| node_config_api
node_landing_js -->|"navigates"| node_canvas_route
node_canvas_js -->|"updates settings"| node_config_api
node_canvas_js -->|"reconnects"| node_stream
node_webcam -->|"feeds video"| node_app
node_app -->|"processes frames"| node_vision
node_vision -->|"interprets"| node_gestures
node_gestures -->|"mutates"| node_board
node_config_api -->|"updates"| node_board
node_board -->|"renders"| node_stream
node_app -->|"exposes"| node_stream
node_stream -->|"displays on"| node_canvas_html

click node_app "https://github.com/joshika-06/gestureflow/blob/main/app.py"
click node_vision "https://github.com/joshika-06/gestureflow/blob/main/app.py"
click node_gestures "https://github.com/joshika-06/gestureflow/blob/main/app.py"
click node_board "https://github.com/joshika-06/gestureflow/blob/main/app.py"
click node_stream "https://github.com/joshika-06/gestureflow/blob/main/app.py"
click node_landing_route "https://github.com/joshika-06/gestureflow/blob/main/app.py"
click node_canvas_route "https://github.com/joshika-06/gestureflow/blob/main/app.py"
click node_config_api "https://github.com/joshika-06/gestureflow/blob/main/app.py"
click node_index_html "https://github.com/joshika-06/gestureflow/blob/main/templates/index.html"
click node_canvas_html "https://github.com/joshika-06/gestureflow/blob/main/templates/canvas.html"
click node_landing_js "https://github.com/joshika-06/gestureflow/blob/main/static/js/landing.js"
click node_canvas_js "https://github.com/joshika-06/gestureflow/blob/main/static/js/canvas.js"
click node_landing_css "https://github.com/joshika-06/gestureflow/blob/main/static/css/landing.css"
click node_canvas_css "https://github.com/joshika-06/gestureflow/blob/main/static/css/canvas.css"
click node_procfile "https://github.com/joshika-06/gestureflow/tree/main/Procfile"

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_index_html,node_canvas_html,node_landing_js,node_canvas_js,node_landing_css,node_canvas_css toneBlue
class node_app,node_webcam,node_vision,node_gestures,node_board,node_stream,node_landing_route,node_canvas_route,node_config_api toneAmber
class node_procfile toneMint
```

## Components

### Browser UI

Landing flow, canvas screen, and client-side controls.

- [Index view](https://github.com/joshika-06/gestureflow/blob/main/templates/index.html): template · Onboarding and picker template for the landing flow. · `templates/index.html`
- [Canvas view](https://github.com/joshika-06/gestureflow/blob/main/templates/canvas.html): template · Dual-panel drawing interface template. · `templates/canvas.html`
- [Landing JS](https://github.com/joshika-06/gestureflow/blob/main/static/js/landing.js): client script · Animated onboarding, picker handling, and pre-canvas configuration. · `static/js/landing.js`
- [Canvas JS](https://github.com/joshika-06/gestureflow/blob/main/static/js/canvas.js): client script · Topbar controls, settings panel, stream reconnects, and live session updates. · `static/js/canvas.js`
- [Landing CSS](https://github.com/joshika-06/gestureflow/blob/main/static/css/landing.css): styles · Styling for the onboarding screen. · `static/css/landing.css`
- [Canvas CSS](https://github.com/joshika-06/gestureflow/blob/main/static/css/canvas.css): styles · Styling for the drawing interface. · `static/css/canvas.css`

### Flask Backend

Single Python process that handles vision, drawing state, routes, and streaming.

- [Flask app](https://github.com/joshika-06/gestureflow/blob/main/app.py): backend core · Main Flask process; owns routes, vision pipeline, drawing state, and stream responses. · `app.py`
- **Webcam**: camera input · Local live video source consumed by the backend.
- [Hand tracking](https://github.com/joshika-06/gestureflow/blob/main/app.py): cv pipeline · MediaPipe/OpenCV landmark detection over incoming frames. · `app.py`
- [Gesture logic](https://github.com/joshika-06/gestureflow/blob/main/app.py): input mapping · Translates finger states into draw, color-select, and pause actions. · `app.py`
- [Drawing state](https://github.com/joshika-06/gestureflow/blob/main/app.py): session state · Server-owned canvas state and current pen/color configuration. · `app.py`
- [Video stream](https://github.com/joshika-06/gestureflow/blob/main/app.py): mjpeg response · Live camera preview with overlays and board output for the canvas page. · `app.py`
- [Landing page](https://github.com/joshika-06/gestureflow/blob/main/app.py): flask route · Entry screen that starts the onboarding and configuration flow. · `app.py`
- [Canvas page](https://github.com/joshika-06/gestureflow/blob/main/app.py): flask route · Main drawing screen that presents the live stream and controls. · `app.py`
- [Config API](https://github.com/joshika-06/gestureflow/blob/main/app.py): settings endpoint · Backend endpoints for color and session updates from the browser. · `app.py`

### Deployment

Process/runtime entrypoint for hosted execution.

- [Procfile](https://github.com/joshika-06/gestureflow/tree/main/Procfile): runtime entry · PaaS process entrypoint using gunicorn. · `Procfile`

## Connections

- Procfile → Flask app: starts · Launches the Flask application process.
- Flask app → Landing page: serves · Routes the landing page request.
- Flask app → Canvas page: serves · Routes the canvas page request.
- Landing page → Index view: renders · Landing route returns the onboarding template.
- Canvas page → Canvas view: renders · Canvas route returns the drawing template.
- Landing page → Landing CSS: loads · Landing page uses its stylesheet.
- Landing page → Landing JS: loads · Landing page uses its browser logic.
- Canvas page → Canvas CSS: loads · Canvas page uses its stylesheet.
- Canvas page → Canvas JS: loads · Canvas page uses its browser logic.
- Landing JS → Config API: submits config · Sends selected board/pen settings before entering the canvas.
- Landing JS → Canvas page: navigates · Transitions the user from onboarding to the drawing screen.
- Canvas JS → Config API: updates settings · Changes colors and session controls without reloading.
- Canvas JS → Video stream: reconnects · Maintains the live stream connection from the browser.
- Webcam → Flask app: feeds video · Camera input enters the server process.
- Flask app → Hand tracking: processes frames · Runs frame analysis for hand landmarks.
- Hand tracking → Gesture logic: interprets · Converts landmarks into gesture states.
- Gesture logic → Drawing state: mutates · Applies draw, select, and pause actions to session state.
- Config API → Drawing state: updates · Writes chosen colors and board settings into shared state.
- Drawing state → Video stream: renders · Board state is composed into the live visual output.
- Flask app → Video stream: exposes · Serves the camera/board stream endpoint.
- Video stream → Canvas view: displays on · The canvas template embeds the live preview.
