Built for API Avengers Hackathon - November 21, 2025
CareForAll is a fault-tolerant, event-driven medical fundraising platform built with microservices architecture. This project demonstrates enterprise-grade patterns like Transactional Outbox, Webhook Idempotency, State Machines, and CQRS to solve real-world distributed systems challenges.
Problem Statement: The original CareForAll platform failed catastrophically during peak traffic due to:
- Duplicate charges from webhook retries
- Lost donations from mid-request crashes
- Database overload from inefficient totals calculation
- No monitoring or observability
- Backward state transitions breaking data integrity
Our Solution: A robust, scalable system that survives these failures and more!
- Identity Service (Port 3001): User authentication, JWT, anonymous sessions
- Campaign Service (Port 3002): Campaign CRUD operations
- Pledge Service (Port 3003): Pledge management with Transactional Outbox Pattern
- Payment Service (Port 3004): Mock payment provider with webhook idempotency
- Totals Service (Port 3005): CQRS read model for fast campaign totals
- Frontend: Vanilla HTML/CSS/JS single-page application
- MongoDB: Replica set for transaction support
- RabbitMQ: Message broker for event-driven architecture
- NGINX: API Gateway and reverse proxy
- Prometheus: Metrics collection
- Grafana: Monitoring dashboards
- Solves dual-write problem (database + message broker)
- Atomic writes using MongoDB transactions
- Background worker publishes events reliably
- Automatic retries with exponential backoff
- Prevents duplicate charges from payment provider retries
- WebhookLog with unique constraint enforcement
- Atomic webhook processing using transactions
- Prevents invalid state transitions (e.g., CAPTURED β AUTHORIZED)
- Complete state history tracking with timestamps
- Validates all transitions before applying
- Fast totals queries (<100ms)
- Event-driven updates (no expensive aggregations)
- Eventually consistent totals
- Idempotent event processing
- System survives service failures gracefully
- No data loss during outages
- Automatic recovery when services restart
- Kill Switch Demo: Totals service can fail, system continues, auto-recovers!
- Docker & Docker Compose
- Node.js 18+ (for local development)
- Git
# Clone repository
git clone <repo-url>
cd Televerse-2
# Start all services
docker-compose up -d
# Wait for services to be ready (30 seconds)
sleep 30
# Check service status
docker-compose ps
# Access the application
open http://localhost:8080- Frontend: http://localhost:8080
- API Gateway: http://localhost:8080/api
- RabbitMQ Management: http://localhost:15672 (admin/admin123)
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin123)
# Install dependencies
npm install
# Run all integration tests
npm run test:integration
# Run with coverage
npm run test:coverageTest Suites:
- β End-to-End Donation Flow (12 tests)
- β Idempotency Tests (8 tests)
- β State Machine Validation (11 tests)
- β Fault Tolerance Tests (7 tests)
Total: 38 integration tests
# Run manual API tests
bash tests/manual-api-tests.sh- Navigate to http://localhost:8080
- Register a new user
- Create a campaign
- Make a donation (anonymous or authenticated)
- View admin dashboard
- Check donation history
Demonstrate system resilience by simulating service failure:
# 1. Create initial pledges ($100 Γ 3 = $300)
# ... make 3 donations via UI ...
# 2. Stop Totals Service
docker stop careforall-totals
# 3. Make more donations ($100 Γ 2 = $200)
# ... donations still work! System resilient!
# 4. Verify totals are stale (still $300)
curl http://localhost:8080/api/totals/<campaign-id>
# 5. Show RabbitMQ queue building up
# Access http://localhost:15672 and check queue depth
# 6. Restart Totals Service
docker start careforall-totals
# 7. Wait 10 seconds for recovery
sleep 10
# 8. Verify totals updated ($500)
curl http://localhost:8080/api/totals/<campaign-id>Key Message: The old system would have crashed immediately. Ours survived and auto-recovered! π
All services expose /metrics endpoint with:
- HTTP request counters
- Response time histograms
- Custom business metrics (outbox pending events, etc.)
Pre-configured dashboards for:
- Service health overview
- Request rates and latencies
- Pledge creation rates
- Outbox event lag
- RabbitMQ queue depths
Televerse-2/
βββ services/
β βββ identity-service/ # Authentication & authorization
β βββ campaign-service/ # Campaign management
β βββ pledge-service/ # Pledges with Outbox pattern
β βββ payment-service/ # Payment processing
β βββ totals-service/ # CQRS read model
βββ frontend/ # Vanilla HTML/CSS/JS app
β βββ index.html # Homepage
β βββ campaign-detail.html # Campaign detail + donation
β βββ login.html # Authentication
β βββ create-campaign.html # Campaign creation
β βββ admin.html # Admin dashboard
β βββ history.html # Donation history
β βββ css/style.css # Styles
β βββ js/
β βββ api.js # API client
β βββ app.js # Application logic
βββ shared/ # Shared utilities
β βββ utils/
β β βββ mongodb.js # DB connection
β β βββ rabbitmq.js # Message broker
β β βββ logger.js # Winston logger
β βββ constants.js # Shared constants
βββ tests/
β βββ integration/ # Integration test suites
β β βββ e2e-flow.test.js
β β βββ idempotency.test.js
β β βββ state-machine.test.js
β β βββ fault-tolerance.test.js
β βββ manual-api-tests.sh # Manual testing script
βββ nginx/ # API Gateway config
βββ prometheus/ # Prometheus config
βββ grafana/ # Grafana dashboards
βββ docs/ # Documentation
β βββ phase2-validation.md
β βββ phase3-validation.md
β βββ phase4-validation.md
βββ docker-compose.yml # Service orchestration
βββ PHASE.md # Implementation plan
| Phase | Status | Description |
|---|---|---|
| Phase 1 | β | Infrastructure Setup (MongoDB, RabbitMQ, Monitoring) |
| Phase 2 | β | Identity & Campaign Services |
| Phase 3 | β | Critical Business Logic (Pledge, Payment, Totals) |
| Phase 4 | β | Frontend + Integration Testing |
| Phase 5 | π | Observability + CI/CD (Next) |
POST /api/auth/register- Register userPOST /api/auth/login- Login userPOST /api/auth/anonymous-session- Create anonymous sessionGET /api/users/profile- Get user profile (JWT required)
GET /api/campaigns- List all campaignsGET /api/campaigns/:id- Get campaign detailsPOST /api/campaigns- Create campaign (JWT required)
POST /api/pledges- Create pledge (requires Idempotency-Key header)GET /api/pledges/:id- Get pledge detailsPATCH /api/pledges/internal/:id/status- Update pledge status (internal)
POST /api/payments/intent- Create payment intentPOST /api/payments/authorize- Authorize paymentPOST /api/payments/capture- Capture paymentPOST /api/payments/webhooks- Webhook handler (payment provider)
GET /api/totals/:campaignId- Get campaign totals (fast!)
Backend:
- Node.js 18
- Express.js
- MongoDB (Replica Set)
- RabbitMQ
- Mongoose ODM
- Winston (Logging)
- Prometheus Client
Frontend:
- Vanilla JavaScript (ES6+)
- HTML5
- CSS3 (Grid, Flexbox)
- No frameworks (pure web standards)
Infrastructure:
- Docker & Docker Compose
- NGINX
- Prometheus
- Grafana
Testing:
- Jest
- Supertest
- MongoDB Driver
- GET /api/totals/:id: ~15ms average (CQRS benefit)
- GET /api/campaigns: ~45ms average
- POST /api/pledges: ~120ms average
- Outbox Worker: Events published within 5-6 seconds
- Webhook Processing: 2-3 seconds
- End-to-End Donation: ~20 seconds (including all webhooks)
β
User can browse campaigns
β
User can make anonymous donations
β
User can register and login
β
User can create campaigns
β
Admin can view dashboard
β
Payment flow completes successfully
β
Totals update in real-time
β
Idempotency prevents duplicates
β
State machine enforces valid transitions
β
System survives service failures
β
Integration tests pass (38 tests)
β
Kill Switch demo works reliably
- Architecture & Design: Phase 1 Complete
- Core Services: Phases 2-3 Complete
- Frontend & Testing: Phase 4 Complete
- Built for: API Avengers Hackathon
ISC
Built to solve the real-world challenges faced by the original CareForAll platform. This project demonstrates that with proper architecture patterns and fault-tolerance mechanisms, distributed systems can be both resilient and maintainable.
Ready for Demo! π
For detailed validation results, see: