Skip to content

MattChowski/WinkBackend

Repository files navigation

Wink (previously Circle) - Backend API

A real-time chat and social application backend built with NestJS, featuring WebSocket support, multi-organization workspaces, and channel-based messaging.

Features

  • 🔐 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

Frontend

The frontend application is maintained in a separate repository:

👉 WinkApp Frontend

Please refer to that repository for frontend setup instructions.

Prerequisites

  • Node.js 18+
  • PostgreSQL
  • Redis
  • Docker (optional, for containerized setup)

Getting Started

1. Clone the repository

git clone https://github.com/MattChowski/WinkBackend
cd circle

2. Install dependencies

npm install

3. Environment setup

Create 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"

4. Start dependencies (Docker)

docker-compose up -d

5. Database setup

# Run migrations and seed the database
npm run db:reset

6. Start the server

# Development mode (with hot reload)
npm run start:dev

# Production mode
npm run start:prod

The API will be available at http://localhost:3000

Swagger documentation: http://localhost:3000/api

Scripts

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

Project Structure

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

API Overview

Authentication

  • POST /auth/signup - Register a new user
  • POST /auth/signin - Sign in
  • POST /auth/signout - Sign out
  • POST /auth/switch-organization - Switch active organization

Channels

  • GET /channels - List channels
  • POST /channels - Create a channel
  • GET /channels/:id - Get channel details

Chat

  • GET /chat/channels/:channelId/messages - Get channel messages

WebSocket Events

  • joinChannel - Join a channel room
  • leaveChannel - Leave a channel room
  • sendMessage - Send a message
  • newMessage - Receive new messages (server → client)

Development

Running tests

# Unit tests
npm run test

# E2E tests
npm run test:e2e

# Test coverage
npm run test:cov

Tech Stack

  • Framework: NestJS
  • Database: PostgreSQL + Prisma ORM
  • Cache/Sessions: Redis
  • Real-time: Socket.IO
  • Auth: Passport.js (session-based)
  • Docs: Swagger/OpenAPI

License

This project is private and unlicensed.

About

Wink replaces scattered tools with one central space for how organizations communicate and share knowledge.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors