Engineering Magic Mirror: Real-Time AI Video Streaming on the Shop Floor

  • Next.js
  • TypeScript
  • Node.js
  • WebSockets
  • WebRTC
  • Lucy-VTON

Modern e-commerce offers instant inventory lookup, personalised recommendations, and dynamic media. Physical retail, by contrast, is hard-bounded by floor space, local inventory, and fitting room friction.

To solve this gap without introducing heavy, high-maintenance hardware to physical stores, I engineered Magic Mirror. A zero-install, dual-screen system that lets shoppers virtually try on full online catalogues in real time using a kiosk screen and their own smartphone.

Here is an architectural breakdown of how I built the platform, managed low-latency state synchronisation across devices, and integrated real-time generative video models into a production retail stack.

System Architecture & State Synchronisation

The core challenge was creating a seamless, low-latency link between two distinct hardware targets: an unattended, public-facing kiosk display (the "Mirror") and an unauthenticated, personal mobile device (the "Controller").

Architectural Data Flow

Data Flow Diagram

Key Engineering Decisions

AI Pipeline & Real-Time Video Processing

Rendering virtual garments onto a live camera feed requires high-throughput, sub-second inference pipelines.

Security, Lifecycle & Edge Edge-Case Management

Operating software in public spaces requires strict session boundary management:

Key Technical Takeaways

Building Magic Mirror highlighted several core principles about deploying interactive systems in physical environments:

  1. Decouple Compute from Hardware: Moving the interactive logic to the user’s personal phone eliminated the need for expensive, high-maintenance shop-floor touchscreens.
  2. Real-Time WebSockets Over Polling: Sub-second visual feedback is critical for natural mirror interactions; event-driven state syncing was essential to prevent input lag.
  3. Hardware-Agnostic Web Standards: Building the display layer around standard web technologies (Next.js, WebRTC, WebSockets) allows the system to run on virtually any smart TV, commercial monitor, or tablet setup.

Technical Summary

System Capabilities & Execution Flow