A serverless real-time messaging service built with NestJS and Pusher, optimized for Vercel deployment.
src/
├── app/ # Application bootstrap and configuration
│ ├── app.module.ts # Main application module
│ ├── app.controller.ts # Basic application endpoints
│ └── app.service.ts # Basic application services
│
├── core/ # Core functionality and infrastructure
│ ├── config/ # Configuration validation and env setup
│ ├── messaging/ # Real-time messaging infrastructure
│ │ ├── services/ # Core messaging services
│ │ ├── controllers/ # Messaging endpoints
│ │ └── gateways/ # WebSocket gateways
│ └── shared/ # Shared services and utilities
│ └── services/ # Common services (Redis, etc.)
│
└── modules/ # Feature modules
├── auth/ # Authentication module
│ ├── controllers/ # Auth endpoints
│ ├── services/ # Auth services
│ ├── middleware/ # Auth middleware
│ └── guards/ # Auth guards
└── chat/ # Chat functionality
├── controllers/ # Chat endpoints
├── services/ # Chat business logic
└── dto/ # Chat data transfer objects
- Application bootstrap and main configuration
- Root module configuration
- Basic health check endpoints
- Contains essential infrastructure and shared functionality
- Not specific to any business feature
- Reusable across different parts of the application
- Environment validation
- Configuration schemas
- Environment variable management
- Real-time messaging infrastructure
- Pusher integration
- WebSocket handling
- Message routing and delivery
- Common services (Redis)
- Shared utilities and helpers
- Cross-cutting concerns
- Feature-specific modules
- Business logic implementation
- Domain-specific functionality
- Supabase authentication integration
- Session management
- User authentication and authorization
- Token handling and validation
- Chat room management
- Message handling
- Real-time chat functionality
- User presence management
- Serverless-first architecture
- Real-time messaging with Pusher
- Redis caching for performance
- Supabase authentication
- WebSocket support
- Modular design
- Type-safe implementation
- Clone the repository
- Install dependencies:
npm install
- Set up environment variables:
cp .env.example .env.local
- Start the development server:
npm run start:dev
Required environment variables:
PUSHER_APP_ID
: Pusher application IDPUSHER_KEY
: Pusher keyPUSHER_SECRET
: Pusher secretPUSHER_CLUSTER
: Pusher cluster regionREDIS_URL
: Redis connection URLSUPABASE_URL
: Supabase project URLSUPABASE_SERVICE_KEY
: Supabase service keyCORS_ORIGIN
: Allowed CORS origin