SR-025 — Tenant Master: Configuration Wizard System Requirements

By Engineering Team•October 9, 2026•7 min read
Metadata Details
System Name tenant-service — Tenant Master
Document ID SR-2026-TEN-001
Author Engineering Team
Status Approved

Traces back to BRD-024.

See it first: Admin UI Walkthrough — Tenant Master

This document covers tenant-service’s six PostgreSQL tables (tenants, tenant_configs, tenant_contacts, tenant_addresses, tenant_theme_styles, tenant_policies) and its Go REST/gRPC surface, plus the ui-admin-application’s features/tenant/configuration/ wizard that drives it. It does not restate how a storefront or mobile client visually renders this configuration — only the downstream read endpoints that hand it the data.


Functional Requirements

Configuration Wizard (TenantConfigPage.tsx / TenantConfigController.ts, route /tenant/basic)

FR-01 (Seven Independently-Saved Steps): The wizard renders seven steps — Basic Configuration, Theme & Branding, Contact & Support, Registered Address, Terms & Conditions, Privacy Policy, Exchange & Returns. Each step is validated and saved on its own; “Save & Next” only calls its section’s PUT if that section’s form is actually dirty — navigating through untouched steps issues zero network calls.

FR-02 (Lazy Per-Step Load): Each section’s data is fetched via GET only the first time that step is visited; revisiting an already-loaded step (Back, Next, or a direct step jump) reuses the in-memory form state rather than re-fetching.

FR-03 (Read-Only Tenant Identity): The immutable tenant code is fetched once via GET /admin/api/v1/tenant and shown disabled on Step 1 — there is no admin-facing create or edit of tenant identity; a tenant is provisioned out-of-band before this wizard is ever used.

FR-04 (Basic Configuration): storeName, aboutDescription, featuresDescription, and appVersion — all required. GET/PUT /admin/api/v1/tenant/config/basic.

FR-05 (Theme & Branding): appLogoUrl, appSloganDescription, applicationMainFont, primaryThemeSeed/buttonColor/fontColor/accentColor/surfaceColor/cardBgColor/saleBadgeColor (hex color strings), cardCornerRadius/cardBorderWidth/cardElevation (numeric), and contentDensity (compact/comfortable/spacious). GET/PUT /admin/api/v1/tenant/config/theme.

FR-06 (Logo Upload via the Shared Image Pipeline): The logo is captured through the shared ImageUploader organism (aspect-ratio choice, crop, zoom, rotate, flip) and uploaded through content-processor’s asynchronous image pipeline under a fixed tenant_logo transaction name, keyed deterministically by the tenant’s own ID rather than a per-upload random ID — a tenant has exactly one logo slot. The wizard shows a presigned display URL for on-screen preview only; it is never written back into appLogoUrl. The persisted appLogoUrl is updated only once tenant-service’s own Pub/Sub message receiver observes content-processor’s completion event for that transaction.

FR-07 (Contact & Support): supportEmail, supportPhoneTollFree — both required in the admin UI. GET/PUT /admin/api/v1/tenant/config/contact.

FR-08 (Registered Address, India-Only Model): registeredCompanyName, addressLine1, addressLine2 (optional), city, state, postalCode (Indian 6-digit pincode format), country (fixed to "India", not editable). GET/PUT /admin/api/v1/tenant/config/address.

FR-09 (One Discriminated Policy Resource, Three Instantiations): Terms & Conditions, Privacy Policy, and Exchange & Returns are three instances of the same PolicyType-discriminated resource (TERMS | PRIVACY | RETURNS), not three separate domain models. Each holds policyContent (rich text) and a server-computed version. GET/PUT /admin/api/v1/tenant/config/{terms|privacy|returns} — the PUT body carries only policyContent; version is never client-supplied.

FR-10 (Server-Driven Policy Auto-Versioning): On every successful policy upsert, tenant-service computes the next version (v1 → v2 → v3, …) from the existing row’s version, or v1 if the policy has never been saved before — this is the version shown as a read-only chip in the Terms/Privacy/Returns steps, per BRD-024 BR-04.

FR-11 (Reusable Placeholder Tokens in Policy Content): The policy editor offers quick-insert tokens — store name, registered company name, address lines, city/state/postal code/country, phone, support email, and application website URL — per BRD-024 BR-03. These tokens are stored verbatim inside policyContent; they are resolved against the tenant’s current Basic/Address/Contact/application configuration only when read through the client-facing aggregate endpoints (FR-13), never on the admin GET — an admin always edits the raw token text, not a resolved preview.

FR-12 (“Not Configured Yet” Semantics): Every section’s GET returns 404 if that tenant has never saved that section; the admin UI treats this as an empty, ready-to-fill form, not an error state.

FR-13 (Downstream Aggregate Read Path): A separate client-facing GET /client/api/v1/tenant-info assembles Basic + Contact + Address + all three Policies + the (not-yet-admin-editable) application-config website URL into one flat response, with every placeholder token resolved — gated to tenants whose Status is ACTIVE and whose FirebaseTenantID is non-blank (403 otherwise). GET /client/api/v1/policies offers the same placeholder-resolved aggregation, reachable without an authenticated session, for pre-login policy display. This is exactly the read TenantInfoService performs on the mobile Settings area — see SR-026 FR-11’s About/Support/Terms/Privacy/Returns screens.

FR-14 (gRPC Identity Read Only): TenantService/GetTenantCode is the only gRPC surface tied to this feature’s data — consumed by order-service to format order codes. None of the seven wizard sections are otherwise exposed over gRPC.


Non-Functional Requirements

Multi-Tenancy & Auth Propagation

Every admin GET/PUT resolves tenant_id from the caller’s AuthClaims, never the request body; every PUT sets updated_user_id/updated_at from the same source, and created_user_id/created_at are never overwritten after a section’s first insert — the standard five-field audit contract.

Validation Parity — Frontend Stricter Than Backend

Several fields the admin UI requires and format-checks client-side have no equivalent server-side validation: supportPhoneTollFree; registeredCompanyName, city, state on the address section; and eight of the Theme section’s fourteen fields (accentColor, surfaceColor, cardBgColor, saleBadgeColor, cardCornerRadius, cardBorderWidth, cardElevation, contentDensity). (Gap — tracked as Technical Debt — TD-00019.)

Wizard Step-Indicator Navigation

TenantConfigPage.tsx’s step-indicator circles are clickable (wired to a step-jump handler), unlike the admin app’s documented wizard convention of non-interactive, progress-only step indicators. (Gap — tracked as Technical Debt — TD-00019.)

Client-Side DEV_MOCK Fallback — Absent Here, Unlike Other Features

TenantRepository.ts has no DEV_MOCK_* fallback, despite this being a documented convention for new ui-admin-application features. (Gap — tracked as Technical Debt — TD-00019.)