Case study 01 · Multi-tenant SaaS
Merchant Management System
A platform where payment providers onboard merchants, run KYB checks, take card payments and settle with merchants.
- My role
- Architect and developer (settlement, KYB, payments)
- Team
- 4 engineers
- Timeline
- 1 year, first commit to production
- Status
- In production
- Client
- fintech companies in Egypt
- Stack
- Laravel · Vue.js · PostgreSQL · Stancl Tenancy · Reverb · Docker · CyberSource · MPGS
The problem
Payment providers had no dashboard to manage their merchants. Onboarding and KYB checks, following payment transactions and settling with merchants all needed one place, and each provider's data had to stay separate from the others'.
The solution
A multi-tenant platform built from scratch. Each provider gets its own isolated database; the provider's team and its merchants both work in it.
- KYB onboarding: draft, submit, review, approve or reject, with revision history and real-time collaboration.
- Card payments: CyberSource and MPGS, plus a hosted payment page with checkout, payment links and invoicing.
- Settlement: automatic and manual cycles, fee profiles, transaction splitting, bank accounts and multi-step approvals.
- Security: OAuth2 scoped tokens, TOTP MFA with recovery codes, role-based access and audit logs.
The hardest problem
The settlement engine had to handle four things at once, and every amount had to be right:
- each merchant can have its own fee rules (MDR profiles);
- one transaction can be split between several parties;
- automatic and manual settlement cycles run side by side;
- generation must stay fast as transactions grow.
Correctness is protected by reconciling settlements against the underlying transactions, with unit and feature tests around the calculations.
My contribution
I designed the architecture and the database, and built the settlement engine, the KYB approval workflow and the CyberSource and MPGS integrations, in a team of four.
Architecture
Key decisions
| Decision | Why |
|---|---|
| A database per tenant (Stancl Tenancy) | Each provider's data stays fully separate |
| Denormalised settlement data and composite indexes | Settlement generation was the slow path |
| Real-time KYB review over WebSockets | Reviewers and merchants see each revision as it happens |
Results
Measured on a 1 GB synthetic transaction dataset, after a schema redesign, denormalisation and composite indexes.
Client details are confidential, so the client is described rather than named and no client screens are shown.