How joshika-06/gestureflow works
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 Flask app · landing.js Landing JS · canvas.js Canvas JS · canvas.html Canvas view
Components 16
Browser UI
Landing flow, canvas screen, and client-side controls.
- Index view · Onboarding and picker template for the landing flow.
templates/index.html - Canvas view · Dual-panel drawing interface template.
templates/canvas.html - Landing JS · Animated onboarding, picker handling, and pre-canvas configuration.
static/js/landing.js - Canvas JS · Topbar controls, settings panel, stream reconnects, and live session updates.
static/js/canvas.js - Landing CSS · Styling for the onboarding screen.
static/css/landing.css - Canvas CSS · Styling for the drawing interface.
static/css/canvas.css
Flask Backend
Single Python process that handles vision, drawing state, routes, and streaming.
- Flask app · Main Flask process; owns routes, vision pipeline, drawing state, and stream responses.
app.py - Webcam · Local live video source consumed by the backend.
- Hand tracking · MediaPipe/OpenCV landmark detection over incoming frames.
app.py - Gesture logic · Translates finger states into draw, color-select, and pause actions.
app.py - Drawing state · Server-owned canvas state and current pen/color configuration.
app.py - Video stream · Live camera preview with overlays and board output for the canvas page.
app.py - Landing page · Entry screen that starts the onboarding and configuration flow.
app.py - Canvas page · Main drawing screen that presents the live stream and controls.
app.py - Config API · Backend endpoints for color and session updates from the browser.
app.py
Deployment
Process/runtime entrypoint for hosted execution.
- Procfile · PaaS process entrypoint using gunicorn.
Procfile
Connections 21
- 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.