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)
- Clone / open the project in
ott-backend. - Install dependencies:
npm install- (Optional) create
.envto 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/....
- Node.js
- Express
- CORS
- Morgan (request logging)
- Nodemon (dev)
From the ott-backend folder:
npm installIf you see npm permission/cache errors, fix them first (for example by running
sudo chown -R $(id -u):$(id -g) ~/.npmin your own terminal) and then retry the install.
Create a .env file if you want to override defaults:
PORT=4000npm run devServer will start on http://localhost:4000.
POST /api/auth/register– register user, returns token + user + profilesPOST /api/auth/login– login user, returns token + user + profilesGET /api/auth/me– get current user fromAuthorization: Bearer <token>
Seed user available out of the box:
- email:
demo@example.com- password:
password- token:
demo-token-u1(use asAuthorization: Bearer demo-token-u1)
GET /api/profiles– list profiles for current userPOST /api/profiles– create profile ({ "name": "Kids" })PATCH /api/profiles/:profileId– rename profileDELETE /api/profiles/:profileId– delete profile
GET /api/home?profileId=<profileId>– returns:profile– active profilefeatured– a featured content itemrows– array of rows likeContinue Watching,Popular,Movies,Series
GET /api/content– list all demo contentGET /api/content/:id– single content item plussimilarrecommendations
GET /api/search?query=money&category=Movies– full-text search over title/description, optionalcategoryfilter
GET /api/profiles/:profileId/list– current profile watchlistPOST /api/profiles/:profileId/list– add to list ({ "contentId": "1" })DELETE /api/profiles/:profileId/list/:contentId– remove from list
POST /api/profiles/:profileId/progress– update playback position- body:
{ "contentId": "1", "position": 120, "duration": 3600 }
- body:
GET /api/profiles/:profileId/continue-watching– items with progress for that profile
- Login / register screen:
- Call
POST /api/auth/loginorPOST /api/auth/registerand storetokenin memory/localStorage.
- Call
- Profile selection screen:
- Call
GET /api/profileswithAuthorization: Bearer <token>to render profiles.
- Call
- Home screen:
- Call
GET /api/home?profileId=<profileId>to render featured + rows (like Netflix rails).
- Call
- Details / player screen:
- Call
GET /api/content/:idfor metadata and similar content. - Periodically POST to
/api/profiles/:profileId/progressto keep “Continue Watching” up to date.
- Call
- Search screen:
- Call
GET /api/search?query=<text>&category=<optional>on input changes or search submit.
- Call
- My List screen:
- Call
GET /api/profiles/:profileId/listto render. - Call
POST/DELETElist endpoints when user toggles the “My List” button.
- Call
- 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