Skip to content

Vignesh1318/ott-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OTT Backend (Node/Express)

Simple backend API for an OTT (video streaming) platform. Provides basic endpoints for:

  • Health check
  • Listing content
  • Fetching content by id
  • Stubbed auth (login/register)

Setup (quick)

  • Clone / open the project in ott-backend.
  • Install dependencies:
npm install
  • (Optional) create .env to override defaults:
PORT=4000
  • Run the dev server:
npm run dev
  • Backend will be available at http://localhost:4000.
  • Frontend should call APIs using base URL http://localhost:4000/api/....

Tech stack

  • Node.js
  • Express
  • CORS
  • Morgan (request logging)
  • Nodemon (dev)

Getting started

1. Install dependencies

From the ott-backend folder:

npm install

If you see npm permission/cache errors, fix them first (for example by running sudo chown -R $(id -u):$(id -g) ~/.npm in your own terminal) and then retry the install.

2. Configure environment (optional)

Create a .env file if you want to override defaults:

PORT=4000

3. Run in development

npm run dev

Server will start on http://localhost:4000.

4. API endpoints

Auth / account

  • POST /api/auth/register – register user, returns token + user + profiles
  • POST /api/auth/login – login user, returns token + user + profiles
  • GET /api/auth/me – get current user from Authorization: Bearer <token>

Seed user available out of the box:

  • email: demo@example.com
  • password: password
  • token: demo-token-u1 (use as Authorization: Bearer demo-token-u1)

Profiles (profile selection screen)

  • GET /api/profiles – list profiles for current user
  • POST /api/profiles – create profile ({ "name": "Kids" })
  • PATCH /api/profiles/:profileId – rename profile
  • DELETE /api/profiles/:profileId – delete profile

Home screen

  • GET /api/home?profileId=<profileId> – returns:
    • profile – active profile
    • featured – a featured content item
    • rows – array of rows like Continue Watching, Popular, Movies, Series

Content

  • GET /api/content – list all demo content
  • GET /api/content/:id – single content item plus similar recommendations

Search screen

  • GET /api/search?query=money&category=Movies – full-text search over title/description, optional category filter

My List (per profile)

  • GET /api/profiles/:profileId/list – current profile watchlist
  • POST /api/profiles/:profileId/list – add to list ({ "contentId": "1" })
  • DELETE /api/profiles/:profileId/list/:contentId – remove from list

Continue watching / playback

  • POST /api/profiles/:profileId/progress – update playback position
    • body: { "contentId": "1", "position": 120, "duration": 3600 }
  • GET /api/profiles/:profileId/continue-watching – items with progress for that profile

5. Frontend usage (typical flow)

  • Login / register screen:
    • Call POST /api/auth/login or POST /api/auth/register and store token in memory/localStorage.
  • Profile selection screen:
    • Call GET /api/profiles with Authorization: Bearer <token> to render profiles.
  • Home screen:
    • Call GET /api/home?profileId=<profileId> to render featured + rows (like Netflix rails).
  • Details / player screen:
    • Call GET /api/content/:id for metadata and similar content.
    • Periodically POST to /api/profiles/:profileId/progress to keep “Continue Watching” up to date.
  • Search screen:
    • Call GET /api/search?query=<text>&category=<optional> on input changes or search submit.
  • My List screen:
    • Call GET /api/profiles/:profileId/list to render.
    • Call POST/DELETE list endpoints when user toggles the “My List” button.

Next steps / production hardening

  • Plug in a real database (PostgreSQL, MongoDB, etc.)
  • Implement real authentication (JWT, sessions, etc.)
  • Add user profiles, watchlists, and history
  • Add pagination, search, and categories

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors