A real-time chat and social application backend built with NestJS, featuring WebSocket support, multi-organization workspaces, and channel-based messaging.
- 🔐 Authentication - Session-based auth with Passport.js
- 🏢 Multi-organization - Users can belong to multiple organizations
- 💬 Real-time messaging - WebSocket-powered chat via Socket.IO
- 📢 Channels - Public and private channel support
- 🗄️ PostgreSQL - Prisma ORM with PostgreSQL database
- 🔄 Redis - Session storage and caching
- 📖 API Documentation - Swagger/OpenAPI docs
The frontend application is maintained in a separate repository:
Please refer to that repository for frontend setup instructions.
- Node.js 18+
- PostgreSQL
- Redis
- Docker (optional, for containerized setup)
git clone https://github.com/MattChowski/WinkBackend
cd circlenpm installCreate a .env file in the root directory:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/circle?schema=public"
REDIS_URL="redis://localhost:6379"
SESSION_SECRET="your-session-secret"docker-compose up -d# Run migrations and seed the database
npm run db:reset# Development mode (with hot reload)
npm run start:dev
# Production mode
npm run start:prodThe API will be available at http://localhost:3000
Swagger documentation: http://localhost:3000/api
| Command | Description |
|---|---|
npm run start:dev |
Start in development mode with hot reload |
npm run start:prod |
Start in production mode |
npm run build |
Build the application |
npm run test |
Run unit tests |
npm run test:e2e |
Run end-to-end tests |
npm run db:reset |
Reset database, run migrations, and seed |
npm run db:seed |
Seed the database |
npm run lint |
Lint and fix code |
src/
├── common/ # Shared utilities, decorators, adapters
├── core/ # Core modules (database)
├── generated/ # Prisma generated client
├── modules/
│ ├── auth/ # Authentication & authorization
│ ├── channels/ # Channel management
│ ├── chat/ # Messaging service
│ ├── events/ # WebSocket gateway
│ ├── organizations/
│ └── users/
└── types/ # TypeScript type definitions
prisma/
├── schema.prisma # Main Prisma schema
├── models/ # Prisma model definitions
├── migrations/ # Database migrations
└── seed.ts # Database seeder
POST /auth/signup- Register a new userPOST /auth/signin- Sign inPOST /auth/signout- Sign outPOST /auth/switch-organization- Switch active organization
GET /channels- List channelsPOST /channels- Create a channelGET /channels/:id- Get channel details
GET /chat/channels/:channelId/messages- Get channel messages
joinChannel- Join a channel roomleaveChannel- Leave a channel roomsendMessage- Send a messagenewMessage- Receive new messages (server → client)
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:cov- Framework: NestJS
- Database: PostgreSQL + Prisma ORM
- Cache/Sessions: Redis
- Real-time: Socket.IO
- Auth: Passport.js (session-based)
- Docs: Swagger/OpenAPI
This project is private and unlicensed.