Skip to content
←Return to Projects
Case Study

AR Smart Mirror

Real-time interactive AR virtual try-on system designed for retail fashion.

The Problem

In-store clothing fitting is slow, creates long queues in fitting rooms, and increases garment wear. Retailers need an instant, hygienic, and engaging digital mirror that lets shoppers visualize outfits without undressing.

My Role

Built solo with AI-assisted development — computer vision pipeline design, MediaPipe pose detection integration, Canvas AR overlay engine, FastAPI backend services, Docker multi-container topology, and Cloudflare Zero Trust ingress.

Highlights

  • Sub-30ms real-time body tracking and landmark extraction using MediaPipe Pose
  • Dynamic Canvas AR garment warping and affine transformation for realistic clothing drape
  • FastAPI backend with PostgreSQL catalog and Redis session pub/sub synchronization
  • Mobile controller pairing allowing customers to browse catalogs and trigger try-ons from their smartphones
  • Production-grade Docker Compose architecture with Nginx reverse proxy and Cloudflare Tunnel

Stack

Python 3.11FastAPIMediaPipeHTML5 CanvasPostgreSQL 15Redis 7DockerNginx

Constraints

  • Hard real-time latency target (<33ms per frame / 30 FPS) to avoid motion sickness and visual lag.
  • Zero customer biometric persistence — video feeds must process in memory without saving raw footage to disk.
  • Compatibility with standard consumer hardware (e.g. RTX 3060) without requiring specialized depth cameras.

System Architecture

Capture & Client
Webcam Feed
MediaPipe Pose (Client A)
Mobile Controller (Client B)
Edge & Ingress
Cloudflare Tunnel
Nginx Reverse Proxy
SSL Termination
Application Services
FastAPI Gateway (:8000)
Garment Overlay Service
WebSocket Pub/Sub
Data & Storage
PostgreSQL 15 (Catalog/Users)
Redis 7 (Session Sync)
Local Volume Storage
Telemetry
Prometheus
Grafana Monitoring (:3000)

Key Trade-offs

The decisions worth defending — what I chose, what I turned down, and why.

Pose tracking execution model

Chose

Client-side MediaPipe Pose on Canvas API with GPU acceleration

Rejected

Server-side video streaming and frame-by-frame inference

Server inference introduces network jitter, high bandwidth overhead, and privacy concerns streaming raw camera feeds over the network.

Garment deformation approach

Chose

Real-time 2D affine mesh deformation keyed to skeletal anchor landmarks

Rejected

Full 3D physics-based volumetric cloth simulation

3D cloth simulation cannot sustain 30+ FPS on edge kiosk hardware; 2D mesh triangulation provides fluid response with low computational cost.

Remote store interconnect

Chose

Cloudflare Tunnel over outbound HTTPS

Rejected

Direct port forwarding and dynamic DNS on store routers

Retail store Wi-Fi and ISP firewalls prevent inbound port forwarding; Cloudflare Tunnels punch through NAT securely without public IPs.

What I'd Do Differently

An honest retrospective — the stuff I'd change with more time, more users, or a second pass.

  1. 1Implement WebGPU shaders for cloth lighting and shadow blending to improve realism under dynamic store lighting.
  2. 2Add an offline fallback queue for store analytics so telemetry buffers locally during internet interruptions.
  3. 3Optimize landmark smoothing filters (OneEuro filter) to eliminate micro-jitter when shoppers stand at edge distances.

Computer Vision & Pose Tracking Shell

Benchmark the real-time AR try-on pipeline (status, camera init, pose detect, mesh align -shirt, latency bench).

icelegends-interactive-shell ~ [armirror]
History: ↑ / ↓
cv-engine@ar-mirror:~/pipeline$

Technical Deep-Dive

Architecture, specifications, and implementation details.

05 — Docker Compose Configuration

#Full docker-compose.yml

version: '3.9'

services:

  ar-frontend:
    image: nginx:alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./frontend:/usr/share/nginx/html:ro
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
    depends_on:
      - ar-api
    restart: unless-stopped

  ar-api:
    build: ./backend
    ports:
      - "8000:8000"
    env_file: .env
    depends_on:
      ar-db:
        condition: service_healthy
      ar-cache:
        condition: service_started
    volumes:
      - ar_garments:/app/garments
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
    restart: unless-stopped

  ar-pose:
    build:
      context: ./backend
      dockerfile: Dockerfile.pose
    ports:
      - "8001:8001"
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
    restart: unless-stopped

  ar-db:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: armirror
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ${DB_PASS}
    volumes:
      - ar_postgres:/var/lib/postgresql/data
      - ./docs/04_PostgreSQL_Schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro
    healthcheck:
      test: ["CMD-SHELL","pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  ar-cache:
    image: redis:7-alpine
    command: redis-server --appendonly yes --requirepass ${REDIS_PASS}
    volumes:
      - ar_redis:/data
    restart: unless-stopped

  ar-monitor:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    environment:
      GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASS}
    volumes:
      - ar_grafana:/var/lib/grafana
      - ./monitoring/grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
    restart: unless-stopped

volumes:
  ar_postgres:
  ar_redis:
  ar_garments:
  ar_grafana:

#.env.example

DB_PASS=change_this_strong_password
REDIS_PASS=change_this_redis_pass
JWT_SECRET=change_this_jwt_secret_min_32_chars
ADMIN_PASSWORD=change_this_admin_pass
GRAFANA_PASS=change_this_grafana_pass
API_VERSION=v1
LOG_LEVEL=INFO
CORS_ORIGINS=http://localhost,https://your-tunnel.yourdomain.com

#Common Commands

# Start all services
docker compose up -d

# Check status
docker compose ps

# View logs
docker compose logs -f ar-api

# Stop all
docker compose down

# Rebuild after code changes
docker compose up -d --build ar-api

# Open PostgreSQL shell
docker exec -it ar-db psql -U postgres -d armirror

# Check GPU inside container
docker exec ar-pose nvidia-smi
~ End of Document ~