Architecture

One platform, many apps: how each client gets its own store

Why Hubble serves every client app from one shared system, how each still gets its own store, and how one client's settings never reach another.

300+ consumer apps have integrated Hubble, and each sells gift cards from the same 500+ brands. No two see the same store. One shows a short list of brands, another the whole catalogue. Prices, allowed amounts, payment options and spending limits differ by client. This post is about why one system serves all of them, and what we hold to so that a change for one client stays with that client.

The problem

Every client wants the store to be its own: its own catalogue, its own discount on each brand, its own rules on amounts and payment, and its own limits. Clients also differ in kind. Some put our store inside their app for their own users. Some call our API with no end user in the loop. Some buy cards to give away. Each kind moves money in its own way, so the design has to know the kind of client as well as the client.

What makes it hard

Three things.

  • Settings are everywhere. A client’s settings touch almost every request in the store, so reading them has to be cheap.
  • A scoping mistake costs money. One client’s discount shown to another client’s users is not a display bug. It is real money paid out.
  • Settings change often, and many hands change them. Our team changes them, and for some settings so does the client, from its own portal.

Why one shared system

The obvious way to keep clients apart is to give each one its own copy of the system. We chose the other way.

A copy per client One shared system
A new client A new deployment New settings
A fix or a feature Shipped once per client Shipped once
Keeping clients apart Comes from the walls between copies Has to be designed into the data

A copy per client makes isolation easy and everything else hard. With one system, a new client is settings, not a code change, and a fix reaches every client at once. The price is that isolation is no longer free. We have to build it into how every setting is stored and read.

The properties we hold to

These are the guarantees the design exists to keep.

  • A request belongs to one client, decided once. Which client a request belongs to is settled from a credential we have checked, and that answer travels with the request. No part of the system works it out a second time.
  • Every setting has one owner. Each setting, price, limit, balance and group of users belongs to exactly one client. No request can read another client’s settings.
  • A group of users is client data. A segment defined for one client’s users means nothing for any other client’s users.
  • One client’s spending never touches another’s. Balances and spending limits are each client’s own, counted against that client’s own orders.
  • Every price can be explained. Prices come from one place, and each answer records where it came from, so we can always say why a client sees the price it sees.
  • When in doubt, no discount. If a client has no price set for a product, the store shows no discount rather than guess. Showing no discount is a mistake we can fix. Showing another client’s discount is not.

The trade-offs we accepted

Flexible settings need guards in code. We can add a new kind of setting without changing how settings are stored. In return, the code has to refuse settings that make no sense, such as a negative limit, at the moment they are written.

Settings that combine are simple until they interact. Each setting is easy to reason about alone. Where several apply to the same user, anyone changing them has to understand how they combine.

Clear owners means more than one place to look. Different parts of a client’s settings sit with the team that changes them. That keeps changes safe, but a question about one client can need more than one place.

We leave out the detail of how settings are stored, read and combined, on purpose.

What we would tell another team

  • Decide the tenant once, from something you have checked, and carry it. Every place that works it out again is a place where it can come out different.
  • Code with no request still needs a tenant. Work that runs on a schedule or in the background should be handed its tenant, never left to read an empty one.
  • Scope segments to tenants too. A group of users defined for one client is that client’s data.
  • Put pricing in one place and record where each answer came from. Most pricing questions then become a lookup.
  • Make missing settings fail toward the safe answer. Pick the mistake you can undo.
  • Check settings when they are written, not when they are read. A bad setting caught at write time never reaches a user.

To build on the platform, read the developer docs, or see the API and the SDK. If you would like to work on problems like this, see careers at Hubble.

Questions people ask

Does each client app get its own copy of Hubble?

No. Every client runs on the same system. What makes each store different is the client's own settings, and every setting belongs to exactly one client.

How does a new client app get its own catalogue and prices on Hubble?

Through settings, not code. Our team, and for some settings the client itself, chooses its brands, prices, rules and limits, and no deploy is needed.

Can a setting made for one client reach another client's users?

No. Every setting, price, limit and group of users belongs to one client, and the system only ever reads the settings of the client a request belongs to.

Build with us, or on us

Read the docs, or see the roles we are hiring for.