
Explore building a real-time social media API with NestJS and WebSockets, covering fundamentals, socket.io integration, DTO and JWT authentication, real-time posts, chats, and notifications.
Compare http and websockets protocols, revealing one-way request–response versus bi-directional communication between client and server. The lecture uses a chat app to show http limitations and how websockets address them.
Build a simple http chat app with express and cors, implementing an api to get all messages and to send a message, and show how web sockets enable real-time updates.
Demonstrate the tcp handshake and its three-step process before sending http requests, detailing client syn, server syn and acknowledgement, then client ack, and contrast http’s statelessness with persistent tcp.
Learn how the http handshake upgrades an http connection to the websocket protocol, using the upgrade header and a 101 response to switch from http to the websocket protocol.
Learn how WebSocket enables real-time, bi-directional communication for chat, stocking application, online games, and video streaming, with examples from Facebook, WhatsApp, Discord, and Slack.
Open a WebSocket connection by configuring a native client WebSocket and a server WebSocket using the http upgrade, enabling real-time communication.
Learn to implement a real-time WebSocket flow in a NestJS social media API by sending and receiving data between server and client, handling events, and testing with ws.send and onmessage.
Explain what a socket is—the endpoint between a client and server in WebSocket communication, and how a server handles multiple clients via a callback.
Refactor the chat app to send a JSON message object with type and data from client to the WebSocket server, then broadcast to all connected clients in real time.
Explore why socket.io provides a robust real-time solution over the ws package, with event-based messaging, auto reconnect, long polling fallback, and support for rooms and namespaces.
Set up socket.io on both the client and server to enable real-time web sockets, install the packages, and embed the client script in index.html for same-domain connections.
Learn to send and receive data with socket.io by emitting events to a specific socket, listening for those events, and using the socket id to identify connections.
Explore sending and receiving data with websockets by emitting an event with a name and data, listening for updates, and wrapping messages in an object with acknowledgement callbacks.
Build a real-time chat app with socket.io by sending messages via an emit event, handling server listeners, and broadcasting to all connected clients using io instead of a single socket.
Explore broadcasting with socket.io in a NestJS real-time chat app, sending messages to all clients or all except the sender, and notifying others on new joins.
Learn to create and join rooms in a Socket.io chat app, emit join room requests to the server, and display the joined room name.
Join a room and send messages to that room or the global chat. Learn room messaging with io.to, a room message event, and deduplication.
Explore namespaces in socket.io to isolate events, using a default namespace and an admin namespace like /admin, and broadcast events to all clients in a namespace.
Create a real-time chat feature that lists online users via websockets and socket.io, emitting new user events and handling disconnects to update all clients.
Set up a Nest.js project and run a dev server on port 3000 using the Nest CLI and npm, while exploring the src structure and dist build.
Explore how a NestJS controller handles requests, routes to methods, and returns responses, using the @Controller decorator and module wiring to expose endpoints like /products.
Learn the single responsibility principle from SOLID, where a controller calls a service that calls a repository to handle business logic and data, with each class focused on one purpose.
Explore how a class acts as a provider by injecting it as a dependency. Grasp dependency injection, inversion of control, and the distinction between tightly coupled and loosely coupled design.
Explore inversion of control to avoid tightly coupled code and achieve loose coupling through constructor injection, illustrated with a TypeScript car and person example.
Refactor your NestJS app to implement inversion of control through dependency injection by using constructor-based private services and readonly fields to decouple components.
Learn how dependency injection delegates object creation to the NestJS framework via an inversion of control container, enabling providers and controllers to wire services automatically.
Explore how the NestJS IoC container powers dependency injection by marking classes as injectable, registering providers, and auto wiring services into controllers through constructor parameters.
Organize a NestJS application with modules like user, order, and chat, manage root app module, providers, controllers, imports, and exports, enabling dependency injection.
Create a post module with post.controller, post.service, and post.module, export the module, and import it into the app module to connect posts to the application and enable the /posts route.
Explore how NestJS uses Express middleware by building a logger middleware. Apply it in the app module with forRoutes and global middleware to log requests for selected routes and methods.
Apply middleware in NestJS, compare using the app module versus a specific post route, and add a post middleware that runs only on the post route alongside a global logger.
Explore NestJS exception filters and built-in http exceptions to control error handling. Throw familiar errors like bad request, forbidden, and unauthorized, and customize messages or create custom exceptions as needed.
Learn how NestJS pipes transform inputs and validate parameters, using @Param and ParseIntPipe to convert strings to numbers and handle validation for route parameters.
Learn how NestJS guards enforce route protection by implementing the CanActivate interface, enabling authorization checks with the UseGuard decorator for controlled access to handlers.
Discover NestJS interceptors as dependency injection tools performing before and after logic around handlers, configured with @UseInterceptor(LoggingInterceptor), and contrasted with middleware.
Learn how NestJS uses decorators, including custom decorators like @User, to access request data with @Request, @Param, @Body, @Query, and manage session data with @Session.
Explore the core concept of NestJS, covering controller, provider, module, middleware, exception filter, pipe, guard, and interceptor, and learn to apply them by building a project.
Create a NestJS project with a simple blog post API using MongoDB, as the first of two projects in the course, with a later SQL-based project to follow.
Master the nest CLI command line interface to scaffold modules, controllers, and services with nest generate and schematics. Learn to use nest new and nest n for quick project setup.
Configure MongoDB for a NestJS real-time social media API by installing mongoose, creating a MongoDB cluster, and enabling network access for seamless integration with NestJS.
Connect NestJS to MongoDB Atlas using the mongo module and mongoose, import it in app.module.ts, and configure the atlas url with forRoot; verify by running the app.
Define a post schema in NestJS using @Schema and @Prop to map a post document, configure the MongooseModule.forFeature with PostSchema, and create a posts collection in MongoDB.
Explore how to inject a mongoose-based repository into a NestJS service, using dependency injection to create and persist posts via a controller, DTOs, and the repository pattern.
Explore handling the request body in a NestJS controller with the @Body decorator, creating posts with title and description, logging inputs, and preparing for DTO concepts.
Learn how the data transfer object, or dto, reduces data for create and response, excluding id and password, with two dtos: create-post dto for input validation.
Use data transfer objects to shape requests and responses, map post data to a ResponsePostDTO, remove __v, and expose _id as a string in an MVC workflow.
Apply class-validator to validate DTOs in NestJS using @IsNotEmpty and built-in rules. Enforce a global validation pipe in main.ts to reject empty title or description.
Explore how the dto pattern connects a postman client to server. The server creates an entity from the dto and returns a dto response with simple schema and dto validation.
Implement get all posts by querying the post model with find(), map entities to the post DTO, and return an array of response post DTOs.
Explore practical options to reduce data in a NestJS API, comparing DTO-based responses with class-transformer serialization, and discussing when to exclude sensitive fields like passwords.
Use a NestJS response interceptor to convert controller results into a DTO after the response, using map, plainToInstance, and class-transformer Expose/Exclude.
Transform dtos in NestJS using a transform dto interceptor and a custom decorator to pass and reuse dto classes; enable type checking with class transformer.
Create a getOne endpoint in NestJS to fetch a post by id using @Param and findOne with _id, and throw NotFoundException when not found.
Update all fields with PUT in the NestJS real-time social media api, using id and UpdatePostDTO. Compare update methods (findByIdAndUpdate, findOneAndUpdate, or manual save) and anticipate PATCH for partial updates.
Learn to implement a patch operation in a NestJS API by creating UpdatePostPatchDTO with PartialType, extending CreatePostDTO, validating id and request body, and merging updates with Object.assign in updateOne.
Create a deleteOne service using postModel.deleteOne with _id and verify the post exists; expose a controller delete endpoint that returns nothing on success and throws an error if not found.
Export the post service from the post module and import the post module into the user module to inject the post service into the user service using the post schema.
Set up swagger ui in a NestJS project by installing the swagger package and using the document builder and swagger module to expose /api routes with a user controller.
Demonstrates configuring Swagger UI in a NestJS project by adding @ApiProperty to DTOs, customizing title and description, renaming tags with @ApiTags, and exploring try out, patch, and multipart/form-data.
Build a basic NestJS health check using terminus, create a health module and controller, expose /health with an http health indicator, and extend checks to database health.
Learn to document a NestJS application using compodoc, install the tool, generate and view documentation locally, customize ports, and explore modules, controllers, and injectable code.
Understand the NestJS request life cycle, from middleware to guards and interceptors, including global, controller, and method-level scopes and pipes shaping the request and response.
Explore NestJS api versioning using uri-based versioning to run multiple versions like v1 and v2 in parallel, with configuration in main.ts and optional api prefixes.
Explain circular dependency in NestJS and how post service and user service depend on each other. Show how forwardRef with inject helps avoid the cycle in module and service design.
Review the key NestJS concepts by covering CRUD operations, DTO usage, and customizing DTOs for responses with Mongo integration; preview the upcoming big project.
Set up a Next.js project, create a project named social, install the Next.js CLI, run the app on localhost:3000, and preview a hello world page.
Resolve an eslint issue in the NestJS real-time social media api course by applying a Stack Overflow-based fix, moving the line into the rows of the as link, and saving.
Set up MongoDB with Mongoose for a NestJS real-time social media API, wiring the database into the app module, creating a cluster, configuring access, and establishing a connection workflow.
Build a real-time social media API with NestJS and MongoDB by defining the user schema, generating a cross-resource structure, and wiring controllers, services, and modules for a REST API.
Configure environment variables in a NestJS project by using the config module, global settings, and async configuration with a factory to access the module url and port.
Explore API versioning in NestJS as you scaffold a new project, rename it, create folders for authentication, and set up a user controller and sample data to test the flow.
Implement sign up authentication in a NestJS real-time social media API by configuring the user schema, sign up DTO, and authentication service, and exposing a sign up endpoint.
Hash the user password using an external library in a NestJS app, then save the hashed password to the database and return a sanitized user object without the password.
Transform dto responses in NestJS using an interceptor and class-transformer to shape the output with a message and data. Integrate class-validator and fix eslint issues for clean, typed results.
Learn to generate a JSON web token in a NestJS real-time API after saving a user, configuring the JWT service with a secret, and returning an access token.
Implement sign in by locating the user by email, validating the password with hashing, and issuing a JSON web token as an access token.
Implement an authentication guard in NestJS by extracting the bearer token from request headers, verifying it, attaching the decoded user to the request, and export a global authentication module.
Learn to implement a get current user route in a NestJS real-time social media API, using a custom current user decorator to fetch user data from the request.
Add signup validation in NestJS using class-validator, enforcing non-empty fields and valid email formats, with customizable messages and a unique email check via user lookup.
Implement role-based authorization in a NestJS real-time social media API by extending the user schema with a role and customizing the JSON web token payload.
Explore implementing role-based authorization in a NestJS API using a custom row decorator and the reflector to enforce admin vs user access on create, read, update methods.
Explore role guard authorization in a NestJS real-time social media API, implementing admin overrides and user-owned-resource checks by comparing current user id with the requested resource id.
Examine the role guard’s limitations when authorizing actions across resources, highlighting user ID versus resource ID mismatches and lookups for admin vs user actions.
Build a resource module in NestJS, wiring a service with user models and mongoose schemas to fetch results by user id, and mark the module as global.
Refine the post schema by replacing title with content, adding author and content blocks like image or video; implement privacy and auto-generated created_at and updated_at timestamps.
Create a post in NestJS with mandatory content, optional hexadecimal background color, and optional privacy, using class-validator for validation and a create post controller to save.
Create a response post dto in NestJS, defining id, background color, content, media url, privacy, created at, and updated at, and wire it into controllers for real-time posts.
Master getting all posts in NestJS with a custom response DTO that includes author data via a transformer, populating current user information and debugging responses.
Learn to fix object id changes after refresh in a NestJS application programming interface by using a custom decorator and class transformer to keep consistent ids in responses.
Get a post by ID in a NestJS real-time social media API using MongoDB and ID verification, with controller updates.
Update post by id using nestjs with mongodb, validating changes, handling errors, and updating content for a real-time social media api with websockets.
Implement remove by id for posts and add a custom pipe to validate the MongoDB _id, preventing internal server errors from invalid IDs.
Set up cloudinary in a NestJS project to upload media, creating a module, service, provider, and controller. Learn to handle buffers with a readable stream to produce media URLs.
Build a multi-file upload service in NestJS for a real-time social media API, wiring file imports, controllers, and a media library to handle uploads and logging.
Refactor NestJS media handling by introducing a media class, updating media URL flow, and adding batch endpoints to upload and block media with Cloudinary URLs for the front end.
Learn to delete a media file by its unique public ID in a NestJS real-time social media API, including validating details and updating media lists.
Design a DTO to return a generated URL in a NestJS real-time social media API. Transform nested data and manage Cloudinary versioned media metadata.
Learn cursor pagination for a NestJS real-time social media API, replacing MongoDB skip with a created timestamp cursor, using limit plus one to detect has next for efficient infinite scroll.
Design and implement reactions for posts by separating reaction documents, tracking user and post references, and using a reaction count field to avoid heavy aggregation and improve performance.
Create and update a reaction schema in NestJS, explore map versus object for reaction counts, reference users and bosses, and enable REST CRUD for a real-time social media API.
Learn to implement add reaction functionality in a nestjs real-time social media API by handling box and reaction services, validating input, and updating or creating reactions.
Learn how to update reaction counts in a real-time social media API using NestJS, including decrementing old reactions, incrementing new ones, validating values, and persisting changes.
Learn to build a real-time social media API with websockets in NestJS by implementing a response reaction count dto and using transforms to return the correct reaction data.
Describe how to implement a remove reaction flow in a NestJS real-time social media API, including revoking reactions, deleting the reaction document, and updating the reaction count on the post.
Attach and display the current reaction to a post in real time using a reaction controller and API, and map updated data to the front end.
Refactor to atomic operation demonstrates turning two update and save actions into a single atomic operation to avoid race conditions when updating reaction counts in a real-time social media API.
Implement real-time updates for a NestJS social media API by wiring socket.io to emit reaction events to other users and preview WebSocket integration.
You may have heard the phrase: "To build a chat app, you need WebSockets." But have you ever stopped to ask — why?
In this hands-on course, you’ll learn to build a real-time social media API using NestJS and WebSockets (Socket IO) — not just by memorizing syntax, but by understanding the fundamentals behind real-time communication. We’ll explore how sockets work under the hood, how data flows between client and server, and how to architect a system that can scale and respond instantly.
Rather than spoon-feeding you code, this course teaches you how to read documentation, think critically, and apply these skills to your own projects. You'll gain the confidence to build and extend real-time features independently.
We start with a deep dive into the fundamentals of WebSockets, from how the TCP handshake works to the HTTP upgrade process that opens a persistent WebSocket connection. You’ll clearly understand what’s happening behind the scenes before writing a single line of code.
Next, you'll build a simple chat app using raw WebSocket APIs, giving you a solid foundation before introducing any libraries. Once you understand the basics, we’ll transition into Socket IO, where you’ll explore its core concepts including custom events, rooms, and namespaces — and how they simplify real-time communication.
Once your WebSocket knowledge is solid, we shift gears and jump into NestJS fundamentals. You’ll learn about modules, controllers, services, and guards — and then apply them to build a complete, real-time social media backend
Why This Course?
This is not just another crash course. It’s a practical, project-driven guide that helps you think like a backend engineer. If you’re comfortable with JavaScript/TypeScript, have some Node.js or NestJS experience, and want to level up your backend skills with real-time architecture, this course is for you.
By the end, you’ll walk away with a complete real-time backend — ready to power your own chat app, live feed, or social platform.