Back to Projects

Flexible Payments System

Architected a distributed payment system enabling tenants to split monthly rental payments, supporting 75% of company revenue.

March 1, 2024
TypeScriptReactNode.jsNest.jsGraphQLMongoDBMySQL

Overview

As a Senior Software Engineer at Zego, I led a small team to architect and develop a distributed flexible payments system. This system enables property manager tenants to split their monthly rental payments into multiple smaller payments, making housing more accessible and improving payment completion rates.

The Challenge

Property managers needed a way to offer flexible payment options to their tenants without increasing their operational complexity or risk exposure. The solution needed to:

  • Handle billions of dollars in transactions annually
  • Integrate seamlessly with existing payment infrastructure
  • Maintain 99%+ uptime for mission-critical operations
  • Support a key partnership accounting for up to 75% of company revenue

Technical Architecture

The system was built using Domain Driven Design principles, with clear bounded contexts for payment scheduling, transaction processing, and reconciliation. A React frontend communicates with a GraphQL gateway, which routes requests to specialized Nest.js microservices backed by MySQL and MongoDB.

Key Technical Decisions

GraphQL for Flexible Queries

We chose GraphQL to allow the frontend to request exactly the data it needs, reducing over-fetching and improving performance for complex payment dashboards.

Event-Driven Architecture

Payment state changes are published as events, allowing other services to react asynchronously. This decoupling improved system resilience and made it easier to add new features.

C4 Modeling

We used C4 diagrams to document the system architecture at multiple levels of abstraction, making it easier for new team members to understand the system.

Results

  • 99% uptime maintained for mission-critical payment processing
  • 75% of revenue supported through key partnership integration
  • Improved tenant satisfaction through flexible payment options
  • Reduced late payments by allowing tenants to align payments with their pay schedules

Lessons Learned

  1. Domain expertise matters: Working closely with product and business teams helped us understand the real-world constraints of property management
  2. Start with the domain model: DDD helped us create a shared language with stakeholders
  3. Invest in observability: Comprehensive logging and monitoring were essential for maintaining reliability