🎬 Scene It All - System Architecture

← Back to Home

System Architecture & Data Flow

GitHub - Source Control & Auto-Deploy FRONTEND Scene It All Web App Browse β€’ Rate β€’ Track β€’ Chat β€’ Recommend Cloudflare Pages / trumpsbigly.com User requests (genres, movies, ratings, tracking) Movie data + recommendations (cached, enriched) BACKEND API Express.js Server Fetches β€’ Caches β€’ Enriches β€’ Generates Recommendations β€’ Handles Sessions Railway.app (Node.js) Store/Fetch: movies, ratings, user lists, sessions Cached movies, user preferences, recommendations DATABASE MongoDB Atlas Movies β€’ User Lists β€’ Ratings β€’ Sessions Recommendations β€’ Embeddings β€’ Cache MongoDB Atlas (AWS) EXTERNAL APIS Scene It All β€’ Mailgun/TMDB/OMDb/OpenAI Pool Tracker β€’ YoLink TMDB API Movie data, ratings, genres, posters, release dates Requests movie data OMDb API Rotten Tomatoes scores, reviews, viewer ratings Enrich with RT scores OpenAI API Text embeddings for similarity scoring Generate embeddings Mailgun API Email delivery for invite codes (Scene It All) Send invite emails YoLink API IoT devices Temperature, sensors (Pool) Query IoT data DATA FLOW DETAILS 0. User Authentication: Signup: Email + password β†’ bcryptjs hashes password β†’ stores User in MongoDB β†’ generates JWT token. Login: Email + password β†’ bcryptjs verifies against hash β†’ returns JWT token. All protected endpoints require valid JWT bearer token in header. 1. User Browses: Frontend (authenticated) β†’ GET /api/genres with JWT token β†’ Backend verifies token β†’ fetches from TMDB & caches β†’ Returns genre list + movie count 2. Backend Enriches Data: For each movie: fetch title, poster, TMDB rating β†’ call OMDb for Rotten Tomatoes score β†’ store in MongoDB for caching 3. User Tracks Movies: Frontend β†’ POST /api/movies/{id}/seen with JWT β†’ Backend verifies user from token β†’ stores in UserMovieList with userId β†’ Database returns confirmation 4. AI Recommendations: Weekly cron: Get user's rated movies (filtered by userId) β†’ OpenAI generates embeddings β†’ Compare against all unwatched movies β†’ Score by similarity β†’ Store top 30 in MongoDB for this userId β†’ Frontend displays when user clicks "Recommendations"

Component Breakdown

πŸ™ GitHub - Version Control & CI/CD

Role:

  • Central repository for all source code (frontend, backend, configs)
  • Git version control with full commit history and branching
  • Integrates with Railway for automatic deployments
  • Tracks all changes made to the codebase

Deployment Flow:

  • Developer pushes code to main branch on GitHub
  • GitHub webhook triggers Railway deployment
  • Railway pulls latest code and rebuilds application
  • New version goes live automatically (continuous deployment)

What It Stores:

  • server.js β€” Express backend code
  • movies/movie-tracker.html β€” Frontend app
  • db/models.js β€” MongoDB schemas
  • package.json β€” Dependencies and build config
  • All other apps (Pool Tracker, City Bomber, etc.)

🌐 Cloudflare Pages - Frontend Hosting

Role:

  • Serves your entire user-facing web application globally via CDN
  • Acts as the "browser-facing" layerβ€”everything users interact with
  • Handles routing and serves static HTML/CSS/JavaScript files
  • Automatically deploys whenever you push to GitHub

What It Serves:

  • Scene It All app (movie-tracker.html) β€” browse, rate, track, chat about movies
  • Landing page (index.html) β€” shows links to all apps
  • Architecture documentation β€” the page you're reading now
  • All UI elements, buttons, tabs, and forms the user sees
  • CSS styling and JavaScript interactivity (no server-side rendering)

βš™οΈ Railway.app - Backend API Server

Role:

  • Runs your Node.js Express serverβ€”the "brain" of your app
  • Handles all business logic: what to return, when to cache, when to fetch external data
  • Gateway between frontend (browser) and backend services (databases, APIs)
  • Executes scheduled tasks (cron jobs) like weekly recommendation generation

Key Responsibilities:

  • Authenticate users β€” Verify email/password with bcryptjs, issue JWT tokens, validate tokens on all protected endpoints
  • Manage invites β€” Create 30-day invite codes for new users, verify invite codes during signup
  • Multi-user isolation β€” Filter all data queries by userId from JWT token (each user sees only their own data)
  • Fetch data from TMDB API when user searches
  • Enrich movies with Rotten Tomatoes scores from OMDb
  • Cache popular movies in MongoDB to avoid repeated API calls

πŸ—„οΈ MongoDB Atlas - Database

Role:

  • Persistent data storage for everythingβ€”movies, user data, history
  • Survives server restarts and deploys (unlike memory)
  • Accessible from Railway backend via connection string
  • Scales automatically as you add more movies/users

Collections Stored:

  • Users β€” User accounts with email, bcrypt password hash, registration date, last login
  • Invites β€” Invite codes (30-day expiration), created by admin, email they're sent to, use status
  • Movies β€” ~5,000+ movie records with title, TMDB rating, OMDb RT score, poster URL, release date, genres
  • UserMovieLists β€” Which movies each user has marked as "Seen", "Watch Later", or "Enjoyed"
  • MovieRatings β€” Thumbs up/down ratings from each user (used to train recommendation algorithm)
  • Recommendations β€” Pre-computed AI suggestions per user with reasons (top 30 per user, updated weekly)

πŸ”Œ External APIs - Third-Party Services

TMDB API (The Movie Database)

What it provides (Scene It All):

  • Movie titles, descriptions, poster artwork
  • TMDB ratings (audience ratings out of 10)
  • Release dates, genres, runtime, director and cast
  • 8 million+ movies in their database

OMDb API (Open Movie Database)

What it provides (Scene It All):

  • Rotten Tomatoes critics score (0-100)
  • Rotten Tomatoes audience score
  • IMDb ratings and votes

OpenAI API (AI/Chat & Embeddings)

What it provides (Scene It All):

  • Text Embeddings: Convert movie descriptions β†’ numerical vectors for similarity matching
  • Chat Completions: Conversational AI for "ask the movie assistant"

Mailgun API (Email Service)

What it provides (Scene It All):

  • Sends invite code emails to new users
  • Reliable email delivery with tracking
  • Sender verification and authentication (SPF/DKIM)

When it's called:

  • Admin generates invite code β†’ Mailgun sends email with 30-day code to recipient
  • Recipient uses code during signup to join the app

YoLink API (IoT Smart Home Devices)

What it provides (Pool Tracker):

  • Access to smart IoT devices (pool thermometers, sensors, etc.)
  • Real-time temperature and sensor readings
  • Device discovery and management
  • Connection authentication with OAuth tokens

When it's called:

  • User clicks "Find My Devices" β†’ Backend requests YoLink API for list of user's devices
  • User selects device β†’ Backend queries current temperature from YoLink
  • Pool Tracker displays real-time data from IoT sensors

Data Lifecycle Example

1. User browses horror movies: Frontend sends request to Railway β†’ Railway calls TMDB API β†’ Caches results in MongoDB β†’ Returns to frontend with OMDb RT scores.

2. User marks "The Shining" as seen: Frontend sends rating to Railway β†’ Railway stores in MongoDB under user's account β†’ Updates recommendation algorithm state.

3. Weekly recommendation job runs: Railway cron pulls user's rated movies β†’ Calls OpenAI to generate embeddings β†’ Compares against 5000+ horror movies β†’ Scores by similarity β†’ Saves top 30 to MongoDB β†’ User sees them in Recommendations tab next login.

4. User asks chat "What's a good horror movie?": Frontend sends message to Railway β†’ Railway calls OpenAI chat API with user's preferences context β†’ Returns suggestion β†’ User sees in chat sidebar.