This project is a comprehensive learning exercise for RabbitMQ, implementing a payment processing system with progressive complexity levels from beginner to expert.
A payment processing gateway that handles transactions, refunds, and fraud detection. RabbitMQ is used for asynchronous processing to avoid blocking users during payment verification.
- Node.js - Runtime environment
- NestJS - Web framework
- TypeORM - ORM for database operations
- PostgreSQL - Database
- RabbitMQ - Message broker
- Stripe - Payment gateway integration
- Simple queue for payment requests
- Basic producer/consumer pattern
- JSON message handling
- Durable queues with manual acknowledgments
- Fraud detection with delays
- Audit trail logging
- Load balancing across workers
- Flexible routing with topic patterns
- Different handlers for different transaction types
- Priority queues for high-value transactions
- Dead-letter queues for failed transactions
- RPC for real-time status checks
- Retry mechanisms
- Fault tolerance
- Docker and Docker Compose
- Node.js 18+
- Clone the repository
git clone <repo-url>
cd e-commerce-rabbitmq- Install dependencies
npm install- Start services with Docker Compose
docker-compose up -dThis will start:
- RabbitMQ on port 5672 (Management UI on 15672)
- PostgreSQL on port 5432
Access RabbitMQ Management UI: http://localhost:15672
- Username: admin
- Password: admin123
- Create
.envfile
cp .env.example .env
# Update with your Stripe keys- Run the application
npm run start:devsrc/
├── payment/ # Payment processing module
│ ├── entities/ # TypeORM entities
│ ├── dto/ # Data transfer objects
│ ├── services/ # Business logic
│ └── queue/ # Queue handlers
├── rabbitmq/ # RabbitMQ configuration
│ ├── beginner/ # Basic queue pattern
│ ├── intermediate/ # Work queues
│ ├── advanced/ # Topic exchanges
│ └── expert/ # DLQ, RPC patterns
└── common/ # Shared utilities
POST /payments- Create a paymentGET /payments/:id- Get payment statusPOST /payments/:id/refund- Refund a payment
- Start with Beginner - Understand basic queuing
- Move to Intermediate - Learn about work queues and durability
- Explore Advanced - Study topic exchanges and routing
- Master Expert - Implement production-grade features
# Development
npm run start:dev
# Build
npm run build
# Production
npm run start:prod
# View RabbitMQ Management
open http://localhost:15672
# Check containers
docker psThis is a learning project focused on understanding RabbitMQ patterns. It includes:
- Multiple complexity levels
- Real-world scenarios
- Best practices
- Production considerations