Skip to content

About

Movie featuring web platform featuring React 19, Node.js/Express BFF, relational persistence with Prisma & SQLite/PostgreSQL, Clerk auth, and a Python cosine-similarity recommendation engine.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

58 Commits

Folders and files

Repository files navigation

🎬 Flex-Watch β€” Enterprise Movie Discovery & Streaming Platform

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.


πŸ›οΈ System Architecture

                                [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

✨ Production Highlights

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.

πŸ“ Clean Monorepo Directory Structure

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)

πŸš€ Getting Started

Prerequisites

  • Node.js: v18 or higher (v20+ recommended)
  • npm: v9+
  • Docker & Docker Compose (optional, for containerized run)

Method 1: Local Monorepo Development (One-Command Run)

  1. Clone the repository:

    git clone https://github.com/your-username/Flex-Watch.git
    cd Flex-Watch
  2. Setup Backend Environment:

    cd backend
    cp .env.example .env
    npm install
    npx prisma db push
    cd ..
  3. Install Root Workspaces Dependencies:

    npm install
  4. Run Full-Stack (Frontend + Backend Concurrently):

    npm run dev

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)

Method 2: Docker Compose (Full Production Stack)

To run the complete production topology (PostgreSQL, Redis, Backend API, and Nginx reverse proxy):

docker compose up --build -d

πŸ§ͺ Testing & Benchmarks

Run full monorepo test suite:

npm test

Run backend API smoke tests:

npm run test:backend

Run frontend unit & integration tests:

npm run test:frontend

Run high-concurrency performance benchmark:

npm run benchmark

πŸ“‘ Core API Endpoints

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

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to your branch (git push origin feature/amazing-feature)
  5. Open a Pull Request (PR template will guide verification)

πŸ“„ License

This project is for educational and personal use.

About

Movie featuring web platform featuring React 19, Node.js/Express BFF, relational persistence with Prisma & SQLite/PostgreSQL, Clerk auth, and a Python cosine-similarity recommendation engine.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages