Fintech Systems
Setu Payment Service
Production-minded payment lifecycle event ingestion, immutable ledger state machine, and SQL reconciliation engine.
FastAPIPythonPostgreSQLSQLAlchemyFintechReconciliation
The problem
Asynchronous webhook hops, network retry storms risking catastrophic double-credits, fragmented multi-day transaction states, and financial reconciliation discrepancies between gateway payments and actual settlements.
Approach
- Engineered an event-driven immutable ledger using FastAPI and Supabase (PostgreSQL via SQLAlchemy) deployed serverless on Vercel.
- Implemented strict database-enforced idempotency on event_id — safely swallowing network retries with a 200 OK already_processed response to prevent double-credits.
- Built a state machine engine dynamically deriving the master transaction state across payment_status, settlement_status, and lifecycle progression.
- Pushed analytical calculations directly down to PostgreSQL using optimized GROUP BY and CASE WHEN queries to aggregate merchant settlement rates and transaction volumes in milliseconds.
- Developed a dedicated anomaly detection engine classifying real-world financial edge cases: settled_after_failure (potential fraud), processed_not_settled (stuck money), and stale_initiated.
- Shipped a branded Developer Experience (DX) portal with ReDoc, interactive Swagger OpenAPI, visual web dashboard, and a 24-point comprehensive Postman test suite.
Impact
- Zero double-credits guaranteed via database-level idempotency
- Real-time SQL discrepancy detection across 3,800+ transactions & 5 merchants
- Complete live developer experience: Base API, ReDoc guide, Swagger & visual dashboard