Vuvo Backend is a production-ready, highly scalable RESTful API built for a modern video streaming and content delivery platform (YouTube-style architecture). It features enterprise-grade JWT authentication, chunked media streaming to AWS S3, ImageKit CDN integration, automated infrastructure provisioning with Terraform, and 100% automated test coverage with Jest and Supertest.
- Architecture: Layered Controller-Service-Model Pattern built on Express 5 and ES Modules.
- Storage Engine: Stream-based chunk processing using
@aws-sdk/client-s3linked to AWS S3 object storage and ImageKit.io CDN for global edge acceleration. - Security & Auth: Dual-token JWT system (Access & Refresh tokens stored in HTTP-Only cookies), password hashing via
bcryptjs, and dynamic CORS origin reflection. - Database & Performance: MongoDB Atlas with Mongoose v9 schema modeling, MongoDB
.populate()joins, and atomic$inccounters to prevent concurrency race conditions. - Infrastructure as Code (IaC): Declarative Terraform scripts (
main.tf) automating AWS EC2t3.microprovisioning, Security Groups, and S3 bucket policies. - Quality Assurance: 100% Passing Unit & Integration test suite using Jest and Supertest with Mongoose model mocks.
┌────────────────────────┐
│ Client (Frontend) │
└───────────┬────────────┘
│ HTTP / Cookies (JWT)
▼
┌────────────────────────┐
│ Express.js API Router │
└───────────┬────────────┘
│
┌──────────────────────────┼──────────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Auth & Security │ │ Business Logic │ │ Multer Stream │
│ Middleware │ │ Controllers │ │ File Handler │
└────────┬────────┘ └─────────┬────────┘ └────────┬─────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ JWT & Cookie │ │ MongoDB Atlas │ │ AWS SDK v3 (S3) │
│ Token Checks │ │ (Mongoose ORM) │ │ & ImageKit CDN │
└─────────────────┘ └──────────────────┘ └──────────────────┘
| Layer | Technology | Purpose & Implementation Details |
|---|---|---|
| Runtime | Node.js (v20+) |
Native ES Modules ("type": "module") for modern JS features. |
| Framework | Express.js (v5.x) |
REST API routing, custom middleware pipelines, and centralized error handling. |
| Database | MongoDB Atlas |
Cloud NoSQL database with Mongoose v9 ORM and aggregation pipelines. |
| Media Storage | AWS S3 |
Object storage via @aws-sdk/client-s3 v3 using Node.js fs.createReadStream. |
| CDN Acceleration | ImageKit.io |
Edge caching and automatic image/video format optimization. |
| Auth & Security | JWT + bcryptjs |
Access & Refresh tokens stored in HTTP-Only cookies + salted password hashes. |
| Infrastructure | Terraform |
Automated provisioning of AWS S3 buckets, EC2 t3.micro instances & Security Groups. |
| API Testing | Jest + Supertest |
100% automated unit and integration testing suite for all REST endpoints. |
POST /register— Multi-part registration (Avatar & Cover image uploads to S3, password hashing).POST /login— Authenticates credentials, generates Access & Refresh Tokens into HTTP-Only cookies.POST /logout— Invalidates refresh token in DB and clears auth cookies.GET /getCurrentUser— Protected route returning currently authenticated user profile.PATCH /avatarUpdate— Deletes old avatar from S3 and uploads new avatar image.PATCH /coverimageUpdate— Deletes old cover image from S3 and uploads new cover image.
GET /— Fetches paginated video feed (page,limit, searchqueryfilter) with populated channel owner details.GET /v/:videoId— Fetches single video details and atomically increments view counter ($inc: { views: 1 }).POST /videoUpload/publish— Accepts multi-part video & thumbnail uploads, streams files to S3, and saves duration & metadata.
POST /toggle/v/:videoId— Toggles Like/Unlike status on a video for the authenticated user.GET /v/:videoId— Returns total like count and whether the requesting user liked the video.
GET /v/:videoId— Fetches paginated comments with owner username & avatar details.POST /v/:videoId— Posts a new comment under a video.DELETE /c/:commentId— Deletes a comment (enforces owner authorization).
POST /c/:channelId— Toggles Subscribe/Unsubscribe on a channel.
The project maintains a 100% test pass rate using Jest and Supertest. Tests run completely offline by leveraging Mongoose model mocks.
# Run all test suites
npm testtests/user.test.js: Registration field validation, missing file checks, login validation, protected route rejection.tests/video.test.js: Unauthorized publish blocking.tests/video_feed.test.js: Feed pagination formatting, non-existent video handling.tests/like.test.js: Total likes aggregation & unauthorized toggle checks.tests/comment.test.js: Comment list pagination & unauthorized posting prevention.
The repository includes a complete Terraform script (main.tf) that automates AWS provisioning:
# main.tf snippet
resource "aws_s3_bucket" "vuvo_bucket" {
bucket = "vuvo-media-storage-99"
force_destroy = true
}
resource "aws_instance" "vuvo_server" {
ami = "ami-0ad21ae1d0696ad58" # Ubuntu 24.04 LTS
instance_type = "t3.micro" # Free Tier eligible
security_groups = [aws_security_group.vuvo_sg.name]
}- Node.js v20+
- MongoDB Atlas Cluster
- AWS Account (IAM Credentials)
Create a .env file in the project root:
PORT=8000
MONGODB_URL=mongodb+srv://<username>:<password>@cluster0.mongodb.net/vuvo
CORS_ORIGIN=http://localhost:5173
# JWT Secrets
ACESS_TOKEN_SECRET=your_access_token_secret_key
ACESS_TOKEN_EXPIRY=1d
REFRESH_TOKEN=your_refresh_token_secret_key
REFRESH_TOKEN_EXPIRY=10d
# AWS Credentials
AWS_REGION=ap-south-1
AWS_ACCESS_KEY_ID=your_aws_access_key_id
AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
AWS_S3_BUCKET_NAME=vuvo-media-storage-99
# CDN Configuration
CDN_DOMAIN=https://ik.imagekit.io/your_imagekit_id# Install dependencies
npm install
# Run automated test suite
npm test
# Start development server
npm run devSumit — Fullstack & Backend Engineer
Specializing in Node.js, Cloud Storage Architecture (AWS/Cloudflare), Database Optimization, and Automated Testing.