Engineering practices · Architecture

Architecture practices.

Tenant scoping, provisioning, configuration over code, order states, money snapshots, verified events, integrations, offline branches, additive change, audit history and scale: the decisions under every platform we build, and how we make each one.

Platform Architecture Decisions

A platform that many organisations share for years rests on a dozen architectural decisions made early, and each one is expensive to change once customers depend on it.

Tenant scopingevery requestSpecial tenantsown databaseProvisioningfrom a templateConfigurationnot codeOrder stateseleven, explicitMoney snapshotsrates frozenVerified eventsnot redirectsOne contractmany providersOffline branchesno collisionsAdditive changeone releaseAudit historyevery fieldScale patternsbefore the database Platformmany organisations · years
1,100+permission checks across our platforms
11explicit order states
10payment gateways behind one contract
27kinds of record with full audit history

Multi-tenancy

How one codebase serves many organisations without them ever seeing each other.

01

Tenant Resolution and Scoping

In a shared platform every customer’s data sits in the same tables, so the boundary between them is only as strong as the code on every request. One missing filter, cache key or file path and one organisation sees another’s orders, files or settings. The tenant is resolved once, from the host name or the signed-in session, and then decides templates, media, cache, settings and payment credentials; every row carries the tenant key, with more than 1,100 permission checks on top.

Requesthost name · sessionTenant resolvedonce, before any logicRowstenant key on every rowMediaits own folderCacheits own namespaceSettingsits own configurationPaymentsits own credentialsAnother tenant’s IDno rows returned1,100+ checkspermissions on top
02

Special-tenant Routing

Some tenants should not share storage with the rest, such as demonstration organisations or customers with their own isolation needs. Mixed into production tables, they put test data in real reports and prospects one bug away from real customers. One shared schema serves everyone by default, designated tenants are routed to a separate database through configuration, and custom domains map one-to-one to stores.

Tenant ATenant BTenant CDemo organisationRouterby configurationShared databasetenant key on every rowSeparate databasefor designated tenantscustom domains map one-to-one; a domain moves without data changes
03

Template-based Provisioning

How a new customer is set up decides how consistent the platform stays for years. Hand-built tenants drift apart and a retried sign-up can quietly create a duplicate, and every difference becomes a support call. A new tenant is created from a verified sign-up, receives its defaults by copying a template tenant, can attach its own domain, and provisioning is idempotent, so a retry never creates a second tenant.

Sign-upone-time passwordTenantcreated onceTemplatedefaults copiedDomainoptionalLivesame releaseRetried requestreturns the same tenant
04

Configuration-driven Behaviour

A platform has to keep up with the businesses it serves without a developer for every change. Platforms that need code for every field, stage or rule end up as a backlog of small changes or a fork per large customer. Differences live in configuration: settings, templates, feature switches and workflows whose stages name their next stages, group and owner, dashboards built from five functions in seven chart types, and even AI model choices.

CONFIGURATION · PER TENANTsettingsthemestemplatesfeature switchesworkflowsmodel choicesOne codebaseno forks per customerA WORKFLOW, AS DATA New In progress ClosedRequestReviewReworkApprovedRejected
Is your platform bending to every customer request?

An engineer reviews how tenants, configuration and customisations are handled today, and where the platform will stop scaling.

Transactions and State

Where platforms most often lose money, history or trust.

05

Order State Machine

An order is far more than paid or unpaid, and every screen, report and integration has to agree on where it stands. Tracked as loose flags, orders end up shipped but unpaid, or refunded twice. Orders move through eleven explicit states with only allowed transitions, and payment runs on its own track of pending, paid, failed and refunded.

ORDER · ELEVEN STATES, ALLOWED TRANSITIONS ONLYNewProcessingPackingShippedDeliveredprocurebillingdelayedcancelledrejectedreturnedsix more states, each with its own allowed movesPAYMENT · ITS OWN TRACKPendingPaidFailedRefundedevery screen, report and integration reads the same state
06

Transaction Snapshots

An invoice from last year must still add up the way it did on the day it was raised. Platforms that look prices and rates up live rewrite history every time a rate changes, and reconciliations stop matching. The price, tax, discount and, in partner networks, the commission rates in force are copied onto each transaction when it happens.

LIVE RATES · CHANGE OVER TIMEPrice Tax Commission order placedOrderprice · tax · commission copiedRates change laterthe order does not
11order states, each with allowed moves
4payment states on their own track
3workflow stage groups: new, in progress, closed
7chart types from five functions, by configuration
07

Verified Payment Events

A browser returning from a payment page proves nothing: it can be faked, refreshed or lost. Platforms that mark orders paid or upgrade plans on that redirect either give goods away or miss real payments. An order becomes paid only when the gateway’s proof is checked; the browser return and the server notification are both handled, the first wins, and billing events are stored by ID so retries never apply twice.

Gatewaypayment madeBrowser returncan be faked or lostServer notificationsigned by the gatewayProof checkedagainst the orderfirst one winssecond does nothingevents stored by ID · retries never apply twice

Integrations and Change

How a platform connects to everything around it, and how it changes without breaking.

08

Provider Abstraction Layer

Payment gateways, couriers, marketplaces and AI models change their terms and APIs, and every business wants a different one. Wired straight into checkout or features, each new provider means rewriting core code, and a failing provider leaves the platform stuck. Each kind of provider sits behind one contract: ten payment gateways implement the same module contract, delivery charges come from courier zones across more than 19,000 pincodes, and each AI role reads its model from configuration.

Platformcalls one contractPaymentscontractDeliverycontractAI modelscontractten gateway modulesCourier zones19,000+ pincodesModel per roleset in configuration
09

Offline Branch Sync

Shops, branches and field teams cannot stop billing when the internet drops. Records created offline in several places collide when they meet again, and renumbering afterwards breaks invoices and audits. Each branch is initialised with its own number series, so records never collide and merge without renumbering, and branches synchronise with head office in order.

Branch Aseries 1xxxxxxx · offlineBranch Bseries 2xxxxxxx · offlineHead officemerged, no renumberingsync in orderOnline storestockbridge jobNo collisions by design: every branch owns its own range of numbers
Adding providers, branches or channels to an existing platform?

An engineer reviews how your integrations and data flows are wired, and what will break as you add more.

10

Additive Schema Changes

Platforms that serve many customers for years change constantly, and the risk lies in how changes reach everyone. A fork per customer multiplies every fix, and a migration per tenant turns every release into a project. Every tenant runs the same codebase on the same release, each change is tried on a staging copy before it is merged, and database changes are additive so no release needs a per-tenant migration.

live Branch + stagingtried firstmergedevery tenant, same releaseDATABASE CHANGES+ new column+ new tableno per-tenant migrationevery tenant on the same release
11

Audit Trail

Disputes, audits and support questions all come down to who changed what, when, and what it was before. Platforms that store only the current value cannot answer, usually months after it mattered. Every change to a record, form value, stage or setting is written with the field, old and new value, action, person and time across twenty-seven kinds of record, and form values are versioned per stage.

EntityFieldOldNewActionWhoWhen OrderstatuspackedshippedupdatedAsha10:42 CardstagereviewapprovedupdatedRavi10:44 Settingtax modeoffonupdatedAdmin10:51 Formamount—12,400addedMeera11:02 Example rows. 27 kinds of record carry this trail; form values are versioned per stage.who changed what, when, and what it was before
19,000+pincodes served by courier zones
27kinds of record with full audit history
5 minfrom database change to the AI retrieval index
1codebase and release for every tenant

Scaling Patterns

When to cache, when to index, when to replicate.

12

Read Path Scaling

The database is the hardest part of a platform to scale, so every request that reaches it unnecessarily is borrowed time. Platforms that meet growth with a bigger database server still stall on sale days, large catalogues and AI features. Most traffic is answered before the database by a CDN, per-store page and widget caches and, past a few hundred thousand products, a dedicated search index, while AI retrieval reads only from a replica kept current every five minutes.

Trafficvisitors, sale days, AI requestsCDNversioned filesPage cachesper store, own expirySearch indexfrom a change tablemost requests end herePrimary databasecarts, checkouts, order writesReplicafeeds AI retrieval · 5 minthe database serves only what nothing else can

Self-assessment Questions

Questions worth asking of any platform you run today.

  1. If a customer changes an ID in a request, can they see another customer’s data?
  2. Does adding a new customer need a developer or a deployment?
  3. Does any large customer run on its own fork of your code?
  4. If a tax or commission rate changes today, do last year’s invoices change too?
  5. Is an order marked paid when the browser comes back from the payment page?
  6. How much core code changes when you add a payment gateway or courier?
  7. Can your branches keep billing when the internet drops, without duplicate numbers?
  8. Can you say who changed a record, when, and what it was before?
Want an Independent Architecture Review of your platform?

An engineer reviews your tenancy, data model, integrations and release process against the questions above, and gives you a prioritised plan.

Discuss a project

Share a short brief. If it is a fit, the next step is a call with one of our engineers.