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/FirebaseTenantIDgate 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 intoappLogoUrlonce 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
PolicyTypeinstances of one sharedtenant_policiestable, 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.Aggregatefans out concurrently (errgroup) across five repositories to assembleGET /client/api/v1/tenant-infoandGET /client/api/v1/policies, with placeholder tokens resolved in the response. - gRPC identity lookup —
TenantService/GetTenantCode, the only gRPC surface this feature exposes, consumed byorder-servicefor 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
tenantsrow across eight historical migrations. PolicyService.UpsertPolicyalways computesversionserver-side (v1→v2→ …) — the admin’sPUTbody never includes it, and the three policy types share one service method keyed byPolicyType, not three separate implementations.- The logo upload is a two-phase write: the admin’s own
PUT /admin/api/v1/tenant/config/themecall persists every Theme field exceptappLogoUrl; the finalappLogoUrlis written only whenmessage_receiver/tenantlogo_receiver.go’sHandleImageProcessedconsumescontent-processor’s completion event for thetenant_logotransaction. 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-sideValidate()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.tshas noDEV_MOCK_*fallback, unlike other recently-added ui-admin-application features — tracked in Technical Debt — TD-00019, TD-03.GetTenantCodeis 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.