A production-ready, event-driven microservices e-commerce backend built with modern technologies
QueueCommerce demonstrates enterprise-level microservices architecture with real-time event processing, payment integration, and scalable infrastructure. Built with NestJS, TypeScript, RabbitMQ, and integrated with Stripe for payment processing.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT APPLICATIONS β
β (Web, Mobile, Admin Panel) β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββ
β API GATEWAY (Future) β
β Authentication β Rate Limiting β Routing β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββΌββββββββββββββββββ¬ββββββββββββββββββββββββββ
β β β β
βββββΌβββββ βββββββΌββββββ ββββββΌββββββ βββββββββββ
β ORDER β β PAYMENT β βINVENTORY β β USER β
βSERVICE β β SERVICE β β SERVICE β βSERVICE β
βPort:3000β βPort:3003 β βPort:3001 β β(Future) β
βββββ¬βββββ βββββββ¬ββββββ ββββββ¬ββββββ βββββββββββ
β β β
β β β
βββββΌβββββ βββββββΌββββββ ββββββΌββββββ βββββββββββ
βMongoDB β β MongoDB β β MongoDB β βNOTIFICATIONβ
βOrders β β Payments β βInventory β β SERVICE β
β DB β β DB β β DB β β(Future) β
ββββββββββ βββββββββββββ ββββββββββββ βββββββββββ
β
β
βββββββΌββββββ
β STRIPE β
β API β
βββββββββββββ
βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββΌββββββββββ
β RABBITMQ β
β MESSAGE BROKER β
β Event Bus β
βββββββββββββββββββββ
- Port: 3000
- Database: MongoDB Atlas
- Features:
- Complete order lifecycle management
- Real-time event publishing for downstream services
- Order status tracking and updates
- Customer information management
- Comprehensive validation and error handling
- API: RESTful with OpenAPI documentation
- Events: Publishes
order.created
,inventory.reservation.requested
,payment.process.requested
- Port: 3001
- Database: MongoDB Atlas
- Features:
- Real-time product catalog management
- Advanced inventory reservation system
- Stock quantity tracking with automatic updates
- Low stock alerting system
- Product search and filtering capabilities
- API: RESTful with OpenAPI documentation
- Events: Consumes inventory requests, publishes reservation confirmations
- Port: 3003
- Database: MongoDB Atlas
- External Integration: Stripe Payment Platform
- Features:
- Real Stripe payment intent creation
- Payment confirmation and refund processing
- Webhook handling for payment status updates
- Secure payment data management
- Multi-currency support (USD default)
- API: RESTful with OpenAPI documentation
- Events: Consumes payment requests, publishes payment confirmations
- Message Broker: RabbitMQ with Docker deployment
- Pattern: Publish-Subscribe with reliable message delivery
- Reliability: Durable queues with acknowledgments
- Scalability: Horizontal scaling ready
- Strategy: Database per service pattern
- Provider: MongoDB Atlas (Cloud-hosted)
- Features: Connection pooling, automatic failover, global distribution
- Security: Encrypted connections, authentication
- Provider: Stripe (Industry-leading payment platform)
- Mode: Test environment with real API integration
- Features: Payment intents, webhooks, refunds, multi-currency
- Security: PCI-compliant, encrypted communication
- β Order Service with event publishing
- β Inventory Service with real-time stock management
- β Payment Service with Stripe integration
- β RabbitMQ event-driven communication
- β MongoDB Atlas integration
-
π API Gateway
- Centralized routing and load balancing
- JWT/OAuth2 authentication
- Rate limiting and throttling
- Request/response transformation
- API versioning
-
π User Service
- User registration and authentication
- Role-based access control (RBAC)
- Profile management
- Session management
- Password security and recovery
-
π Notification Service
- Email notifications (order confirmations, payment updates)
- SMS notifications for critical updates
- Push notifications for mobile apps
- Template management
- Delivery tracking and analytics
-
π Redis Integration
- Session storage and caching
- Real-time pub/sub messaging
- Cache-aside pattern implementation
- Performance optimization
-
π CQRS & Event Sourcing
- Command Query Responsibility Segregation
- Event store implementation
- Read/write model separation
- Event replay capabilities
-
π Security Hardening
- JWT/OAuth2 authentication
- Rate limiting per user/IP
- Circuit breaker patterns
- Input validation and sanitization
- HTTPS enforcement
-
π Monitoring Stack
- Prometheus metrics collection
- Grafana dashboards and alerting
- Custom business metrics
- Performance monitoring
-
π Logging & Tracing
- ELK Stack (Elasticsearch, Logstash, Kibana)
- Distributed tracing with Jaeger/Zipkin
- Structured logging across services
- Error tracking and analytics
-
π Testing Suite
- Jest unit testing framework
- Integration testing
- Contract testing between services
- Load testing and performance benchmarks
-
π Containerization
- Docker containers for all services
- Multi-stage builds for optimization
- Container security scanning
- Image registry management
-
π Orchestration
- Kubernetes deployment manifests
- Helm charts for configuration management
- Auto-scaling policies
- Rolling deployments
-
π DevOps Pipeline
- CI/CD with automated testing
- Infrastructure as Code (IaC)
- Environment management
- Automated security scanning
Technology | Purpose | Status |
---|---|---|
NestJS | Node.js framework with dependency injection | β Implemented |
TypeScript | Type-safe JavaScript with modern features | β Implemented |
Node.js | Runtime environment | β Implemented |
Technology | Purpose | Status |
---|---|---|
MongoDB Atlas | Cloud-hosted NoSQL database | β Implemented |
RabbitMQ | AMQP message broker | β Implemented |
Redis | In-memory cache and pub/sub | π Planned |
Technology | Purpose | Status |
---|---|---|
Stripe | Payment processing platform | β Implemented |
SendGrid | Email delivery service | π Planned |
Twilio | SMS and communication APIs | π Planned |
Technology | Purpose | Status |
---|---|---|
Docker | Containerization | β Partial (RabbitMQ) |
Kubernetes | Container orchestration | π Planned |
Prometheus | Metrics and monitoring | π Planned |
Grafana | Visualization and dashboards | π Planned |
- Node.js 18+ with npm
- Docker Desktop
- MongoDB Atlas account
- Stripe test account
-
Clone and Install
git clone https://github.com/your-org/QueueCommerce.git cd QueueCommerce # Install dependencies for all services cd services/order-service && npm install cd ../inventory-service && npm install cd ../payment-service && npm install
-
Infrastructure Setup
# Start RabbitMQ with management interface docker run -d --hostname queuecommerce-rabbit \ --name queuecommerce-rabbit \ -p 5672:5672 -p 15672:15672 \ rabbitmq:3-management # Configure RabbitMQ admin user docker exec queuecommerce-rabbit rabbitmqctl add_user admin admin123 docker exec queuecommerce-rabbit rabbitmqctl set_user_tags admin administrator docker exec queuecommerce-rabbit rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
-
Environment Configuration
# Copy environment templates cp services/order-service/.env.example services/order-service/.env cp services/inventory-service/.env.example services/inventory-service/.env cp services/payment-service/.env.example services/payment-service/.env # Configure MongoDB Atlas connections # Configure Stripe test API keys # Configure RabbitMQ connection strings
-
Start Services
# Terminal 1 - Order Service cd services/order-service && npm start # Terminal 2 - Inventory Service cd services/inventory-service && npm start # Terminal 3 - Payment Service cd services/payment-service && npm start
-
Health Checks
# Verify all services are running curl http://localhost:3000 # Order Service curl http://localhost:3001 # Inventory Service curl http://localhost:3003 # Payment Service
-
End-to-End Flow Test
# 1. Check available products curl http://localhost:3001/products # 2. Create test order curl -X POST http://localhost:3000/orders \ -H "Content-Type: application/json" \ -d '{ "customer": { "customerId": "test_customer_001", "email": "[email protected]", "firstName": "John", "lastName": "Doe" }, "items": [{ "productId": "laptop-001", "productName": "Gaming Laptop", "quantity": 1, "unitPrice": 129999 }], "shippingAddress": { "street": "123 Test Street", "city": "Test City", "state": "TC", "postalCode": "12345", "country": "USA" }, "paymentMethod": "credit_card" }' # 3. Verify payment was created curl http://localhost:3003/payments
Service | Documentation | Base URL |
---|---|---|
Order Service | http://localhost:3000/api | http://localhost:3000 |
Inventory Service | http://localhost:3001/api | http://localhost:3001 |
Payment Service | http://localhost:3003/api/docs | http://localhost:3003 |
POST /orders
- Create new orderGET /orders
- List orders with paginationGET /orders/:id
- Get order detailsPATCH /orders/:id
- Update order statusPOST /orders/:id/cancel
- Cancel order
GET /products
- List products with filteringPOST /products
- Add new productGET /products/:id
- Get product detailsPATCH /products/:id
- Update productGET /inventory/reservations
- View inventory reservations
POST /payments
- Create payment intentGET /payments
- List paymentsPOST /payments/:id/confirm
- Confirm paymentPOST /payments/:id/refund
- Process refundPOST /payments/webhook/stripe
- Stripe webhook handler
- Horizontal Scaling: Services designed as stateless containers
- Database Sharding: MongoDB Atlas supports automatic sharding
- Load Balancing: Ready for load balancer integration
- Caching Strategy: Redis integration planned for performance optimization
- Data Encryption: TLS in transit, encrypted at rest
- API Security: Rate limiting and authentication planned
- Payment Security: PCI-compliant Stripe integration
- Environment Security: Secrets management via environment variables
- Health Checks: Built-in health endpoints
- Structured Logging: Comprehensive logging with context
- Error Tracking: Detailed error handling and reporting
- Performance Metrics: Application-level metrics collection
- Fault Tolerance: Circuit breaker patterns planned
- Message Reliability: Durable queues with acknowledgments
- Data Consistency: Eventual consistency through event sourcing
- Backup Strategy: Automated MongoDB Atlas backups
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature
) - Follow coding standards and add tests
- Commit changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open Pull Request
- TypeScript strict mode enabled
- ESLint and Prettier for code formatting
- Comprehensive error handling
- Unit and integration tests required
- API documentation updates
- Single Responsibility Principle
- Database per service
- Event-driven communication
- Idempotent operations
- Graceful error handling
This project is licensed under the MIT License - see the LICENSE file for details.
QueueCommerce - Building the future of e-commerce with modern microservices architecture.