A high-performance C++20 engine for handling seat reservations with sub-microsecond latency and lock-free concurrency. Now features a real-time React frontend and WebSocket broadcasting.
┌─────────────────────────────┐ ┌─────────────────────────────┐
│ User A (Browser) │ │ User B (Browser) │
│ React + WebSockets │◄────►│ React + WebSockets │
└──────────▲──────────────────┘ └──────────▲──────────────────┘
│ │
│ Real-time Updates │
└──────────────────┐ ┌──────────────┘
│ │
┌─────────────────────────────▼──▼──────────────────────────┐
│ FastAPI Gateway (Python) │
│ • REST API for Holds/Confirms │
│ • WebSocket Broadcaster │
└──────────┬────────────────────────────────────────────────┘
│ gRPC / FFI
┌──────────▼────────────────────────────────────────────────┐
│ C++ SeatLock Engine │
│ • Atomic State Management (32M ops/sec) │
│ • Expiry Worker │
└───────────────────────────────────────────────────────────┘
Benchmark Results (16 threads, 1.6M operations):
Ops/Sec: 32,240,000
Time: 0.05 seconds
Throughput: Sub-millisecond lock acquisition
# Windows
build_seatlock.batcd backend
pip install -r requirements.txt
uvicorn main:app --reloadSimply open frontend/index.html in your browser.
- Green: Available
- Orange: Held (Real-time update)
- Red: Sold (Real-time update)
- Lock-Free Core: Uses
std::atomicand CAS loops for maximum throughput. - Real-Time Sync: WebSockets broadcast seat state changes instantly to all connected clients.
- Fine-Grained Locking: Alternative implementation available for comparison.
- Auto-Expiry: Background thread automatically releases held seats after timeout.
seatlock/
├── src/ # C++ Source
│ ├── AtomicSeatManager.cpp
│ └── ...
├── include/ # C++ Headers
├── backend/
│ ├── main.py # FastAPI + WebSockets
│ └── requirements.txt
├── frontend/ # Real-time UI
│ ├── index.html
│ ├── app.js
│ └── styles.css
├── build_seatlock.bat # Automated Build Script
└── README.md
- System Design: "I extended the C++ engine with a FastAPI gateway to support web clients. I implemented WebSockets to solve the 'stale view' problem in ticketing, ensuring users see taken seats instantly."
- Concurrency: "The core engine handles 32M ops/sec using lock-free structures, while the frontend handles eventual consistency via WebSocket events."
- Full Stack: "Demonstrates integration from low-level C++ memory management up to high-level React UI state."
- Frontend: Configured for Vercel (
vercel.json) - Backend: Configured for Railway/Heroku (
Procfile)
Live seat updates with color-coded status (Available, Held, Sold)
Interactive REST API testing interface
Kid of Dynamic
- GitHub: @Raphasha27