Data Model
Mika models commerce with typed DTOs and backend repository ports.
Read the model in three layers:
| Layer | Source | Purpose |
|---|---|---|
| Public DTOs and inputs | ../emdash-mika/src/api/types.ts |
Stable JSON shapes returned by MikaApi, Astro Actions, plugin routes, and client helpers. |
| Backend repository ports | ../emdash-mika/src/api/backend.ts |
Host-owned persistence contracts used to implement cart, checkout, order, stock, account, webhook, email, and admin flows. |
| Persisted documents | ../emdash-mika/src/types/documents.ts and ../emdash-mika/src/storage/collections.ts |
Internal storage envelopes and index config used by Mika’s backend implementation. |
The public surface is the DTO/API contract. Storage documents and migrations are implementation details; do not document storage as a stable public package subpath.
Core Concepts
Section titled “Core Concepts”ContentRefDTOconnects a sellable to host content withcollection,id, and optionallocale. Product routes can use slugs, but Mika catalog lookup uses this stable content ref.SellableDTOis the purchasable unit. It carries active state, title, optional SKU, variant options/groups, prices, and optional availability.PriceDTObelongs to a sellable and records amount, currency, purchase mode, fulfillment kind, subscription interval fields, and active state.AvailabilityDTOis a read-time stock snapshot for a sellable, including status, available quantity, max-per-order, and low-stock flags.CartDTO,WishlistDTO,CheckoutSessionDTO,OrderSummaryDTO,SubscriptionDTO,DownloadDTO, andEntitlementDTOare operation-facing views, not raw storage records.
The copied account templates can render license rows through their own MikaTemplateAccountLicense extension in templates/astro/lib/account.ts. That is a template display shape, not a public core DTO exported from @bnomei/emdash-mika/types.
Product To Sellable Example
Section titled “Product To Sellable Example”A host product entry can have one stable content ref and several Mika sellables:
EmDash/content entry collection: products id: mira-field-clipboard slug: /products/mira-field-clipboard
Mika sellable contentRef: { collection: "products", id: "mira-field-clipboard" } id: sellable_panel_pack_mira prices: - id: price_panel_pack_mira amount: 1900 currency: USD mode: one_time availability: status: in_stock maxPerOrder: 3The route slug is host-owned. The content ref is the stable join between the product entry and Mika catalog data.
Internal Collection Partitions
Section titled “Internal Collection Partitions”Mika’s default storage config groups internal documents into five partitions:
| Partition | Main document types |
|---|---|
catalog |
catalog items and coupons. |
session |
carts, wishlists, and checkout sessions. |
account |
customers, provider accounts, subscriptions, entitlements, and licenses. |
ledger |
orders. |
ops |
webhooks, email messages, account export/delete records, provider sync runs, workflows, and admin audit events. |
Those names explain how the package backend thinks about data, but host apps should integrate through MikaApi, repository ports, provider adapters, and copied Astro surfaces rather than depending on internal collection paths.
The backend repository port set is wider than the default storage document partitions. Current backend wiring also includes stock for stock items, events, and reservations, plus ephemeral for expiring token, lock, rate-limit, and cache records. Treat those as backend persistence responsibilities, not public DTOs or stable storage subpaths.
Seeded Template Data
Section titled “Seeded Template Data”../emdash-mika-template/seed/mika-actions.seed.json is fixture data for a runnable EmDash app. It defines EmDash collections such as products, stock items, customers, orders, and action button fields so the template can smoke-test admin actions and storefront flows.
Do not treat the seed file as Mika’s schema. It is a host-app fixture that exercises Mika contracts.
Related Tasks
Section titled “Related Tasks”- Product Authoring maps host content into sellables, prices, stock, and public metadata.
- Types lists DTO and branded primitive export groups.
- First Product Page shows the route-level content ref lookup.
Source Anchors
Section titled “Source Anchors”- ⓟ
../emdash-mika/src/types/index.ts - ⓟ
../emdash-mika/src/types/documents.ts - ⓟ
../emdash-mika/src/api/types.ts - ⓟ
../emdash-mika/src/api/backend.ts - ⓟ
../emdash-mika/src/storage/collections.ts - ⓟ
../emdash-mika/src/types/operational.ts - ⓐ
../emdash-mika/src/templates/astro/lib/account.ts - ⓣ
../emdash-mika-template/seed/mika-actions.seed.json