A microservice architecture using NestJS, gRPC, and Kafka (in progress).
- Node.js: v22
- Package Manager: npm
- Database: MySQL
- Framework: NestJS
- Communication: gRPC
- Message Broker: Kafka (In Progress)
.
├── api-gateway/ # API Gateway Service
├── grpc-user/ # User Microservice
├── shared/ # Shared Resources
│ ├── errors/ # Error Handling
│ └── proto/ # Protocol Buffers
└── docker/ # Docker Configuration
- Node.js v22
- MySQL
- npm
- Create
.envfiles in bothapi-gatewayandgrpc-userdirectories:
# api-gateway/.env
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=root
DB_DATABASE=user_db# Install dependencies
npm install# ts compile proto files
npm run pbcompile
# Start User Service
npm run start:user
# Start API Gateway
npm run start:api- api-gateway: HTTP to gRPC gateway
- grpc-user: User management microservice
- shared: Common resources (protos, errors)
- Protocol Buffers for service definitions
- Type-safe communication between services
- Efficient binary protocol
- Message broker for event-driven architecture
- Asynchronous communication between services
- Event sourcing and CQRS patterns
Once the services are running, you can access the Swagger documentation at:
http://localhost:3000/api
The project implements a comprehensive error handling system:
- gRPC to HTTP error mapping
- Consistent error response format
- Detailed error logging
- Kafka integration
- Event-driven architecture
- CQRS implementation
- Additional microservices