A production-grade, distributed movie discovery and streaming web platform inspired by BookMyShow and Netflix. Features a high-performance React 19 frontend powered by Vite 6 and Vitest, an Express BFF (Backend-For-Frontend) with Prisma ORM persistence, two-tier caching (L1 In-Memory + L2 Redis) with singleflight request deduplication, interactive OpenAPI 3.0 / Swagger docs, Prometheus metrics, on-demand Python ML recommendations, and full Docker Compose containerization.
[Web Browser / Client]
β
(Clerk Auth Token / Guest Session)
β
βΌ
[Nginx Reverse Proxy & Static Host]
β
βΌ
[Flex-Watch API Server (Node.js)]
ββββββββββββββββββββββββββΌβββββββββββββββββββββββββ
βΌ βΌ βΌ
[Security & Resilience] [Persistence Layer] [Catalog & ML Engine]
- Helmet, CORS Protection - Prisma ORM - L1 In-Memory LRU Cache
- Rate Limiting - SQLite (Local Dev) - L2 Distributed Redis
- Structured Pino Logs - PostgreSQL (Production) - Singleflight Collapsing
- Trace IDs (x-request-id) - Watchlist & Bookings - On-demand ML Serving
- Prometheus /metrics - Idempotency & Conflict - Protected TMDB Secrets
| Feature | Description |
|---|---|
| π‘οΈ Zero Secret Exposure | TMDB API keys and Clerk credentials live strictly on the backend service. |
| β‘ Two-Tier Resilient Caching | Local L1 LRU memory + distributed L2 Redis with singleflight promise collapsing eliminates upstream TMDB rate limit spikes and stampedes. |
| π Interactive Swagger UI | Complete OpenAPI 3.0 interactive documentation and live sandbox available at /api/docs. |
| π Prometheus Metrics | Production-ready /metrics endpoint tracking HTTP latency histograms, status code counts, and cache hit ratios. |
| ποΈ Cinema Seat Booking | BookMyShow-style curved screen seat selector with tiered pricing (VIP/Club/Standard), conflict guards (409), idempotent bookings, and digital printable ticket passes. |
| π Database Persistence | Watchlists ("My List") and booking drafts are persisted via Prisma ORM (SQLite for zero-config dev, PostgreSQL for cloud production). |
| π€ On-Demand ML Recommendations | ML cosine-similarity matches (~4,800 titles) are served dynamically via API rather than bloated into the client bundle. |
| π₯ Interactive Hero Carousel | Live background video trailers with audio toggle, poster fallback for low-speed connections, and YouTube API sync. |
| π Real-Time Catalog & Search | Live search and multi-genre filtering across trending, popular, upcoming, and top-rated movies & TV series. |
| π³ Full Containerization | Multi-stage Dockerfiles and docker-compose.yml orchestrating PostgreSQL, Redis, Backend API, and Nginx. |
| π¦ Automated CI Pipeline | GitHub Actions validating backend migrations, linting, and 100% frontend test suites on PR/push. |
| π High-Throughput Benchmark | Automated autocannon concurrency test verifying 1,200+ req/sec throughput and singleflight collapsing. |
Flex-Watch/
βββ .github/
β βββ workflows/ci.yml # GitHub Actions CI (validates backend & frontend)
β βββ PULL_REQUEST_TEMPLATE.md # Standard PR checklist
βββ frontend/ # βοΈ React 19 + Vite 6 Client Application
β βββ src/ # Components, pages, layouts, and services
β βββ public/ # Static assets (HTML, favicons, manifests)
β βββ Dockerfile # Multi-stage production Nginx container
β βββ nginx.conf # Nginx reverse proxy & gzip configuration
β βββ package.json # Frontend dependencies & scripts
β βββ tailwind.config.js # Custom cinematic dark theme
βββ backend/ # π Node.js/Express BFF & API Server
β βββ prisma/
β β βββ schema.prisma # Prisma DB schema (User, Watchlist, Booking)
β βββ data/
β β βββ recommendations.json # ML recommendation lookup table (~718 KB)
β βββ src/
β β βββ config/env.js # Zod environment schema & validation
β β βββ db/prisma.js # Singleton Prisma client
β β βββ middlewares/ # Logger (Pino), Auth, ErrorHandler, RateLimiter
β β βββ routes/ # Health, Movies, Series, Search, Watchlist
β β βββ services/ # Cache (Singleflight), TMDB, Recommendations
β β βββ server.js # Express application bootstrap
β βββ tests/
β β βββ test_api.js # Backend integration smoke tests
β βββ Dockerfile # Multi-stage backend container (non-root)
β βββ package.json # Backend dependencies & scripts
βββ ml-engine/ # π§ Python Content-Based Recommendation Pipeline
β βββ export_data.py # Cosine similarity export script
β βββ movies_dict.pkl # Pickled movie dataset
β βββ similarity.pkl # Pickled cosine similarity matrix
βββ docs/ # Architecture, setup, and feature guides
βββ docker-compose.yml # Production stack (Postgres + Redis + API + Web)
βββ package.json # Root monorepo workspaces orchestrator
βββ .gitignore # Multi-tier ignore rules (DBs, envs, logs)
- Node.js: v18 or higher (v20+ recommended)
- npm: v9+
- Docker & Docker Compose (optional, for containerized run)
-
Clone the repository:
git clone https://github.com/your-username/Flex-Watch.git cd Flex-Watch -
Setup Backend Environment:
cd backend cp .env.example .env npm install npx prisma db push cd ..
-
Install Root Workspaces Dependencies:
npm install
-
Run Full-Stack (Frontend + Backend Concurrently):
npm run dev
-
Frontend: http://localhost:3000
-
Backend API: http://localhost:5000
-
Interactive API Docs (Swagger UI): http://localhost:5000/api/docs
-
Prometheus Metrics: http://localhost:5000/metrics
-
Or run individual services:
npm run dev:frontend(React client only)npm run dev:backend(Express API only)npm run db:studio(Open Prisma visual database GUI)
To run the complete production topology (PostgreSQL, Redis, Backend API, and Nginx reverse proxy):
docker compose up --build -d- Frontend Web Application: http://localhost
- Interactive API Docs: http://localhost/api/docs
- Backend API Probes: http://localhost/health/ready
- PostgreSQL Database: Port
5432 - Redis Cache: Port
6379
Run full monorepo test suite:
npm testRun backend API smoke tests:
npm run test:backendRun frontend unit & integration tests:
npm run test:frontendRun high-concurrency performance benchmark:
npm run benchmark| Method | Endpoint | Description | Cache Policy |
|---|---|---|---|
GET |
/api/docs |
Interactive OpenAPI 3.0 Swagger UI | Real-time |
GET |
/metrics |
Prometheus observability metrics | Real-time |
GET |
/health/live |
Liveness check probe | None |
GET |
/health/ready |
Deep check (DB, Cache, TMDB) | Real-time |
GET |
/api/v1/movies/trending |
Weekly/daily trending movies | 30 mins |
GET |
/api/v1/movies/popular |
Popular movies catalog | 1 hour |
GET |
/api/v1/movies/top-rated |
Top-rated movies catalog | 2 hours |
GET |
/api/v1/movies/:id |
Full movie details | 24 hours |
GET |
/api/v1/movies/:id/recommendations |
Dynamic ML recommendations | On-demand |
GET |
/api/v1/bookings/occupied |
Reserved seats for showtime | Real-time |
GET |
/api/v1/bookings |
Retrieve user bookings | Authenticated/Guest |
POST |
/api/v1/bookings |
Idempotent seat reservation (conflict safe) | Atomic (409 guard) |
DELETE |
/api/v1/bookings/:id |
Cancel cinema booking | Authenticated/Guest |
GET |
/api/v1/watchlist |
Retrieve user watchlist | Authenticated/Guest |
POST |
/api/v1/watchlist |
Add movie to persistent watchlist | Authenticated/Guest |
DELETE |
/api/v1/watchlist/:tmdbId |
Remove item from watchlist | Authenticated/Guest |
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request (PR template will guide verification)
This project is for educational and personal use.