# movenb3at/snap-pocket architecture

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

- Interactive diagram: https://gitdiagram.com/movenb3at/snap-pocket
- Repository: https://github.com/movenb3at/snap-pocket

## Overview

SnapPocket is a Flask-based AI photobooth: a browser captures a photo, selects a transformation, polls queued processing, then finalizes and delivers a framed or unframed image by QR/download. It also provides coin controls and a protected admin dashboard. The README documents local YOLO/OpenCV filters, Stable Diffusion, folder monitoring, and Cloudflare access; the sampled backend excerpt confirms some processing and coin/finalization behavior, but not route wiring or most integrations, so those links are omitted rather than inferred.

Main entry points: [`templates/index.html`](https://github.com/movenb3at/snap-pocket/blob/main/templates/index.html) (Capture UI), [`app.py`](https://github.com/movenb3at/snap-pocket/blob/main/app.py) (Flask API), [`public`](https://github.com/movenb3at/snap-pocket/tree/main/public) (Final images), [`templates/download.html`](https://github.com/movenb3at/snap-pocket/blob/main/templates/download.html) (Photo download)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Capture and delivery"]
  node_camera["Capture UI<br/>[index.html]"]
  node_motion["UI motion<br/>[pocket-motion.js]"]
  node_download["Photo download<br/>[download.html]"]
end

subgraph group_backend["Application services"]
  node_api["Flask API<br/>[app.py]"]
  node_coins[("Device coin state<br/>[app.py]")]
  node_jobs["Queued processing<br/>[app.py]"]
  node_status["Task status<br/>[app.py]"]
  node_finalize["Finalize and QR<br/>[app.py]"]
end

subgraph group_processing["Image processing"]
  node_raw[("Captured images")]
  node_localfilters["Local filters<br/>[app.py]"]
  node_mosaicmodel[("YOLO weights")]
  node_frames["Photo framing<br/>[app.py]"]
  node_previews[("Transform previews")]
  node_finalimages[("Final images")]
  node_qrfiles[("QR images")]
end

subgraph group_operations["Operations and access"]
  node_admin["Admin dashboard<br/>[admin.html]"]
  node_watch["Folder monitoring<br/>[app.py]"]
end

node_guest(("Camera guest"))
node_stable["Stable Diffusion"]
node_tunnel["Cloudflare tunnel"]

node_guest -->|"captures with"| node_camera
node_camera -->|"uploads to"| node_api
node_api -->|"tracks balances"| node_coins
node_api -.->|"stores capture"| node_raw
node_api -->|"queues work"| node_jobs
node_jobs -->|"runs img2img"| node_stable
node_jobs -->|"runs local filters"| node_localfilters
node_localfilters -->|"loads face weights"| node_mosaicmodel
node_jobs -->|"writes previews"| node_previews
node_camera -->|"polls task"| node_status
node_status -->|"returns state"| node_camera
node_camera -->|"requests finalization"| node_finalize
node_finalize -->|"applies optional frame"| node_frames
node_finalize -->|"writes image"| node_finalimages
node_finalize -->|"generates QR"| node_qrfiles
node_finalimages -->|"serves attachment"| node_download
node_guest -->|"scans QR"| node_download
node_admin -->|"manages devices"| node_api
node_api -->|"monitors folders"| node_watch
node_guest -.->|"accesses remotely"| node_tunnel
node_camera -.->|"animates controls"| node_motion

click node_camera "https://github.com/movenb3at/snap-pocket/blob/main/templates/index.html"
click node_motion "https://github.com/movenb3at/snap-pocket/blob/main/static/pocket-motion.js"
click node_download "https://github.com/movenb3at/snap-pocket/blob/main/templates/download.html"
click node_api "https://github.com/movenb3at/snap-pocket/blob/main/app.py"
click node_coins "https://github.com/movenb3at/snap-pocket/blob/main/app.py"
click node_jobs "https://github.com/movenb3at/snap-pocket/blob/main/app.py"
click node_status "https://github.com/movenb3at/snap-pocket/blob/main/app.py"
click node_finalize "https://github.com/movenb3at/snap-pocket/blob/main/app.py"
click node_raw "https://github.com/movenb3at/snap-pocket/tree/main/temp"
click node_localfilters "https://github.com/movenb3at/snap-pocket/blob/main/app.py"
click node_mosaicmodel "https://github.com/movenb3at/snap-pocket/tree/main/models/mosaic"
click node_frames "https://github.com/movenb3at/snap-pocket/blob/main/app.py"
click node_previews "https://github.com/movenb3at/snap-pocket/tree/main/static/preview"
click node_finalimages "https://github.com/movenb3at/snap-pocket/tree/main/public"
click node_qrfiles "https://github.com/movenb3at/snap-pocket/tree/main/static/qr"
click node_admin "https://github.com/movenb3at/snap-pocket/blob/main/templates/admin.html"
click node_watch "https://github.com/movenb3at/snap-pocket/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_camera,node_motion,node_download toneBlue
class node_api,node_coins,node_jobs,node_status,node_finalize toneAmber
class node_raw,node_localfilters,node_mosaicmodel,node_frames,node_previews,node_finalimages,node_qrfiles toneMint
class node_admin,node_watch toneRose
class node_guest,node_stable,node_tunnel toneIndigo
```

## Components

### Capture and delivery

- [Capture UI](https://github.com/movenb3at/snap-pocket/blob/main/templates/index.html): `templates/index.html`
- [UI motion](https://github.com/movenb3at/snap-pocket/blob/main/static/pocket-motion.js): `static/pocket-motion.js`
- [Photo download](https://github.com/movenb3at/snap-pocket/blob/main/templates/download.html): `templates/download.html`

### Application services

- [Flask API](https://github.com/movenb3at/snap-pocket/blob/main/app.py): `app.py`
- [Device coin state](https://github.com/movenb3at/snap-pocket/blob/main/app.py): `app.py`
- [Queued processing](https://github.com/movenb3at/snap-pocket/blob/main/app.py): `app.py`
- [Task status](https://github.com/movenb3at/snap-pocket/blob/main/app.py): `app.py`
- [Finalize and QR](https://github.com/movenb3at/snap-pocket/blob/main/app.py): `app.py`

### Image processing

- [Captured images](https://github.com/movenb3at/snap-pocket/tree/main/temp): `temp`
- [Local filters](https://github.com/movenb3at/snap-pocket/blob/main/app.py): `app.py`
- [YOLO weights](https://github.com/movenb3at/snap-pocket/tree/main/models/mosaic): `models/mosaic`
- [Photo framing](https://github.com/movenb3at/snap-pocket/blob/main/app.py): `app.py`
- [Transform previews](https://github.com/movenb3at/snap-pocket/tree/main/static/preview): `static/preview`
- [Final images](https://github.com/movenb3at/snap-pocket/tree/main/public): `public`
- [QR images](https://github.com/movenb3at/snap-pocket/tree/main/static/qr): `static/qr`

### Operations and access

- [Admin dashboard](https://github.com/movenb3at/snap-pocket/blob/main/templates/admin.html): `templates/admin.html`
- [Folder monitoring](https://github.com/movenb3at/snap-pocket/blob/main/app.py): `app.py`

### Other components

- **Camera guest**
- **Stable Diffusion**
- **Cloudflare tunnel**

## Connections

- Camera guest → Capture UI: captures with (evidence: `README.md`)
- Capture UI → Flask API: uploads to (evidence: `README.md`)
- Flask API → Device coin state: tracks balances (evidence: `app.py`)
- Flask API → Captured images: stores capture
- Flask API → Queued processing: queues work (evidence: `README.md`)
- Queued processing → Stable Diffusion: runs img2img (evidence: `README.md`)
- Queued processing → Local filters: runs local filters (evidence: `README.md`)
- Local filters → YOLO weights: loads face weights (evidence: `README.md`)
- Queued processing → Transform previews: writes previews (evidence: `README.md`)
- Capture UI → Task status: polls task (evidence: `README.md`)
- Task status → Capture UI: returns state (evidence: `README.md`)
- Capture UI → Finalize and QR: requests finalization (evidence: `README.md`)
- Finalize and QR → Photo framing: applies optional frame (evidence: `app.py`)
- Finalize and QR → Final images: writes image (evidence: `README.md`)
- Finalize and QR → QR images: generates QR (evidence: `README.md`)
- Final images → Photo download: serves attachment (evidence: `README.md`)
- Camera guest → Photo download: scans QR (evidence: `README.md`)
- Admin dashboard → Flask API: manages devices (evidence: `README.md`)
- Flask API → Folder monitoring: monitors folders (evidence: `README.md`)
- Camera guest → Cloudflare tunnel: accesses remotely
- Capture UI → UI motion: animates controls
