← Selected Engineering Work

Multi-tenant SaaS

White-label Restaurant Management Platform

Built a restaurant management platform that serves multiple restaurant chains from a single codebase. Each chain gets its own branding, menu structure, and operational workflows - without forking the code. The hard part: making the system flexible enough to handle different restaurant types (fast food, fine dining, delivery-only) while keeping the core logic maintainable.

This platform serves multiple restaurant chains from a single Angular/NestJS codebase. Each chain configures its own branding, menu structure, payment providers, and operational workflows. The challenge: support fast food (quick orders, combo deals), fine dining (reservations, complex menus), and delivery-only (no dine-in, driver tracking) - all from the same system without code forks.

01 / The problem

One codebase, many restaurant types

Restaurant chains have different needs. Fast food wants quick ordering with combo deals and upsells. Fine dining needs reservations, complex menus with modifiers, and table management. Delivery-only doesn't have dine-in at all - they need driver tracking and delivery zone management.

If you hardcode each restaurant type, you end up with three separate codebases. If you try to make one system do everything, you end up with a mess of feature flags and conditional logic that's impossible to maintain.

The solution: build a flexible core with configurable modules. The core handles authentication, orders, payments, and basic CRUD. Each restaurant type is a configuration that enables/disables modules and sets default behaviors.

02 / The architecture

Multi-tenant with tenant-specific configuration

Each restaurant chain is a "tenant" with its own subdomain (chain.restaurant-platform.com), branding, and configuration. The Angular frontend loads tenant-specific themes and feature flags on startup. The NestJS backend uses tenant context to load the right configuration for each request.

MongoDB stores tenant data in separate databases (not just separate collections) for data isolation. This means a bug in one tenant's code can't corrupt another tenant's data. It also makes it easy to backup/restore individual tenants.

The menu system is fully configurable: categories, items, modifiers, combos, pricing rules. Each tenant defines their own menu structure. The order flow adapts based on restaurant type: fast food shows combo suggestions, fine dining shows reservation status, delivery-only shows delivery ETA.

03 / Payment integration

Stripe integration with tenant-specific providers

Each tenant can configure their own Stripe account, payment methods, and refund policies. The platform handles the Stripe integration, but tenants control their own money flow. This means the platform never touches the actual payment processing - it just orchestrates the flow.

The tricky part: handling payment failures. A failed payment for a reservation is different from a failed payment for a delivery order. The system needs to handle retries, refunds, and chargebacks differently based on the operation type.

I built a state machine for order/payment flow that tracks the exact state of each transaction. This makes it possible to retry failed payments without double-charging, and to handle partial refunds correctly.

Evidence & further reading

Technical references