Skip to main content
HS
HiSETSuccess
LeetCode Prep

AI & FDE Interview Room

Role paths, mocks, cost studio, chapters, cases, and staff-level depth.

Case study · FDE · 35 min

Multi-Tenant AI Customization Without Forks

Support per-customer prompts, tools, and retrieval sources without maintaining one-off code forks for each deployment.

FDEmulti-tenantconfig

Interview opener

Every customer wants bespoke prompts and workflows.

  1. 1.When does customization become an unmaintainable fork?
  2. 2.How do you productize patterns across tenants?
  3. 3.Who pays for permanent snowflakes?

Strong signals

Hit 0/3

Weak signals (avoid)

  • Fork the repo per customer
  • Say yes to everything

Requirements

  • 50 tenants; 10 want custom tone; 5 need custom tools; all share core product
  • Config-driven customization; no per-tenant git branches
  • Isolation: data, cache, secrets, rate limits per tenant
  • Upgrade: core improvements roll to all within 1 week

Back-of-envelope Estimation

MetricCalculationResult
Tenants5050
Config versions/tenantavg 4200 configs
Fork cost if branched50 × 2 eng-days/upgrade100 days/release
Config approach1 core + overlays~3 days/release
Savings100 − 3~97 eng-days/release

API Design

EndpointMethodDescription
PUT /v1/tenants/{id}/configPUTOverlay: prompts, tools allow-list, branding
GET /v1/tenants/{id}/config/diffGETShow divergence from core defaults
POST /v1/tenants/{id}/validatePOSTRun tenant eval suite before activate

Data Model

EntityKey fieldsNotes
tenant_configtenant_id, version, json_overlayJSON Schema validated
tool_registrytool_id, schema, risk_levelGlobal catalog
tenant_toolstenant_id, tool_id, enabledAllow-list join

High-level Design

Overlay composition
Request + tenant_id
   → load core defaults
   → merge tenant overlay (deep merge with deny-lists)
   → resolve tools allow-list
   → bind retrieval to tenant indexes
   → execute pipeline
Admin UX edits overlay → validate schema + eval → activate version

Deep Dive: What Belongs in Config

  • Safe: system prompt snippets, tone, retrieval filters, enabled tools
  • Unsafe as config: arbitrary code, unrestricted HTTP tools, shared cache keys
  • Productize repeated custom work after 3 similar tenants
  • Charge enterprise SKU for custom tools to fund maintenance

Bottlenecks at Scale

  • Config sprawl — lint unused overlays quarterly
  • One tenant's heavy tool breaks shared workers — isolate executors
  • Upgrade breaks overlay assumptions — contract tests per tenant suite

Failure Modes & Monitoring

SLOTargetAlert
Config activate success99%Warn on validate fail spike
Cross-tenant data leak0Red-team continuous
Core upgrade adoption< 7 daysTrack lagging tenants
Custom tool errors< 1%Per-tenant dashboards