← All projects

KaiPay

Event-driven simulated payment platform · Nov 2026

  • Java
  • Spring Boot
  • PostgreSQL
  • Apache Kafka
  • Docker
  • React
View source on GitHub
KaiPay merchant dashboard showing simulated balance, gross volume, fees, refunds and a list of recent payments with their statuses.
Merchant dashboard Simulated balance, gross volume, fees and refunds in MYR, above the merchant's recent payments and their statuses.

KaiPay is a simulated payment platform. It does not move real money. I built it to work through the problems that make payment backends hard: keeping the database and the message broker consistent, recovering from a crash mid-payment, and never refunding more than was captured.

What I built

  • Transactional outbox. Payment records and their event intents are written to PostgreSQL in one transaction. A publisher then sends the events to Apache Kafka with retries, giving at-least-once asynchronous delivery.
  • Crash-recoverable authorization. Authorization moves through three committed database stages, and simulator outcomes are stored durably. Kafka retry topics and consumer deduplication let processing resume without repeating a decision that is already final.
  • Double-entry accounting. Captures and refunds in MYR are recorded as journal entries in integer sen and validated to balance. Pessimistic row locking prevents over-refunding in the concurrent scenarios I tested.