A distributed microservices platform built with NestJS, Nx monorepo, and event-driven architecture for scalable job processing and user authentication.
Trigger is a modern microservices platform designed for handling distributed job processing with the following key components:
- π Auth Service (
apps/auth) - Authentication and user management with gRPC API - π Jobs Service (
apps/jobs) - Job management and scheduling with GraphQL API - β‘ Executor Service (
apps/executor) - Job execution engine with Pulsar messaging
- π GraphQL (
libs/graphql) - Shared GraphQL schemas and utilities - π gRPC (
libs/grpc) - Protocol buffer definitions and gRPC clients - π― NestJS (
libs/nestjs) - Common NestJS utilities and decorators - πΎ Prisma (
libs/prisma) - Database client and schema management - π‘ Pulsar (
libs/pulsar) - Apache Pulsar messaging client and utilities
- Node.js 18+
- Docker and Docker Compose
- PostgreSQL database
- Apache Pulsar cluster
-
Install dependencies:
npm install
-
Set up environment variables:
# Root environment configuration cp .env.example .env # Edit .env with your configuration # Application-specific environment files cp apps/auth/.env.example apps/auth/.env cp apps/jobs/.env.example apps/jobs/.env cp apps/executor/.env.example apps/executor/.env # Edit each app's .env file with service-specific configuration
-
Generate Prisma client:
npx nx run auth:generate-prisma
-
Start all services:
npm start
This will start:
- Auth Service: http://localhost:3000/api
- Jobs Service: http://localhost:3001/api
- Executor Service: http://localhost:3002/api
Start specific services:
# Auth service only
npx nx serve auth
# Jobs service only
npx nx serve jobs
# Executor service only
npx nx serve executor- Purpose: User authentication and authorization
- Technologies: NestJS, Prisma, gRPC, GraphQL
- Features:
- User registration and login
- JWT token management
- gRPC microservice for inter-service communication
- GraphQL API for frontend integration
- Purpose: Job management and scheduling
- Technologies: NestJS, Apache Pulsar, GraphQL
- Features:
- Job creation and scheduling
- Job status tracking
- Event-driven job processing
- GraphQL API with job providers discovery
- Purpose: Job execution engine
- Technologies: NestJS, Apache Pulsar
- Features:
- Consumes jobs from Pulsar queues
- Executes job workloads
- Reports job completion status
- Scalable worker architecture
The project includes Docker configurations for containerized deployment:
# Build all services
docker-compose build
# Start the entire stack
docker-compose up -d
# View logs
docker-compose logs -fapps/
βββ auth/ # Authentication service
βββ executor/ # Job execution service
βββ jobs/ # Job management service
libs/
βββ graphql/ # Shared GraphQL utilities
βββ grpc/ # gRPC protocol definitions
βββ nestjs/ # Common NestJS utilities
βββ prisma/ # Database client
βββ pulsar/ # Messaging client
# Build all projects
npx nx run-many -t build
# Build specific project
npx nx build auth# Run all tests
npx nx run-many -t test
# Test specific project
npx nx test auth# Generate new NestJS app
npx nx g @nx/nest:app my-service
# Generate new library
npx nx g @nx/node:lib my-lib
# Generate Prisma migrations
npx nx run auth:prisma-migrate-devKey environment variables to configure:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/trigger"
# Pulsar
PULSAR_SERVICE_URL="pulsar://localhost:6650"
# JWT
JWT_SECRET="your-secret-key"
# gRPC
GRPC_PORT=50051The project uses a custom module resolver (module-resolver.js) to handle internal library dependencies in the monorepo. This ensures proper module resolution in both development and production environments.
- Framework: NestJS
- Monorepo: Nx
- Database: PostgreSQL with Prisma ORM
- Messaging: Apache Pulsar
- API: GraphQL + gRPC
- Authentication: JWT
- Containerization: Docker
- Language: TypeScript
- Jobs Service: http://localhost:3001/graphql
- Auth Service: http://localhost:3000/graphql
- Auth Service: localhost:50051
I use Linear for issue tracking and project management throughout this project. Linear's streamlined workflow has been instrumental in maintaining my development velocity by providing:
- Automated branch naming - Each issue automatically generates branch names (e.g.,
side-22-dockerize-all-microservices) - Seamless PR linking - Pull requests are automatically linked to Linear issues for complete traceability
- Milestone tracking - Clear progress visualization across development phases
- Efficient workflow - Streamlined task management and status updates
The branch naming convention you see across this repository directly reflects Linear's issue tracking system, ensuring every code change I make is tied to a specific feature or bug fix.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Add a products module with full CRUD operations
- Integrate Drizzle ORM for database operations in the products module
- Implement gRPC communication protocol for the products service
- Prepare Kubernetes manifests
- Deploy to AWS Elastic Kubernetes Service (EKS)
- Configure AWS-specific Helm charts and values