Skip to content

dev-josias/collab

Repository files navigation

Collab Platform

A microservices-based collaboration platform with real-time chat, authentication, and workspace management.

Architecture

This is a monorepo containing multiple services and shared libraries:

Services

  • auth - Authentication service (Fastify + Prisma + PostgreSQL)
  • chat - Real-time chat service (Fastify + WebSocket + RabbitMQ + Redis)
  • storage - File storage service
  • analytics - Analytics service

Libraries

  • @collab/prisma - Shared Prisma client with database models
  • @collab/plugins - Shared plugins (Prometheus metrics)
  • @collab/events - Event envelope types
  • @collab/types - Shared TypeScript types
  • @collab/redis-utils - Redis utilities and key helpers

Tech Stack

  • Runtime: Node.js
  • Framework: Fastify
  • Database: PostgreSQL (via Prisma)
  • Message Queue: RabbitMQ
  • Cache: Redis
  • Metrics: Prometheus
  • TypeScript: Full type safety across services
  • Monorepo: Yarn workspaces

Getting Started

Prerequisites

  • Node.js 18+
  • Docker & Docker Compose
  • PostgreSQL
  • Redis
  • RabbitMQ

Installation

# Install dependencies
yarn install

# Generate Prisma clients
yarn workspace @collab/prisma prisma:generate

# Start infrastructure (PostgreSQL, Redis, RabbitMQ)
docker-compose -f infra/docker/docker-compose.yml up -d

# Set up environment variables
cp .env.example .env
# Edit .env with your configuration

# Run migrations
yarn workspace @collab/prisma prisma:migrate dev

Development

# Run auth service
yarn workspace auth dev

# Run chat service
yarn workspace chat dev

Environment Variables

Each service requires specific environment variables. See .env.example files in each service directory.

Common variables:

  • DATABASE_URL - PostgreSQL connection string
  • REDIS_URL - Redis connection string
  • RABBITMQ_URL - RabbitMQ connection string
  • JWT_SECRET - Secret for JWT token signing
  • REFRESH_SECRET - Secret for refresh tokens

Features

Authentication Service

  • User registration and login
  • JWT-based authentication
  • Refresh token rotation
  • Rate limiting
  • Prometheus metrics

Chat Service

  • Real-time WebSocket messaging
  • Channel-based chat
  • Message replay on reconnect
  • Typing indicators
  • Read receipts
  • RabbitMQ message distribution
  • Redis offset tracking

Project Structure

collab-platform/
├── libs/              # Shared libraries
│   ├── prisma/        # Database client and schemas
│   ├── plugins/       # Fastify plugins (metrics)
│   ├── events/        # Event types
│   ├── types/         # TypeScript types
│   └── redis-utils/   # Redis utilities
├── services/          # Microservices
│   ├── auth/          # Authentication service
│   ├── chat/          # Chat service
│   ├── storage/       # Storage service
│   └── analytics/     # Analytics service
├── infra/             # Infrastructure configs
│   └── docker/        # Docker compose and configs
└── tsconfig/          # TypeScript configurations

Metrics

All services expose Prometheus metrics at /metrics:

  • HTTP request duration and counts
  • WebSocket connection metrics
  • RabbitMQ message metrics
  • Database query metrics
  • Authentication metrics
  • Custom business metrics

API Documentation

Auth Service (/auth)

  • POST /register - Register new user
  • POST /login - User login
  • POST /refresh - Refresh access token
  • POST /logout - Logout user
  • GET /me - Get current user
  • GET /health - Health check
  • GET /metrics - Prometheus metrics

Chat Service (/chat)

  • GET /ws - WebSocket connection endpoint
  • GET /channels/:id/messages - Get channel messages
  • GET /health - Health check
  • GET /metrics - Prometheus metrics

Development Guidelines

  1. Type Safety: All code is TypeScript with strict mode enabled
  2. Code Style: Follow existing patterns and use ESLint
  3. Testing: Write tests for new features
  4. Documentation: Update README and add JSDoc comments
  5. Commits: Use conventional commit messages

License

MIT

About

Collab Platform Leveraging Production Good Practices

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published