Not tutorials. Not clones. These are domain-specific backend systems where I made real architectural decisions — and learned from the ones that didn't work.
A ledger-based loan management system where every financial transaction creates an immutable,
hash-chained entry — the same principle banks use for audit trails. Loans go through a full lifecycle:
application → async credit check → approval → Kafka-driven disbursal → EMI generation → repayment with
late penalty calculation → foreclosure.
System Flow
User applies for loan
│
├── RiskAssessmentEngine runs async credit check on background ThreadPool
│ └── CompletableFuture + custom ThreadPoolExecutor (5 core, 20 max, CallerRunsPolicy)
│
├── Admin approves → disburseLoan() publishes DisbursalEvent to Kafka
│ └── DisbursalConsumer: credits wallet + generates installment schedule
│
├── Each payment: SELECT FOR UPDATE on installment row (pessimistic lock)
│ ├── Wallet debit with BigDecimal precision
│ ├── Late penalty = per-day rate × days overdue (rate varies by credit score)
│ └── LedgerEntry created with SHA-256 hash chain (previousHash → currentHash)
│
└── Every ledger write triggers: score recalculation + fraud detection
└── FraudDetectionService: sliding-window rate limiter (ConcurrentHashMap + ArrayDeque)
Spring Boot 3.2
Spring Kafka
JPA + PostgreSQL
Spring Security + JWT
Spring AOP
Caffeine Cache
Spring Actuator
BigDecimal
Centralized Audit Logging — Spring AOP
Custom @Auditing annotation + @Around aspect intercepts any annotated service method
│
├── Captures: authenticated userId (from SecurityContext), client IP (X-Forwarded-For aware)
├── Measures: method execution time via System.currentTimeMillis() delta
├── Records: method arguments, action name, SUCCESS/FAILED status
└── Persists to AuditLog entity — every loan approval, wallet debit, disbursal is traced
Result: zero audit code inside business logic. Add @Auditing(action = "LOAN_DISBURSED") and it's logged.
Kafka Event Pipeline
LedgerService.record() saves hash-chained entry → publishes LedgerCreatedEvent
│
├── @EventListener + @Async → recalculates credit score (repayment +20, deposit +5)
├── Forwards to Kafka "ledger-topic" → LedgerConsumer (downstream analytics)
└── FraudDetectionService: sliding-window rate limiter
└── ConcurrentHashMap + ArrayDeque: if >10 txns in 5 sec → publishes to "fraud-topic"
"disbursal-topic": LoanService publishes DisbursalEvent on approval
└── DisbursalConsumer: wallet credit + installment schedule generation — fully async
- Interest rate adjusts by credit score (1%–4% annual rate tiers) — EMI formula with proper amortization math and last-month rounding correction
- Every wallet operation uses SELECT FOR UPDATE (pessimistic locking) to prevent double-spend on concurrent requests
- LedgerIntegrityService validates the entire SHA-256 hash chain on demand — wired into Spring Actuator custom HealthIndicator
- Foreclosure: remaining principal + 2% fee, cancel all pending installments, close loan — single @Transactional boundary
- All financial math uses BigDecimal with explicit RoundingMode — no floating point anywhere in the money path
View source on GitHub ↗
A real-time appointment and queue management system for clinics. Patients book slots,
get token numbers, and see live queue updates via WebSocket. The interesting part: a smart
shuffling engine that promotes checked-in patients over no-shows in real time.
Queue Intelligence
Patient checks in at reception
│
├── QueueShufflingService acquires ReentrantLock
│ ├── Scans today's BOOKED appointments sorted by token
│ ├── Finds "holes": absent patient ahead of present patient
│ └── Swaps token numbers atomically, then releases lock
│
├── WebSocket broadcast via STOMP to /topic/queue/{doctorId}
│ └── All connected clients see updated queue positions instantly
│
└── Doctor calls next → tracks consultation duration → calculates
average wait time from historical data (totalDuration / totalConsultations)
Spring Boot 3.2
WebSocket + STOMP
Spring Security + JWT
JPA + PostgreSQL
Spring Mail
Caffeine Cache
Swagger/OpenAPI
- Role-based access: ADMIN manages doctors, DOCTOR calls next patient, PATIENT books and tracks queue position
- Async email notifications on booking confirmation using Spring's @Async with custom thread pool
- Insurance verification runs asynchronously after booking — doesn't block the HTTP response
- Daily scheduled task auto-cancels stale BOOKED appointments from previous days
- Wait time estimation: remaining appointments × average consultation time + time left for current patient
- Doctor performance tracking: total consultations, total duration, calculated per-patient average
View source on GitHub ↗