Backend API for a streaming-style platform (users, content catalog, subscriptions/payments) with background media processing and real-time notifications.
- Runtime: Node.js (ES Modules)
- Web framework: Express 5
- Database: PostgreSQL
- ORM: Prisma
- Auth:
- JWT via
Authorization: Bearer <token>(custom middleware) - Google OAuth 2.0 via Passport (
passport-google-oauth20)
- JWT via
- Realtime: Socket.IO (notifications)
- Background jobs: BullMQ + Redis (media processing queue)
- Storage: AWS S3 / S3-compatible (MinIO supported via custom endpoint)
- Payments: Stripe (PaymentIntents + webhook)
- Email: Nodemailer (SMTP via Gmail host in code)
- Scheduling: node-cron (daily maintenance jobs)
- API docs: Swagger UI + runtime-generated OpenAPI 3.0
index.jsboots the HTTP server and spawns a separate Node process worker for media jobs.app.jsbuilds the Express app + Socket.IO server and mounts all routers under/api/*.- Prisma is used in controllers, cron jobs, and the worker to persist state.
High-level request flow:
- Express middleware: CORS, session, body parsing (Stripe webhook uses
express.raw), logging - Route match (
/api/...) - Controller executes business logic + Prisma queries
- Side effects (as applicable): queue a BullMQ job, emit Socket.IO notification, send email, update subscription status
This list is based on the routers that are actually mounted:
/api/users(register/login, password reset OTP, Google OAuth redirect/callback, profile updates, notifications)/api/uploads(multipart video + optional thumbnail upload that enqueues a media job)/api/contents(content listing and admin content management)/api/payments(Stripe PaymentIntent creation, webhook receiver, subscription metrics)/api/admin/categories(category CRUD, services, genre list, content-by-genre)/api/admin/user(admin user management: list, suspend/unsuspend, delete)/api/admin/settings(account deactivation/reactivation, permanent delete)/api/ratings(CRUD ratings + “top ratings” aggregation)/api/favourites(create/list favourites)/api/support(support ticket creation + admin ticket management)
For the canonical, always-up-to-date route list, use the generated OpenAPI served by the running app (see below).
- Upload endpoint writes files into
tmp_uploads/and inserts aContentrow withcontent_status. - A BullMQ job (
mediaqueue) is enqueued. - The worker (
modules/workers/media.worker.js) uploads the video (and optional thumbnail) to S3/MinIO using AWS SDK multipart upload and updatesContentwith bucket/key metadata andcontent_status.
When enabled, app.js schedules daily jobs to:
- expire subscriptions whose
end_datehas passed and downgrade the user role/flags - unsuspend users whose
suspend_endTimehas passed - reactivate users after a deactivation end date
When the server is running:
- Swagger UI:
http://localhost:<PORT>/api-docs - OpenAPI JSON:
http://localhost:<PORT>/openapi.json
OpenAPI is generated from the registered Express routes (with optional YAML overrides in swagger/*.yml).
npm run openapi:generateWrites swagger/openapi.json.
npm run docs:buildGenerates swagger/openapi.json and copies it to docs/openapi.json.
npm installThis project uses PostgreSQL via Prisma.
- Set
DATABASE_URLto a valid Postgres connection string. - Run Prisma migrations (if you are setting up a new database):
npx prisma migrate devThis repo includes docker-compose.yml that runs:
- Redis (BullMQ queue backend)
- MinIO (S3-compatible storage)
docker compose up -dMinimum to boot the API:
PORTDATABASE_URLJWT_SECRET
Used by specific features:
- Sessions / Passport:
SESSION_SECRET,NODE_ENV - Google OAuth:
GOOGLE_APP_ID,GOOGLE_APP_SECRET,GOOGLE_CALLBACK_URL - Stripe:
STRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET - Email:
MAIL_USERNAME,MAIL_PASSWORD,MAIL_FROM_NAME,MAIL_FROM_ADDRESS,ADMIN_EMAIL(also used by support) - Socket notifications:
SYSTEM_EMAIL(optional; used as notification sender identity) - S3/MinIO uploads:
AWS_REGION,AWS_S3_BUCKET,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_S3_ENDPOINT(MinIO),AWS_S3_FORCE_PATH_STYLE - Upload tuning (worker):
UPLOAD_PART_SIZE_MB,UPLOAD_QUEUE_SIZE - Redis/BullMQ:
REDIS_HOST,REDIS_PORT,REDIS_PASSWORD,SKIP_REDIS - OpenAPI generation:
OPENAPI_SERVER_URL,PUBLIC_BASE_URL,WRITE_OPENAPI_FILE,OPENAPI_GENERATION
Development (nodemon):
npm run devProduction-style:
npm startnpm run dev— run API with auto-reloadnpm start— run APInpm run openapi:generate— write OpenAPI JSON toswagger/openapi.jsonnpm run docs:build— generate + copy OpenAPI todocs/openapi.json