Skip to content
Personal

Slack API Clone

2022-03-25 — 2022-07-28

Slack backend clone project for learning NestJS module system and DI/IoC patterns — implemented Socket.io real-time messaging, Passport session authentication, and TypeORM relational data modeling

Slack API Clone project cover image

Project Description

A learning project for adopting the NestJS framework (similar to Java Spring) into practice by cloning the core backend of Slack. Separated domains into 6 NestJS modules (Users, Workspaces, Channels, DMs, Auth, Events) and designed 8 TypeORM entities with ManyToMany/ManyToOne relationships and join tables to implement the Workspace-Channel-User membership structure. Handled per-channel real-time message broadcasting and online user tracking through a Socket.io-based WebSocket Gateway with dynamic namespaces (/ws-.+/) and room patterns, and built session-based authentication using Passport Local Strategy with express-session.

Highlights

  • Domain separation across 6 NestJS modules with independent structures
  • Relational modeling across 8 TypeORM entities with ManyToMany join tables
  • Socket.io real-time messaging with dynamic namespaces and room patterns
  • Passport + express-session auth with Guard-based route protection
  • QueryRunner manual transactions ensuring multi-entity creation atomicity

Features

  • Sign-up/Login — Passport Local Strategy + bcrypt hashing, express-session based authentication, Guard-based route protection for authenticated/unauthenticated access
  • Workspace management — auto-creation of default channel and member on workspace creation, Owner-based ownership structure, member invitation and lookup
  • Channel messaging — channel creation and member management, paginated chat history, image file upload (Multer), unread message counting
  • Real-time communication — Socket.io WebSocket Gateway, dynamic namespaces (/ws-.+/) for workspace isolation, room-based per-channel message broadcasting, real-time online user tracking
  • Swagger API documentation — automatic API docs generation via @nestjs/swagger decorators

Lessons Learned

  • 💡 Confirmed that NestJS module/provider/controller structure follows the same design philosophy as Spring's IoC/DI container, enabling natural transition of Java backend experience to Node.js
  • 💡 Gained experience modeling memberships with JoinTable and intermediate entities (WorkspaceMembers, ChannelMembers) in TypeORM ManyToMany relationships — achieving flexibility for additional metadata management over simple relation mapping
  • 💡 Learned that Socket.io namespace/room hierarchy enables efficient workspace→channel message isolation, and Gateway lifecycle hooks (OnInit/OnConnect/OnDisconnect) provide systematic connection state management
  • 💡 Learned manual transaction management pattern using QueryRunner to ensure atomicity of User, WorkspaceMember, and ChannelMember creation during sign-up

Tech Stack

TypeScript Node.js NestJS Socket.io MySQL TypeORM Passport Swagger Jest

Related Links

  • course

Project Images