This project is a backend payment system inspired by eSewa/Khalti, built with a focus on:
- Financial correctness
- Distributed systems design
- Backend interview readiness
It implements real-world payment system patterns such as:
- Double-entry ledger
- Idempotent transactions
- Saga-based workflows
- Event-driven architecture
- Node.js (TypeScript)
- Fastify (high-performance HTTP framework)
- Prisma ORM
- PostgreSQL (ACID-compliant financial storage)
- Docker & Docker Compose
- Redis (caching, idempotency, rate limiting)
- Kafka (event-driven communication)
- MinIO (object storage for KYC)
- Pino (structured logging)
- Prometheus (metrics)
- OpenTelemetry (tracing)
- Jest (unit + integration)
- Testcontainers (real DB in tests)
- k6 (load testing)
- Clear domain boundaries
- Easier to develop within 1 month
- Future-ready for microservices
- Every transaction = debit + credit
- Immutable ledger entries
- Financial correctness guaranteed
- Prevents duplicate payments
- Redis + DB-level enforcement
- All money stored as
BIGINT(paisa) - Avoids floating point errors
apps/api→ Main backend serviceapps/worker→ Kafka consumerspackages/shared-types→ Shared DTOsinfra/→ Docker, Terraform, K8sdocs/→ Architecture & ADRs
git clone https://github.com/your-team/esewa-clone
cd esewa-clonepnpm installdocker-compose up -dcd apps/api
pnpm prisma migrate devpnpm run seedpnpm run devpnpm run test # Unit tests
pnpm run test:integration # Integration tests
pnpm run test:coverage # Coverage reportpnpm run load-testTarget:
- p99 latency < 500ms
- zero double charges
- JWT RS256 authentication
- bcrypt password + PIN hashing
- HMAC request signing (merchant APIs)
- Rate limiting (Redis)
- TLS enforced
- User registration + KYC
- Wallet management
- Payment processing
- Merchant integration
- Webhooks with retry
- Refund system
- Ledger reconciliation
You should be able to explain:
- Idempotency
- Optimistic locking
- Saga pattern
- Double-entry accounting
- Event-driven architecture
- ACID vs eventual consistency
- No frontend (API-first)
- Single currency (NPR)
- No real banking integration
- Identity & Auth
- Wallet & Balance
- Transactions & Idempotency
- Ledger & Reconciliation
MIT