Skip to content

ananeridev/payment-processor

Repository files navigation

Payment Processor

A robust payment processing system with modular architecture, functional programming, and comprehensive testing using node test runner.

Features

  • 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

Prerequisites

  • Node.js 20.6+
  • PostgreSQL
  • K6 (for load testing)

Installations

git clone <repository-url>
cd payment-processor
npm install
brew install k6 
cp env.example .env

Running

npm run dev or start
npm run worker

API

Create Payment

POST /payments
Content-Type: application/json
Idempotency-Key: unique-key-123
Screenshot 2025-09-23 at 12 44 14

Get Payment

GET /payments/{id}
Screenshot 2025-09-23 at 12 43 41

Testing

npm run test:integration

npm run test:load
npm run test:stress
npm run test:concurrency

npm run test:all

Stress test evidences

Load test:

Screenshot 2025-09-23 at 14 27 34

Stress test:

Screenshot 2025-09-23 at 14 28 34

Concurrency Test

Screenshot 2025-09-23 at 14 32 54

Performance Targets collected

  • Payment creation: < 1.5s (P95)
  • Payment retrieval: < 500ms (P95)
  • Error rate: < 5%
  • Throughput: > 100 req/s
  • Idempotency: 100% maintained

Arch

  1. Create payment via API
  2. Validate idempotency key
  3. Queue payment job
  4. Process asynchronously via worker
  5. Route to best available provider
  6. Execute payment
  7. Update status in database
  8. Notify via outbox events

About

payment processor using nodejs and modular arch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published