惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
P
Privacy International News Feed
L
LINUX DO - 热门话题
T
Threatpost
Latest news
Latest news
C
Cybersecurity and Infrastructure Security Agency CISA
Cisco Talos Blog
Cisco Talos Blog
Cyberwarzone
Cyberwarzone
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
NISL@THU
NISL@THU
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
V
Vulnerabilities – Threatpost
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
H
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cisco Blogs
Security Latest
Security Latest
博客园 - 叶小钗
博客园 - Franky
The Hacker News
The Hacker News
Engineering at Meta
Engineering at Meta
Scott Helme
Scott Helme
S
Securelist
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
A
About on SuperTechFans
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园_首页
B
Blog RSS Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
月光博客
月光博客
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tor Project blog
A
Arctic Wolf

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Scaling a Multi-Brand SaaS Platform Without Losing Your Mind: How We Built It
Dynamite Tec · 2026-05-16 · via DEV Community


You're the architect of a SaaS platform. Your sales team just closed three major clients—each with their own branding requirements, custom workflows, and backend integrations. Your CTO asks: "Can we make this work without spinning up separate deployments?"

Your answer used to be "maybe," and it would involve a lot of if (brand === "...") statements scattered across your codebase.

We've been there. And we found a better way.

The Nightmare: Conditional Architecture Hell

When we first started supporting multiple brands, our approach was... let's call it "direct."

if (brand === "dynamite") {
  return <DynamiteCard />
}

if (brand === "restaurant") {
  return <RestaurantCard />
}

if (brand === "pharmacy") {
  return <PharmacyCard />
}

Enter fullscreen mode Exit fullscreen mode

The problems started immediately:

  • Impossible to maintain: Every new feature meant touching dozens of conditional branches
  • Tight coupling: A change for one client could break another
  • Onboarding nightmare: Adding the fifth brand meant rewriting half the application
  • Dangerous to modify: You couldn't refactor anything without fear

We called it Conditional Architecture Hell, and every team that's scaled a multi-tenant SaaS has lived through it.

The real question wasn't "can we support multiple brands?" It was "can we support them elegantly?"

The Answer: A Hybrid Architecture

Instead of building separate systems for each brand, we designed a single platform that could bend to different requirements without breaking.

Our solution combines four key patterns:

  1. Hexagonal Architecture — Business logic stays isolated from external dependencies
  2. Registry Pattern — Dynamic component and action resolution without conditionals
  3. Plugin Architecture — Brand-specific code lives in isolated plugin modules
  4. Adapter Pattern — Different backends speak a common language (Unified DTOs)

This gave us one codebase, one deployment, and infinite flexibility.

How It Works: The 30,000-Foot View

Here's the basic flow:

Browser
   ↓
Next.js Frontend (Single App)
   ↓
Brand Plugin Layer (Dynamic Resolution)
   ↓
Backend API Gateway
   ↓
Brand Adapter Factory (Normalize Everything)
   ↓
Database / External APIs

Enter fullscreen mode Exit fullscreen mode

Each layer is designed to solve one specific problem. Let's break it down.

Part 1: Frontend — The Registry Pattern

The frontend is the first place where the magic happens. Instead of hardcoding which component belongs to which brand, we use a registry.

Brand Detection via Subdomains

We identify tenants through subdomains:

dynamite.domain.com
restaurant.domain.com
pharmacy.domain.com

Enter fullscreen mode Exit fullscreen mode

Our middleware extracts the brand name:

const brand = hostname.split(".")[0]

Enter fullscreen mode Exit fullscreen mode

This becomes the tenant context for the entire request.

Components Are Registered, Not Hardcoded

Instead of conditionals, we register components by brand:

registerRecordCard("dynamite", DynamiteCard)
registerRecordCard("restaurant", RestaurantCard)
registerMenuAction("Live Track", LiveTrackAction)
registerMenuAction("Start Delivery", StartDeliveryAction)

Enter fullscreen mode Exit fullscreen mode

When the frontend needs to render something, it doesn't check if brand === X. It just asks the registry:

const CardComponent = getRecordCard(brand)
const ActionComponents = getMenuActions(brand)

Enter fullscreen mode Exit fullscreen mode

Why This Pattern Changed Everything

The registry pattern eliminated:

Problem Solution
Endless conditionals Dynamic resolution
Hard to onboard new clients Register and go
Risky refactoring Isolated logic
Can't scale beyond 10 brands Supports unlimited brands

This single decision became one of the most important architectural choices we made.

Part 2: Backend — Hexagonal Architecture

The frontend was half the battle. The backend was harder.

Every brand had:

  • Different database schemas
  • Different API endpoints
  • Different query logic
  • Different transformation rules
  • Different business workflows

A typical query might look completely different for each tenant:

// DynamiteAdapter
SELECT * FROM order_tracking WHERE status = 'active'

// RestaurantAdapter
SELECT * FROM delivery_orders WHERE completed_at IS NULL

// DataneralAdapter
SELECT * FROM prescription_orders WHERE fulfillment_status IN (...)

Enter fullscreen mode Exit fullscreen mode

We couldn't just "configure" our way out of this. We needed a way to let each brand implement its own data fetching logic, but have everything speak the same language downstream.

Enter Hexagonal Architecture.

The Principle: Business Logic Shouldn't Know About Persistence

In hexagonal architecture, your core business logic sits in the center and communicates with the outside world through ports (interfaces). The actual database, APIs, and external services are adapters that implement those ports.

Domain (Pure Business Logic)
   ↓
Application Services
   ↓
Ports (Interfaces)
   ↓
Adapters (Database, APIs, etc.)

Enter fullscreen mode Exit fullscreen mode

This means:

  • Your business logic doesn't care if data comes from PostgreSQL, MongoDB, or an external ERP
  • You can swap implementations without touching core logic
  • Each brand can fetch data however it needs, as long as it conforms to the port interface

Brand Adapters in Practice

Each tenant gets its own adapter:

class DynamiteRecordAdapter {
  async getRecords() {
    return prisma.$queryRaw`
      SELECT * FROM dynamite_orders 
      WHERE status NOT IN ('completed', 'cancelled')
    `
  }

  async transformToUnified(record) {
    return {
      card_type: "BOOKING",
      products: record.items,
      order_total_amount: record.total
    }
  }
}

class PharmacyRecordAdapter {
  async getRecords() {
    return prisma.$queryRaw`
      SELECT * FROM prescriptions 
      WHERE fulfillment_status = 'pending'
    `
  }

  async transformToUnified(record) {
    return {
      card_type: "PRESCRIPTION",
      products: record.medications,
      order_total_amount: record.total_charge
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

Each adapter:

  • Fetches data its own way ✓
  • Transforms data its own way ✓
  • Returns a unified contract ✓

The Normalization Layer: The Unsung Hero

This became the most important backend layer. Everything flowing from the adapters gets normalized into Unified DTOs:

interface UnifiedRecord {
  card_type: "BOOKING" | "BILLING" | "PRESCRIPTION"
  products: Product[]
  order_total_amount: number
  timeline?: Activity[]
  customer: Customer
}

Enter fullscreen mode Exit fullscreen mode

No matter where the data came from or what it looked like originally, the frontend sees the same structure:

Different Schemas
        ↓
Normalization Layer
        ↓
Unified DTO
        ↓
Frontend (No surprises)

Enter fullscreen mode Exit fullscreen mode

This single layer eliminated dozens of rendering bugs and made the frontend dramatically simpler.

Part 3: Configuration vs. Code — The Hybrid Model

One of our biggest mistakes early on was trying to make everything configurable.

Some clients needed completely custom booking flows. Others needed live tracking integrations. Some wanted QR-code-based workflows. Making all of that configuration-driven would create an unmaintainable abstraction layer.

Instead, we split the problem:

What We Make Configurable

Simple, declarative stuff:

  • Themes and branding
  • Menu structure and visibility
  • Feature flags
  • Permissions and roles
  • Invoice settings
  • Module visibility

These are declarative and safe to change without touching code.

What Stays Plugin-Based

Complex, behavioral stuff:

  • Custom workflows
  • Advanced UI interactions
  • Complex business logic
  • Brand-specific experiences
  • Custom integrations

For these, we let engineers write code inside isolated plugin modules.

This hybrid approach gave us the best of both worlds: flexibility for simple customizations and the power of code for complex ones.

The Final Architecture

By the end, we had built:

Shared SaaS Core (Common functionality)
   +
Registry Pattern (Dynamic UI resolution)
   +
Plugin Adapters (Brand-specific code in isolation)
   +
Hexagonal Backend (Business logic stays pure)
   +
Unified DTO Contracts (All backends speak the same language)

Enter fullscreen mode Exit fullscreen mode

What This Unlocked

With this architecture in place, we were able to:

Onboard new brands faster — No code duplication, no re-architecting

Update the shared core safely — Changes don't ripple across brands

Support 10x more features — Plugin system let brands innovate independently

Reduce bugs dramatically — Isolated plugin code, shared testing, unified contracts

Scale the team — Junior engineers could work on brand plugins without touching core

Move faster — No more "this change might break brand X" conversations

The Real Lesson

The real lesson wasn't about any single pattern. It was about thoughtful separation of concerns.

The registry pattern solved UI composition. Hexagonal architecture solved data access. Plugin architecture solved deployment scale. DTOs solved the integration seams.

No single pattern would have worked alone. But together, they created something greater than the sum of their parts.

If you're building a multi-tenant SaaS and you're drowning in if (brand === statements, know this: there's a better way. It takes more upfront thinking, but it pays for itself a hundred times over as you scale.


Have you built a multi-brand platform? What patterns worked for you? Share your thoughts in the comments below.