# ali-m07/mirrorfit architecture

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

- Interactive diagram: https://gitdiagram.com/ali-m07/mirrorfit
- Repository: https://github.com/ali-m07/mirrorfit

## Overview

MirrorFit is a webcam-based virtual try-on platform, exposed both as a desktop kiosk and an HTTP/WebSocket service. A shopper starts a session, the engine captures frames, estimates and smooths pose, fits a catalog garment, optionally replaces the background, then publishes the composed view; controls also support garment changes, modes, and capture. Session state tracks duration and engagement. The README documents both web demos, studio modes, and image/OBJ garments. Pipeline and route details are supported by sampled source; some API wiring and UI behavior are described by the README rather than inspected source.

Main entry points: [`src/core/tryon_engine.py`](https://github.com/ali-m07/mirrorfit/blob/main/src/core/tryon_engine.py) (Try-on engine), [`src/api/routes.py`](https://github.com/ali-m07/mirrorfit/blob/main/src/api/routes.py) (API routes), [`api_server.py`](https://github.com/ali-m07/mirrorfit/blob/main/api_server.py) (API service), [`src/utils/helpers.py`](https://github.com/ali-m07/mirrorfit/blob/main/src/utils/helpers.py) (Garment catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["User entrypoints"]
  node_desktop["Kiosk app<br/>[main.py]"]
  node_api_service["API service<br/>[api_server.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_contracts["API schemas<br/>[schemas.py]"]
  node_web_demo["Browser demo<br/>[index.html]"]
  node_streamlit["Streamlit demo<br/>[streamlit_app.py]"]
end

subgraph group_pipeline["Try-on pipeline"]
  node_engine["Try-on engine<br/>[tryon_engine.py]"]
  node_webcam["Webcam capture<br/>[webcam.py]"]
  node_pose["Pose tracking<br/>[pose_estimator.py]"]
  node_segmenter["Studio segmentation<br/>[segmenter.py]"]
  node_renderer["Garment renderer"]
  node_overlay["Kiosk overlay<br/>[overlay.py]"]
end

subgraph group_domain["Session and catalog"]
  node_sessions["Session analytics<br/>[session_manager.py]"]
  node_catalog["Garment catalog<br/>[helpers.py]"]
  node_garments["Garment assets<br/>[catalog.json]"]
  node_config["Runtime configuration<br/>[config_loader.py]"]
end

subgraph group_delivery["Streaming and capture"]
  node_outputs["Screenshots and recordings"]
end

node_shopper(("Shopper / operator"))
node_api_clients(("Embedded API clients"))
node_camera_device(("Webcam"))

node_shopper -->|"controls"| node_desktop
node_shopper -->|"uses"| node_web_demo
node_shopper -->|"uses"| node_streamlit
node_api_clients -->|"sends requests"| node_api_service
node_web_demo -->|"calls API"| node_api_service
node_streamlit -->|"calls API"| node_api_service
node_api_service -->|"dispatches"| node_routes
node_routes -->|"uses schemas"| node_contracts
node_desktop -->|"controls"| node_engine
node_routes -->|"controls and queries"| node_engine
node_engine -->|"reads frames"| node_webcam
node_camera_device -->|"provides video"| node_webcam
node_engine -->|"estimates pose"| node_pose
node_engine -->|"segments background"| node_segmenter
node_engine -->|"renders garment"| node_renderer
node_engine -->|"selects and loads"| node_catalog
node_catalog -->|"reads assets"| node_garments
node_routes -->|"updates or reloads"| node_catalog
node_engine -->|"tracks session"| node_sessions
node_engine -->|"draws kiosk HUD"| node_overlay
node_engine -->|"uses settings"| node_config
node_engine -->|"writes captures"| node_outputs
node_routes -->|"returns capture paths"| node_outputs
node_engine -->|"publishes frames"| node_routes

click node_desktop "https://github.com/ali-m07/mirrorfit/blob/main/main.py"
click node_api_service "https://github.com/ali-m07/mirrorfit/blob/main/api_server.py"
click node_routes "https://github.com/ali-m07/mirrorfit/blob/main/src/api/routes.py"
click node_contracts "https://github.com/ali-m07/mirrorfit/blob/main/src/api/schemas.py"
click node_web_demo "https://github.com/ali-m07/mirrorfit/blob/main/web/index.html"
click node_streamlit "https://github.com/ali-m07/mirrorfit/blob/main/streamlit_app.py"
click node_engine "https://github.com/ali-m07/mirrorfit/blob/main/src/core/tryon_engine.py"
click node_webcam "https://github.com/ali-m07/mirrorfit/blob/main/src/camera/webcam.py"
click node_pose "https://github.com/ali-m07/mirrorfit/blob/main/src/vision/pose_estimator.py"
click node_segmenter "https://github.com/ali-m07/mirrorfit/blob/main/src/vision/segmenter.py"
click node_renderer "https://github.com/ali-m07/mirrorfit/blob/main/src/vision/clothing_renderer.py"
click node_overlay "https://github.com/ali-m07/mirrorfit/blob/main/src/ui/overlay.py"
click node_sessions "https://github.com/ali-m07/mirrorfit/blob/main/src/core/session_manager.py"
click node_catalog "https://github.com/ali-m07/mirrorfit/blob/main/src/utils/helpers.py"
click node_garments "https://github.com/ali-m07/mirrorfit/blob/main/assets/clothes/catalog.json"
click node_config "https://github.com/ali-m07/mirrorfit/blob/main/src/utils/config_loader.py"
click node_outputs "https://github.com/ali-m07/mirrorfit/tree/main/output"

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_desktop,node_api_service,node_routes,node_contracts,node_web_demo,node_streamlit,node_api_clients toneBlue
class node_engine,node_webcam,node_pose,node_segmenter,node_renderer,node_overlay toneAmber
class node_sessions,node_catalog,node_garments,node_config toneMint
class node_outputs toneRose
class node_shopper,node_camera_device toneIndigo
```

## Components

### User entrypoints

- [Kiosk app](https://github.com/ali-m07/mirrorfit/blob/main/main.py): `main.py`
- [API service](https://github.com/ali-m07/mirrorfit/blob/main/api_server.py): `api_server.py`
- [API routes](https://github.com/ali-m07/mirrorfit/blob/main/src/api/routes.py): `src/api/routes.py`
- [API schemas](https://github.com/ali-m07/mirrorfit/blob/main/src/api/schemas.py): `src/api/schemas.py`
- [Browser demo](https://github.com/ali-m07/mirrorfit/blob/main/web/index.html): `web/index.html`
- [Streamlit demo](https://github.com/ali-m07/mirrorfit/blob/main/streamlit_app.py): `streamlit_app.py`

### Try-on pipeline

- [Try-on engine](https://github.com/ali-m07/mirrorfit/blob/main/src/core/tryon_engine.py): `src/core/tryon_engine.py`
- [Webcam capture](https://github.com/ali-m07/mirrorfit/blob/main/src/camera/webcam.py): `src/camera/webcam.py`
- [Pose tracking](https://github.com/ali-m07/mirrorfit/blob/main/src/vision/pose_estimator.py): `src/vision/pose_estimator.py`
- [Studio segmentation](https://github.com/ali-m07/mirrorfit/blob/main/src/vision/segmenter.py): `src/vision/segmenter.py`
- [Garment renderer](https://github.com/ali-m07/mirrorfit/blob/main/src/vision/clothing_renderer.py): `src/vision/clothing_renderer.py`
- [Kiosk overlay](https://github.com/ali-m07/mirrorfit/blob/main/src/ui/overlay.py): `src/ui/overlay.py`

### Session and catalog

- [Session analytics](https://github.com/ali-m07/mirrorfit/blob/main/src/core/session_manager.py): `src/core/session_manager.py`
- [Garment catalog](https://github.com/ali-m07/mirrorfit/blob/main/src/utils/helpers.py): `src/utils/helpers.py`
- [Garment assets](https://github.com/ali-m07/mirrorfit/blob/main/assets/clothes/catalog.json): `assets/clothes/catalog.json`
- [Runtime configuration](https://github.com/ali-m07/mirrorfit/blob/main/src/utils/config_loader.py): `src/utils/config_loader.py`

### Streaming and capture

- [Screenshots and recordings](https://github.com/ali-m07/mirrorfit/tree/main/output): `output`

### Other components

- **Shopper / operator**
- **Embedded API clients**
- **Webcam**

## Connections

- Shopper / operator → Kiosk app: controls
- Shopper / operator → Browser demo: uses
- Shopper / operator → Streamlit demo: uses
- Embedded API clients → API service: sends requests
- Browser demo → API service: calls API
- Streamlit demo → API service: calls API
- API service → API routes: dispatches
- API routes → API schemas: uses schemas
- Kiosk app → Try-on engine: controls
- API routes → Try-on engine: controls and queries
- Try-on engine → Webcam capture: reads frames
- Webcam → Webcam capture: provides video
- Try-on engine → Pose tracking: estimates pose
- Try-on engine → Studio segmentation: segments background
- Try-on engine → Garment renderer: renders garment
- Try-on engine → Garment catalog: selects and loads
- Garment catalog → Garment assets: reads assets
- API routes → Garment catalog: updates or reloads
- Try-on engine → Session analytics: tracks session
- Try-on engine → Kiosk overlay: draws kiosk HUD
- Try-on engine → Runtime configuration: uses settings
- Try-on engine → Screenshots and recordings: writes captures
- API routes → Screenshots and recordings: returns capture paths
- Try-on engine → API routes: publishes frames
