A fault-tolerant, event-driven microservices platform for managing donation campaigns with comprehensive observability.
CareForAll is built using modern microservices architecture with the following key components:
- Event-Driven: RabbitMQ message broker for asynchronous communication
- CQRS Pattern: Separate read and write models for optimal performance
- Transactional Outbox: Guaranteed event delivery with at-least-once semantics
- State Machine: Controlled pledge lifecycle with validation
- Distributed Tracing: OpenTelemetry + Jaeger for request tracking
- Metrics & Monitoring: Prometheus + Grafana for real-time insights
- Centralized Logging: ELK Stack (Elasticsearch + Kibana)
- Runtime: Node.js 18+ with TypeScript
- Database: MongoDB Replica Set (transactions support)
- Message Broker: RabbitMQ 3.12
- API Gateway: NGINX
- Distributed Tracing: Jaeger
- Metrics: Prometheus + Node Exporter
- Visualization: Grafana
- Logging: Elasticsearch + Kibana
- Instrumentation: OpenTelemetry SDK
- Web Framework: Express.js
- ODM: Mongoose
- Validation: Zod
- Logging: Pino
- Metrics: prom-client
- Authentication: JWT (jsonwebtoken)
- Docker Engine 20.10+
- Docker Compose 2.0+
- Node.js 18+ (for local development)
- npm 9+ or yarn 1.22+
- Clone the repository:
git clone <repository-url>
cd careforall- Copy environment variables:
cp .env.example .env- Start the infrastructure:
docker-compose up -d- Verify services are running:
docker-compose psAll services should show "healthy" status within 30-60 seconds.
Once the infrastructure is running, access the following UIs:
| Service | URL | Credentials |
|---|---|---|
| RabbitMQ Management | http://localhost:15672 | admin / admin123 |
| Jaeger UI | http://localhost:16686 | - |
| Prometheus | http://localhost:9090 | - |
| Grafana | http://localhost:3000 | admin / admin |
| Kibana | http://localhost:5601 | - |
| Elasticsearch | http://localhost:9200 | - |
| API Gateway | http://localhost | - |
careforall/
βββ services/ # Microservices
β βββ identity-service/ # User authentication & authorization
β βββ campaign-service/ # Campaign management
β βββ pledge-service/ # Pledge processing (with outbox pattern)
β βββ payment-service/ # Payment processing & webhooks
β βββ totals-service/ # CQRS read model for totals
β βββ comms-service/ # Notifications (bonus)
βββ packages/
β βββ shared/ # Shared TypeScript utilities
β βββ types/ # Type definitions
β βββ utils/ # Utility functions
β β βββ mongodb.ts # Database connection
β β βββ rabbitmq.ts # Message broker
β β βββ logger.ts # Structured logging
β β βββ telemetry.ts # OpenTelemetry setup
β β βββ metrics.ts # Prometheus metrics
β β βββ validation.ts # Zod schemas
β β βββ errors.ts # Custom error classes
β βββ constants/ # Shared constants
βββ prometheus/
β βββ prometheus.yml # Metrics scraping config
βββ grafana/
β βββ datasources/ # Prometheus datasource
β βββ dashboards/ # Pre-built dashboards
βββ nginx/
β βββ nginx.conf # API Gateway configuration
βββ docker-compose.yml # Infrastructure orchestration
βββ .env.example # Environment variables template
βββ README.md # This file
cd packages/shared
npm install
npm run buildEach service can be run independently for development:
cd services/<service-name>
npm install
npm run devNote: Services require MongoDB and RabbitMQ. Either run them via Docker Compose or connect to local instances by updating .env.
# Run tests for all packages
npm run test
# Run tests for specific service
cd services/<service-name>
npm testAll HTTP requests, database queries, and message broker operations are automatically traced. View traces at http://localhost:16686.
Features:
- End-to-end request tracking across services
- Performance bottleneck identification
- Dependency analysis
Pre-configured dashboard available at http://localhost:3000 showing:
- HTTP request rate and latency (p50, p95, p99)
- Business metrics: pledges/sec, payment success rate
- RabbitMQ queue depths
- MongoDB connection pool stats
- Error rates by service
- Outbox event processing lag
All service logs are automatically shipped to Elasticsearch. View and search logs at http://localhost:5601.
Log Structure:
- Structured JSON format
- Service name and environment tags
- Request correlation IDs
- Error stack traces
Critical: Change the following secrets in production:
JWT_SECRET=<strong-random-secret>
WEBHOOK_SECRET=<strong-random-secret>- JWT tokens with 7-day expiry
- Role-based access control (RBAC)
- Anonymous session support for guest donors
Guarantees event delivery even if message broker is down:
- Events written to outbox table in same DB transaction as business data
- Background worker polls outbox and publishes to RabbitMQ
- Exponential backoff retry on failures
- Idempotent event processing
All pledge creation requests require Idempotency-Key header (UUID):
- Prevents duplicate charges
- Uses MongoDB unique index for atomic deduplication
- Race-condition free implementation
Pledge status transitions are validated:
PENDING β AUTHORIZED β CAPTURED β COMPLETED
β β
FAILED REFUNDED
Separate write (Pledge Service) and read (Totals Service) models:
- Write: Optimized for consistency and validation
- Read: Pre-calculated totals for < 50ms response time
- Automatic reconciliation every 5 minutes
# Check mongo-init logs
docker-compose logs mongo-init
# Manually initialize if needed
docker exec -it careforall-mongo mongosh --eval "rs.initiate()"# Check RabbitMQ logs
docker-compose logs rabbitmq
# Verify service is healthy
docker-compose ps rabbitmqEnsure services are on the same Docker network:
docker network ls
docker network inspect careforall-network- Totals API response time: < 50ms (p95)
- Pledge creation: < 200ms (p95)
- Payment webhook processing: < 100ms (p95)
- Throughput: 1000+ requests/second
# Test totals endpoint
ab -n 10000 -c 100 http://localhost/api/totals/<campaignId>GitHub Actions pipeline configured for:
- Automated testing on pull requests
- Docker image building and publishing
- Semantic versioning
- Monorepo change detection
See .github/workflows/ci.yml for details.
API documentation will be available in Phase 2 when services are implemented.
- Create a feature branch
- Make your changes
- Ensure tests pass:
npm test - Ensure linting passes:
npm run lint - Submit a pull request
MIT License - see LICENSE file for details
- [Your Team Name]
Phase 1 Complete: Infrastructure Foundation β
Next: Phase 2 - API Gateway & Identity Service