Designing a Scalable Hybrid Architecture

- 2 mins read

Work In Progress: This document is a draft summary of architectural patterns I advocate for. Detailed diagrams and deep-dive analysis are currently being written.

The Challenge: The “Customization Hell”

In B2B SaaS, satisfying specific client requirements often leads to spaghetti code: if (client == 'A') statements scattered everywhere, making the system fragile and untestable.

The Strategy: “Clean Core + Specific Satellites”

To maintain a pristine logical core while allowing necessary deviations, I implement a strict governance strategy:

1. The Core: A Modular Monolith (Clean Architecture)

  • Goal: Host the business rules while allowing controlled variations.
  • Design Pattern: Strategy Pattern & Interfaces. Client-specific logic does exist in the Core, but it is strictly encapsulated in isolated packages behind generic Go Interfaces.
  • Benefit: The Domain Logic remains pure and does not “know” about specific implementations. We can add a new client strategy without touching the existing business rules (Open/Closed Principle).
  • Data Strategy: Strict SQL schema, utilizing JSON types only for controlled flexibility.

2. The Satellites: Extension Services

  • Goal: Handle heavy / outlying workflows that would pollute the Core’s data model.
  • Why: If a client needs a completely different data structure or heavy I/O process, it lives in a Satellite.
  • Tech: Kubernetes / Microservices / Redis Streams.

Key Benefits

  • Maintainability: Client specifics are isolated. Removing a client means simply deleting its package and satellite, leaving the Core clean.
  • Testability: We can unit test the Core logic with mock strategies, and test client strategies in isolation.
  • Stability: No “spaghetti” conditions in the critical path.