Production Backend Wiring
Use this page to decide whether a host API is ready to leave fixture mode.
Prerequisites
Section titled “Prerequisites”- Durable storage for catalog, sessions, accounts, ledger/order data, ops/workflow/email/webhook records, stock, and ephemeral records.
- A provider registry for the provider behavior the host exposes.
- Notification delivery or an explicit decision to use Mika defaults where they exist.
- Idempotency storage for protected replay-sensitive operations.
- Scheduler access for maintenance tasks.
import { createMikaBackendApi } from "@bnomei/emdash-mika/server";import { createMikaProviderRegistry } from "@bnomei/emdash-mika/provider";
export const api = createMikaBackendApi({ repositories, providers: createMikaProviderRegistry([stripeProvider]), notifications, defaults, config, createId, now, hash,});Required Dependency Groups
Section titled “Required Dependency Groups”| Group | Host responsibility |
|---|---|
| Repositories | Durable catalog, session/cart/wishlist/checkout, account, ledger/order, ops/workflow/email/webhook, stock, and ephemeral storage. |
| Provider registry | Registered provider adapters for hosted checkout, portal, invoice, refund, subscription, sync, and webhook behavior the host actually uses. |
| IDs and time | Stable createId, now, optional isoNow, and clock behavior for tokens, reservations, workflows, and audit records. |
| Hashing | Host-selected hashing for email/customer/account lookup, download tokens, and verification-sensitive records. |
| Defaults | Currency, locale, provider, and other defaults that let operations avoid hidden global assumptions. |
| Config | TTLs, return paths, magic-link paths, token lifetimes, metadata, and checkout behavior. |
| Notifications | A hook that maps Mika intents to host-owned mail/support/ops delivery. |
| Maintenance | A scheduled runner plus optional repositories, outbox runner, and ACP session cleanup so email outbox, stuck email leases, raw webhook payload retention, ACP sessions, expired reservations, ephemeral rows, account-delete queues, and stuck workflows are processed. |
Repository Reality
Section titled “Repository Reality”The source repository layer groups state into catalog, session, account, ledger, ops, stock, and ephemeral concerns. A production host does not need to expose those internal storage files as public API, but it does need equivalent durable behavior.
Mika can safely replay some workflows only when storage can persist the relevant idempotency and workflow markers. Examples include checkout idempotency, stock reservation idempotency, webhook deduplication, admin audit records, email outbox state, and account-delete requests.
Provider Is Not Persistence
Section titled “Provider Is Not Persistence”Adding Stripe does not create:
- product catalog records;
- cart/session persistence;
- stock reservations;
- order ledger storage;
- webhook deduplication records;
- email outbox storage;
- idempotency records;
- tax or shipping rules.
The provider adapter only translates provider-facing work. The repositories remain host-owned.
Verify Production Readiness
Section titled “Verify Production Readiness”assertMikaApiWired(api, { scope })passes for the operation families the host exposes.- Checkout start receives a host idempotency key where the calling surface needs replay safety.
- Provider webhooks preserve the raw request body until the adapter verifies the signature.
- Webhook records are deduplicated by provider event ID or payload hash.
- Stock reservations expire through scheduled maintenance; do not rely on users reaching checkout cancel routes.
- Account export/delete queues have a maintenance path, and account-delete maintenance can resume recorded cleanup steps after partial failure.
- Raw webhook provider payload retention and ACP session cleanup have configured limits or stores when those surfaces are enabled.
- Notification hooks either deliver or explicitly allow Mika defaults for supported intents.
- Admin runner routes are reachable only through trusted EmDash/admin surfaces.
You are ready to leave fixture mode when those checks are true for every route or Action the host exposes.
Next: Stripe Provider wires an optional provider adapter. Server API and Provider Contract list the exact backend and adapter contracts.
Source Anchors
Section titled “Source Anchors”- ⓟ
../emdash-mika/src/server.ts - ⓟ
../emdash-mika/src/api/backend.ts - ⓟ
../emdash-mika/src/api/server.ts - ⓟ
../emdash-mika/src/storage/repositories.ts - ⓟ
../emdash-mika/src/api/maintenance.ts - ⓟ
../emdash-mika/src/api/email-outbox.ts - ⓟ
../emdash-mika/src/provider.ts - ⓣ
../emdash-mika-template/src/lib/mika-api.ts