Tenant-Service — Tenant Identity & Master Configuration

By Engineering Team•October 9, 2026•5 min read

Responsibility

tenant-service owns tenant identity and every piece of per-tenant configuration a storefront needs before it can present itself to a customer.

  • Tenant identity — the immutable tenant code and core identity record; read-only from the admin wizard’s perspective. Status/FirebaseTenantID gate whether a tenant is eligible for the client-facing aggregate read path.
  • Tenant Master configuration wizard — a 7-step admin console (Basic, Theme & Branding, Contact & Support, Registered Address, Terms & Conditions, Privacy Policy, Exchange & Returns) where each step is validated and saved independently against its own table. See SR-025 for the full contract.
  • Theme & Branding, with an async logo pipeline — colors, typography, card styling, and content density are saved synchronously with the rest of the Theme step; the logo itself goes through content-processor’s async transcoding pipeline and is only written into appLogoUrl once a Pub/Sub completion event is consumed — a deliberately two-phase write, not a synchronous upload.
  • Policy documents, one discriminated resource — Terms & Conditions, Privacy Policy, and Exchange & Returns are three PolicyType instances of one shared tenant_policies table, auto-versioned server-side on every upsert. See ADR-00039 for why this is one table, not three.
  • Placeholder-token substitution — policy text stores literal tokens (store name, address, phone, support email, etc.); these are resolved against live tenant data only on the client-facing aggregate read endpoints, never on the admin read/write path.
  • Aggregated client-facing read path — AggregatorService.Aggregate fans out concurrently (errgroup) across five repositories to assemble GET /client/api/v1/tenant-info and GET /client/api/v1/policies, with placeholder tokens resolved in the response.
  • gRPC identity lookup — TenantService/GetTenantCode, the only gRPC surface this feature exposes, consumed by order-service for order-code formatting.

Tech Stack

Concern Choice
Language Go
Data store PostgreSQL — six tables: tenants, tenant_configs, tenant_contacts, tenant_addresses, tenant_theme_styles, tenant_policies
gRPC Server — TenantService/GetTenantCode, consumed by order-service
REST Admin wizard’s seven section endpoints, plus the client-facing aggregate endpoints
Messaging Firebase Pub/Sub — subscriber of content-processor’s tenant_logo completion event
Dependency injection Uber Fx
Template @templates/go-postgres-microservice, gRPC layer composed from @templates/go-grpc-microservice

API Endpoints (Tenant Master — Admin Wizard)

Step Endpoint
Tenant identity (read-only) GET /admin/api/v1/tenant
Basic Configuration GET / PUT /admin/api/v1/tenant/config/basic
Theme & Branding GET / PUT /admin/api/v1/tenant/config/theme
Contact & Support GET / PUT /admin/api/v1/tenant/config/contact
Registered Address GET / PUT /admin/api/v1/tenant/config/address
Terms & Conditions GET / PUT /admin/api/v1/tenant/config/terms
Privacy Policy GET / PUT /admin/api/v1/tenant/config/privacy
Exchange & Returns GET / PUT /admin/api/v1/tenant/config/returns

API Endpoints (Client-Facing Aggregate Read)

Endpoint Role
GET /client/api/v1/tenant-info Basic + Contact + Address + all three Policies + application-config website URL, placeholder-resolved; gated to Status = ACTIVE and non-blank FirebaseTenantID
GET /client/api/v1/policies The three Policies only, placeholder-resolved, reachable without an authenticated session

Implementation Notes

  • Each of the seven wizard steps writes to its own table and never locks or rewrites a field it doesn’t own — the per-section normalization this relies on is the subject of ADR-00039, chosen specifically over the original monolithic tenants row across eight historical migrations.
  • PolicyService.UpsertPolicy always computes version server-side (v1 → v2 → …) — the admin’s PUT body never includes it, and the three policy types share one service method keyed by PolicyType, not three separate implementations.
  • The logo upload is a two-phase write: the admin’s own PUT /admin/api/v1/tenant/config/theme call persists every Theme field except appLogoUrl; the final appLogoUrl is written only when message_receiver/tenantlogo_receiver.go’s HandleImageProcessed consumes content-processor’s completion event for the tenant_logo transaction. There is no retry or admin-visible failure state if that event is ever lost — tracked in Technical Debt — TD-00019, TD-05.
  • Several fields the admin UI requires/format-checks client-side (supportPhoneTollFree, three Address fields, eight Theme fields) have no equivalent server-side Validate() check — tracked in Technical Debt — TD-00019, TD-01.
  • TenantConfigPage.tsx’s step-indicator is clickable (step-jump), deviating from the admin app’s documented non-interactive step-indicator convention — tracked in Technical Debt — TD-00019, TD-02.
  • TenantRepository.ts has no DEV_MOCK_* fallback, unlike other recently-added ui-admin-application features — tracked in Technical Debt — TD-00019, TD-03.
  • GetTenantCode is this service’s only gRPC method today — it is identity-only and never touches any of the six wizard-section tables.

Admin UI Walkthrough: 07-ui-admin. Tenant Master: BRD-024, SR-025, ADR-00039, Architecture — Tenant Master: Configuration Wizard, Logo Pipeline, and Aggregated Tenant-Info Read Path, Technical Debt — TD-00019.