Single-Instance Multi-Tenant Architecture Exploration

Ramblers head office is in discussions about adopting NGX Ramblers as a solution to roll out to groups nationally. The primary driver is the Brevo email integration — Ramblers Head Office wants to offer groups a ready-made email solution (newsletters, walk notifications, booking confirmations) without each group having to set up and manage their own email infrastructure. One of their preferences is that a single NGX instance could serve multiple groups rather than the current model of one deployment per group. Scale target: up to 500 groups.

Target Architecture — outlined more detail in the following articles

flowchart TD
    D1@{ icon: "ngx:user", label: "group-a-ramblers.org.uk", pos: "b", h: 48 }
    D2@{ icon: "ngx:user", label: "group-b-ramblers.org.uk", pos: "b", h: 48 }
    DN@{ icon: "ngx:user", label: "...up to 500 domains", pos: "b", h: 48 }

    D1 --> CF
    D2 --> CF
    DN --> CF

    CF@{ icon: "ngx:cloudflare", label: "Cloudflare DNS", pos: "b", h: 48 }
    CF --> FLY

    subgraph FLY["Fly.io Application - 2 to 4 instances"]
        TM["Tenant Resolution Middleware<br/>Host header to groupCode"]
        CACHE["Domain-to-group cache<br/>refreshed periodically"]
        DBR["Database Router<br/>groupCode to mongoose.useDb"]
        TM --> CACHE
        TM --> DBR
    end

    DBR --> MDB1@{ icon: "ngx:mongodb", label: "Group A DB", pos: "b", h: 48 }
    DBR --> MDB2@{ icon: "ngx:mongodb", label: "Group B DB", pos: "b", h: 48 }
    DBR --> MDBN@{ icon: "ngx:mongodb", label: "Group N DB", pos: "b", h: 48 }

    MDB1 --> S3
    MDB2 --> S3
    MDBN --> S3

    S3@{ icon: "ngx:aws", label: "Single S3 Bucket<br/>/{groupCode}/images/", pos: "b", h: 48 }

    style FLY fill:#E8F5EE,stroke:#9BC8AB,stroke-width:2px,rx:12,ry:12,color:#404143

This series of articles explores what would be required to re-architect NGX Ramblers so that any number of groups run off a single application instance, while maintaining the same segregated user experience — where navigating to a group's domain shows only that group's branding, members, walks, and content.

Platform Overview

What NGX Ramblers provides beyond email — walks, bookings, galleries, CMS, and more

Current Architecture

How the per-group deployment model works today — one Docker image, 13 independent apps

Proposed Architecture

Single-instance multi-tenant design — tenant resolution, database switching, request lifecycle

Brevo Email at Scale

The primary rollout driver — outbound email, deliverability, and multi-tenant email isolation

Billing and Costs

Fly.io free-tier analysis, cost comparison at 500 groups, and billing risk assessment

Assessment and Recommendation

Honest pros and cons, effort estimates (AI-assisted vs manual), and recommended approach