How prasanta-mondal76/playtube-fullstack works
1. Repository shape
• This is a Node.js backend for PlayTube, a video/social platform inspired by YouTube.
• The codebase is organized as a classic layered API server: routes → middleware → controllers → models → utilities, with a separate DB bootstrap and a small public temp storage area for uploads.
2. Runtime and application entry
• src/index.js is the server entrypoint.
• src/app.js likely configures the Express application, registers middleware, and mounts feature routes.
• src/constants.js centralizes shared config values used across the app.
3. API surface and feature modules
• The main HTTP API is split by domain into four route groups:
- user.routes.js
- video.routes.js
- playlist.routes.js
- tweet.routes.js
• This suggests a modular REST API where each domain owns its own endpoints and request handling.
4. Controller layer as the orchestration boundary
• Controllers in src/controller/ contain the request-level business logic:
- user.controller.js
- video.controller.js
- playlist.controller.js
- tweet.controller.js
• Controllers sit between Express routes and the persistence layer. They likely validate inputs, call models, manage file uploads, and return standardized responses.
5. Data model layer and domain boundaries
• The app uses distinct Mongoose-style domain models in src/models/:
- user.model.js
- video.model.js
- playlist.model.js
- tweet.model.js
- comment.model.js
- like.model.js
- subscription.model.js
• This indicates a document database architecture with relationships expressed through references between collections rather than a relational schema.
• Core domain boundaries are:
- identity and auth: users
- media content: videos
- curation: playlists
- social posting: tweets
- engagement: comments and likes
- following graph: subscriptions
6. Authentication and request protection
• src/middlewares/auth.middleware.js is the main access-control boundary.
• Protected routes likely require a verified user context before controllers can execute.
• This middleware is important for any diagram because it separates public endpoints from authenticated operations like upload, create, like, subscribe, or edit.
7. File upload and media handling pipeline
• src/middlewares/multer.middleware.js indicates multipart/form-data upload handling.
• public/temp/ is a staging area for uploaded files before they are processed or moved elsewhere.
• src/utils/deleteTempFiles.js implies a lifecycle where temporary local files are cleaned up after successful processing.
• src/utils/cloudinary.js shows that video/image assets are pushed to Cloudinary, so media storage is externalized instead of kept on the app server.
8. External service integrations
• Cloudinary is the clear external media service in the architecture.
• src/utils/sendMail.js shows email delivery is part of the system, likely for onboarding, verification, password recovery, or notifications.
• These integrations sit outside the core API/database boundary and are invoked from controllers or supporting utilities.
9. Database and persistence boundary
• src/db/index.js handles database connectivity and startup initialization.
• Given the model structure, the persistence layer is almost certainly MongoDB accessed through ODM models.
• The data flow is: request → controller → model → database, with response formatting on the way back.
10. Shared utility layer
• src/utils/ contains cross-cutting infrastructure:
- apiError.js for consistent error objects
- apiResponse.js for consistent success payloads
- asyncHandler.js for wrapping async route handlers
- index.js as a utility barrel/export surface
• This utility layer standardizes error handling and response formatting across all route modules.
11. Request processing pattern
• The app likely follows a common Express sequence:
- route matches request
- auth/upload middleware runs if needed
- controller executes domain logic
- model reads/writes the database
- utility helpers format the response or error
• That makes controllers the main orchestration point and models the main persistence boundary.
12. Architectural emphasis for a diagram
• The most important boxes to draw are:
- Express app/server
- route modules by feature
- auth and multer middleware
- controllers
- domain models
- database
- Cloudinary
- email service
- temp upload storage
• The strongest data flow is media upload: client upload → multer/temp file → controller → Cloudinary → database record update.
13. What this repo is not showing
• The tree does not include a frontend app, socket/chat implementation, or task queue, even though the README mentions real-time chat.
• So from the available files, the visible architecture is primarily the backend API and its storage/integration boundaries rather than a full client-server monorepo.
Main entry points: video.controller.js Video Controller · app.js Express App · video.routes.js Video Routes · user.controller.js User Controller
Components 27
Runtime
Express server bootstrap and app setup
- Server · Starts the Node.js process and boots the app
src/index.js - Express App · Configures middleware and mounts feature routes
src/app.js - Constants · Centralized application constants
src/constants.js
API Layer
Feature routes, middleware, and controllers
- User Routes · HTTP endpoints for user features
src/routes/user.routes.js - Video Routes · HTTP endpoints for video features
src/routes/video.routes.js - Playlist Routes · HTTP endpoints for playlist features
src/routes/playlist.routes.js - Tweet Routes · HTTP endpoints for tweet features
src/routes/tweet.routes.js - Auth Middleware · Verifies request identity and protects private endpoints
src/middlewares/auth.middleware.js - Upload Middleware · Handles multipart uploads before controller logic
src/middlewares/multer.middleware.js - User Controller · Orchestrates user-related request flow
src/controller/user.controller.js - Video Controller · Orchestrates video upload and content logic
src/controller/video.controller.js - Playlist Controller · Orchestrates playlist operations
src/controller/playlist.controller.js - Tweet Controller · Orchestrates tweet operations
src/controller/tweet.controller.js
Domain Models
Mongo-style persistence models
- User Model · User collection schema and queries
src/models/user.model.js - Video Model · Video collection schema and queries
src/models/video.model.js - Playlist Model · Playlist collection schema and queries
src/models/playlist.model.js - Tweet Model · Tweet collection schema and queries
src/models/tweet.model.js - Engagement Models · Comment, like, and subscription collections
src/models/comment.model.js
Infrastructure
Database, media storage, and external services
- Database · Initializes application database connectivity
src/db/index.js - Temp Storage · Local staging area for uploaded files
public/temp - Cloudinary · External media storage for images and video assets
src/utils/cloudinary.js - Mail Service · Sends onboarding and notification emails
src/utils/sendMail.js
Shared Utils
Cross-cutting helpers used across the app
- API Error · Standardized application error objects
src/utils/apiError.js - API Response · Standardized success payloads
src/utils/apiResponse.js - Async Handler · Wraps async controllers and routes
src/utils/asyncHandler.js - Utils Index · Shared utility export surface
src/utils/index.js - Temp Cleanup · Removes temporary local upload files
src/utils/deleteTempFiles.js
Connections 43
- Server → Express App: boots · Process startup enters the Express application
- Express App → Constants: uses · Application configuration reads shared constants
- Express App → User Routes: mounts · Registers user feature routes
- Express App → Video Routes: mounts · Registers video feature routes
- Express App → Playlist Routes: mounts · Registers playlist feature routes
- Express App → Tweet Routes: mounts · Registers tweet feature routes
- User Routes → Auth Middleware: guards · Protected user endpoints require authentication
- Video Routes → Auth Middleware: guards · Protected video endpoints require authentication
- Playlist Routes → Auth Middleware: guards · Protected playlist endpoints require authentication
- Tweet Routes → Auth Middleware: guards · Protected tweet endpoints require authentication
- Video Routes → Upload Middleware: uploads · Video requests accept multipart file uploads
- User Routes → User Controller: calls · Routes delegate to user controller logic
- Video Routes → Video Controller: calls · Routes delegate to video controller logic
- Playlist Routes → Playlist Controller: calls · Routes delegate to playlist controller logic
- Tweet Routes → Tweet Controller: calls · Routes delegate to tweet controller logic
- User Controller → User Model: reads/writes · User controller persists user data
- Video Controller → Video Model: reads/writes · Video controller persists video data
- Video Controller → Playlist Model: references · Video logic may relate to playlists
- Playlist Controller → Playlist Model: reads/writes · Playlist controller persists playlist data
- Tweet Controller → Tweet Model: reads/writes · Tweet controller persists tweet data
- User Controller → Engagement Models: uses · User logic interacts with comments, likes, and subscriptions
- Video Controller → Engagement Models: uses · Video logic interacts with engagement collections
- User Model → Database: stored in · Domain models are backed by the database
- Video Model → Database: stored in · Domain models are backed by the database
- Playlist Model → Database: stored in · Domain models are backed by the database
- Tweet Model → Database: stored in · Domain models are backed by the database
- Engagement Models → Database: stored in · Domain models are backed by the database
- Video Controller → Temp Storage: stages files · Uploaded media is staged locally before processing
- Video Controller → Cloudinary: uploads · Media assets are pushed to external storage
- Video Controller → Temp Cleanup: cleans up · Temporary upload files are removed after processing
- User Controller → Mail Service: sends · User flows may trigger email delivery
- Playlist Controller → API Response: formats · Controllers return standardized responses
- Tweet Controller → API Response: formats · Controllers return standardized responses
- User Controller → API Error: raises · Controllers emit standardized errors
- Video Controller → API Error: raises · Controllers emit standardized errors
- User Routes → Async Handler: wraps · Async route handlers are wrapped for error propagation
- Video Routes → Async Handler: wraps · Async route handlers are wrapped for error propagation
- Playlist Routes → Async Handler: wraps · Async route handlers are wrapped for error propagation
- Tweet Routes → Async Handler: wraps · Async route handlers are wrapped for error propagation
- Utils Index → API Error: exports · Utility barrel re-exports error helpers
- Utils Index → API Response: exports · Utility barrel re-exports response helpers
- Utils Index → Async Handler: exports · Utility barrel re-exports async wrapper
- Utils Index → Cloudinary: exports · Utility barrel re-exports integration helpers