Data Model Overview
This section gives the entity model per store and the key API surface. It follows the polyglot ownership rules: each fact has one owner; domains reference Medusa by ID + snapshot.
Context map
Ownership quick reference
| Entity | Store | Owner | Key refs |
|---|---|---|---|
| Product / Variant / Kit | PG | Medusa | — |
| Price / PriceList | PG | Medusa | product |
| Cart / Order | PG | Medusa | customer |
| Promotion | PG | Medusa | — |
| Inventory / Reservation | PG | Medusa | variant, location |
| Payment session | PG | Medusa | order |
| Invoice / Ledger / Payout | PG | Finance | orderId, partnerId |
| Asset | Mongo | Warranty | medusaProductId, ownerId, serial |
| WarrantyClaim | Mongo | Warranty | assetId |
| ServiceTicket / Job | Mongo | FSM | assetId, medusaOrderId, technicianId |
| AMCContract | Mongo | FSM | assetId, customerId |
| ChannelPartner | Mongo | DMS | territory, tier |
| PointsLedger | Mongo | Loyalty | customerId/partnerId |
| Customer360 | Mongo | CRM | medusaCustomerId |
| Content (post/testimonial…) | Mongo | Payload | — |
| TenantConfig / AutomationSub / AuditLog | Mongo | Platform | tenantId |
ID conventions
- Internal: UUID v7 (time-ordered) everywhere.
- Public/human:
nanoidbase32 short ID for assets/warranty/"My Products" and ticket numbers. - Cross-store refs: store the Medusa ID (
medusaOrderId, etc.) and a denormalized snapshot of needed fields.
Per-store detail pages
- Commerce (Medusa / Postgres)
- FSM / Service (Mongo)
- Warranty & Assets (Mongo)
- DMS, Partners & Loyalty
- CMS Content (Payload)
- API Surface
Schemas below are design sketches (TypeScript-ish), not final migrations. They establish shape, ownership, and references.