Architecture — Tenant Master: Configuration Wizard, Logo Pipeline, and Aggregated Tenant-Info Read Path
| Metadata | Details |
|---|---|
| System | tenant-service — Tenant Master |
| Document ID | ARCH-2026-TEN-001 |
| Author | Engineering Team |
| Status | Approved |
Implements SR-025, per the schema decision in ADR-00039.
Components
| Component | Language/Runtime | Role |
|---|---|---|
TenantConfigPage.tsx / TenantConfigController.ts |
React (admin UI) | 7-step wizard shell — dirty tracking, lazy per-step load, step navigation |
TenantRepository.ts |
React/Axios (admin UI) | Sole apiClient consumer for this feature |
ImageUploader (shared organism) + react-easy-crop |
React (admin UI) | Logo crop/zoom/rotate/flip, used only by the Theme step |
transport/api/tenant/ |
Go (Echo REST) | tenant-service’s admin + client controllers |
service/tenantconfig/, service/tenantcontact/, service/tenantaddress/, service/tenanttheme/, service/tenantpolicy/ |
Go | One service per wizard section; tenantpolicy handles all three PolicyType values |
repository/tenantconfig/, .../tenantcontact/, .../tenantaddress/, .../tenanttheme/, .../tenantpolicy/ |
Go (PostgreSQL) | Per-table persistence — tenant_configs, tenant_contacts, tenant_addresses, tenant_theme_styles, tenant_policies |
service/tenantaggregate/ (AggregatorService.Aggregate) |
Go (errgroup) |
Concurrent fan-out read across Config/Contact/Address/Policies/ApplicationConfig for the client-facing aggregate endpoints |
content-processor (async, via Pub/Sub) |
Go | Transcodes/stores the uploaded logo under transaction tenant_logo |
message_receiver/tenantlogo_receiver.go (ITenantLogoUpdateEventService.HandleImageProcessed) |
Go | Consumes content-processor’s completion event, writes the final appLogoUrl into tenant_theme_styles |
transport/grpc/tenant/ (TenantService/GetTenantCode) |
Go (gRPC server) | Read-only tenant-code lookup, consumed by order-service |
End-to-end flow (A) — Per-step independent save
- Admin opens a step;
TenantConfigController.tscalls that step’sGETonly ifloadedStepsRefhas no entry for it yet (SR-025 FR-02). - On “Save & Next,” the controller checks the step’s own dirty flag; if clean, it advances with no network call.
- If dirty,
TenantRepository.tscalls that section’sPUT /admin/api/v1/tenant/config/{basic|theme|contact|address}(SR-025 FR-04–FR-08). transport/api/tenant/maps the request and calls the matchingservice/tenant<section>/Upsert, which validates via that section’s owndomain/<feature>_validation.goand writes through its own repository —tenant_id/updated_user_id/updated_atfromAuthClaims, never the body.- A 404 from the preceding
GET(section never saved before) is treated by the controller as an empty form, not an error (SR-025 FR-12).
End-to-end flow (B) — Logo upload and asynchronous completion
- On the Theme step, the admin picks/crops/rotates the logo through the shared
ImageUploader+react-easy-crop. - The crop is uploaded into
content-processor’s pipeline under transaction nametenant_logo, keyed deterministically by the tenant’s own ID — a tenant has exactly one logo slot, so a re-upload overwrites the same object rather than creating a new one (SR-025 FR-06). - The wizard shows a presigned display URL immediately for on-screen preview; this URL is never written into
appLogoUrldirectly — the Theme step’s ownPUT(flow A) persists every other theme field in the same request, butappLogoUrlstays whatever it already was until step 4. - Once
content-processorfinishes transcoding, it publishes a completion event;tenant-service’smessage_receiver/tenantlogo_receiver.goconsumes it and callsservice/tenanttheme/UpdateLogoUrl, which writes the finalappLogoUrlintotenant_theme_styles— a second, independent write from the admin’s ownPUT, arriving asynchronously.
End-to-end flow (C) — Policy save with auto-versioning
- Admin edits
policyContentfor Terms, Privacy, or Returns, optionally inserting a placeholder token (store name, address line, phone, support email, etc.) from the quick-insert list (SR-025 FR-11). PUT /admin/api/v1/tenant/config/{terms|privacy|returns}carries onlypolicyContent— the request never includesversion.service/tenantpolicy/UpsertPolicy(policyType, ...)reads the existing row (if any) for(tenant_id, policy_type), computes the next version (v1if none exists, else increment), and writes bothpolicyContentand the newversion(SR-025 FR-10) throughrepository/tenantpolicy/.- The response echoes the new
version, which the Terms/Privacy/Returns step renders as a read-only chip.
End-to-end flow (D) — Downstream aggregate reads and gRPC identity lookup
GET /client/api/v1/tenant-infocallsAggregatorService.Aggregate, which fans out concurrently (errgroup) across the Config/Contact/Address/Policies/ApplicationConfig repositories, flattens the results into one response, and resolves every placeholder token inpolicyContentagainst the freshly-read Basic/Address/Contact values before returning — gated toStatus = ACTIVEand a non-blankFirebaseTenantID(SR-025 FR-13).GET /client/api/v1/policiesruns the same aggregation and placeholder-resolution path, scoped to just the three policies, reachable without an authenticated session for pre-login policy display.order-servicecallsTenantService/GetTenantCodeover gRPC (identity only, no config fan-out) when formatting an order code (SR-025 FR-14).- The mobile app’s own
TenantInfoServiceis the other side of step 1 — it performs exactly thistenant-inforead on behalf of the Settings area’s About, Help & Support, Terms, Privacy, and Returns screens, so this flow’s output is what a shopper actually sees on-device. See Architecture — Customer Settings, Flow (G) for that consuming side.
Why this is simple, and what it does not yet guarantee
Splitting each wizard section into its own table and repository means every independent-save step (SR-025 FR-01) is a single-table, single-transaction write with no cross-section locking — the same shape Package Master’s single-service flow has, just across five tables instead of one. The policy-type discriminator means a fourth policy type, if ever added, is a new policy_type value and a new quick-insert-token mapping, not a new table or service.
This flow does not yet guarantee: (a) that a field the admin UI requires client-side (several Theme/Address/Contact fields, per SR-025’s Validation Parity note) is actually enforced server-side — a write that bypasses the admin form could persist a blank or malformed value; (b) that a failed logo-processing completion event is retried or surfaced to the admin — flow (B) step 4 is a fire-and-forget consumer with no compensating UI feedback if it never arrives; (c) that the wizard’s step-indicator navigation matches the admin app’s own documented non-interactive step-indicator convention. All three are tracked in Technical Debt — TD-00019.
Related Documents
- BRD-024 — Tenant Master: Configuring Store Identity, Branding, and Policies
- SR-025 — Tenant Master: Configuration Wizard System Requirements
- ADR-00039 — Per-Section Normalized Config Tables with a Policy-Type Discriminator for Tenant Configuration
- Technical Debt — Tenant Master Gaps
- Admin UI Walkthrough — Tenant Master
- Architecture — Customer Settings: Component Topology and Data Flow — downstream consumer of flow (D)‘s aggregate read path
- Microservices: tenant-service, content-processor, order-service