A robust payment processing system with modular architecture, functional programming, and comprehensive testing using node test runner.
- ES Modules with native Node.js 20.6+ dotenv support
- Functional Programming with pure functions and composition
- Modular Architecture with organized structure
- Comprehensive Testing including integration, load, and stress tests
- Idempotency for safe operations
- Circuit Breaker protection against external provider failures
- Async Worker System for payment processing
- Node.js 20.6+
- PostgreSQL
- K6 (for load testing)
git clone <repository-url>
cd payment-processor
npm install
brew install k6
cp env.example .env
npm run dev or start
npm run worker
POST /payments
Content-Type: application/json
Idempotency-Key: unique-key-123

GET /payments/{id}

npm run test:integration
npm run test:load
npm run test:stress
npm run test:concurrency
npm run test:all
Load test:

Stress test:

Concurrency Test

- Payment creation: < 1.5s (P95)
- Payment retrieval: < 500ms (P95)
- Error rate: < 5%
- Throughput: > 100 req/s
- Idempotency: 100% maintained
- Create payment via API
- Validate idempotency key
- Queue payment job
- Process asynchronously via worker
- Route to best available provider
- Execute payment
- Update status in database
- Notify via outbox events