The 3-in-1 Commerce Package — architecture
The 3-in-1 Commerce Package — architecture
Instruction (Young): "Package 3 products into single package as sell services."My lane: design and architecture. Mira: business plan. Min + Tam: package deep dive.
What is being packaged (from the verified studies)
| # | Product | Role in the package | Anchor |
|---|---|---|---|
| 1 | E-commerce site | Medusa backend + Next.js storefront, per-tenant compose on the Oracle ARM node | medusa-hosting-docker-study |
| 2 | Point of Sale | Agilo POS fork (MIT) against the same tenant backend | medusa-nextjs-commerce-study |
| 3 | AI staff | Per-tenant EVE agent (useEveAgent chat) supporting sales/support | medusa-eve-integration-study |
The product claim, kept honest: "e-commerce website + POS + AI staff" — the AI-staff tier is what Medusa Cloud does not bundle. That is the only differentiator, so it is the tier the architecture must protect.
The design principle that carries the package
One backend, three frontdoors. The three products are not three systems to run — they are three surfaces on one Medusa tenant. The storefront, the POS and the agent all address the same Postgres via the same API surfaces. Nothing in the package duplicates state.
Why this matters commercially: support cost is the hidden price of a 3-product bundle. Three sync paths is the failure mode; three frontdoors on one backend is the sellable claim.
Architecture
┌──────────────────────────────┐
storefront ───▶ │ Store API (publishable key, │
POS (Agilo) ───▶ │ read-scope, tenant-scoped) │ ◀── EVE tools hit this too
└──────────────┬───────────────┘
│
┌──────────────▼───────────────┐
│ Medusa server + worker │
│ Postgres · Redis │
└──────────────┬───────────────┘
│
┌──────────────▼───────────────┐
│ Admin API (scoped app token)│
│ ← only HIL-approved writes │
└──────────────────────────────┘
EVE agent (per tenant, self-hosted Nitro)
├── instructions.md tenant-tuned persona
├── tools/ Store API wrappers (products, carts, checkout, order-status)
├── connections/medusa.ts zod config, secrets from env — never in source
├── skills/ refund-playbook · checkout-flow · gift-card (load-on-demand)
└── workflows order-status watcher · HIL gates (refund, bulk-pricing)
The trust layer, stated as architecture not as a caution: the publishable key can only read. Every write path in the package terminates at the Admin API, and the Admin API is reachable only through a durable workflow gated by human approval. This is what makes an AI-staff tier sellable at all — a tenant will not adopt it if "AI" and "Admin" sit in the same blast radius.
Package tiers (the sellable shape)
| Tier | Products | What it is for |
|---|---|---|
| Storefront | e-commerce site alone | the entry tier |
| Storefront + POS | site + till | retail, physical stock sync |
| Storefront + POS + AI staff | all three | the margin tier, and the only one Medusa Cloud does not match |
The POS is the keystone: it is why one backend is non-negotiable. A POS writing to a separate stock store needs a sync layer, and a sync layer is the defect class this project exists to remove.
Security layer in the package (Echo, 2026-10-18)
The trust layer above governs what the AI may write. This section adds what governs humans — and it changes one sellable claim.
The package carries three identity layers, all A$0 software:
| Layer | Component | Licence | Covers in this package |
|---|---|---|---|
| L1 — platform gate | Authelia | Apache-2.0 | tenant private KB / staging portals |
| L2 — commerce identity | Medusa core MFA | MIT | storefront customers + tenant admin staff |
| L3 — agent identity | Better Auth (in EVE) | MIT | EVE chat users, per-user memory |
Full evidence: [2fa-and-account-management](2fa-and-account-management) · [authelia-optimization](authelia-optimization).
🔴 The package cannot promise staff roles
The tiers table above sells "Storefront + POS + AI staff" to a retailer — who
will very likely have staff. Role separation (admin / staff / read-only) is a
paid Medusa Enterprise feature, not MIT core. Medusa's ENTERPRISE-LICENSE.md
is explicit that RBAC and SSO are Enterprise Edition, and that the RBAC module,
its admin APIs, and its dashboard routes are proprietary.
So the honest package position:
- Pilot (1–3 people): every admin user is a full admin. Ship it.
- Any tenant with staff who must not see margin or pricing: RBAC becomes a licence line item, not build labour.
This is a pricing fact for Mira, not an engineering gap — the build is unavailable at any effort, because the code is not ours to ship.
The second guard the architecture did not have
The trust layer's claim — "every write terminates at the Admin API behind a
human-approval workflow" — gains a real enforcement seam it lacked:
Medusa's requireMfa: { maxAgeSeconds: N } requires a recent MFA challenge
for elevated actions. A refund or a bulk-pricing change approved hours ago in a
stolen session does not satisfy it.
F7 in the feature spec should therefore be strengthened: the HIL gate is proven armed and the elevated-write path requires a fresh MFA challenge. Two independent controls on the same boundary — which is what makes the AI-staff tier defensible to a tenant.
One integration rule
Do not put a tenant's Medusa Admin behind Authelia. Both layers work, but stacking them prompts the tenant admin twice. Authelia protects surfaces with no application login (static KB); Medusa MFA protects Medusa identities. Keep them disjoint — the admin vhost gets Medusa's MFA only.
Tenant isolation
Per-tenant Docker compose: server + worker + Postgres + Redis + storefront + EVE agent, entirely separate per tenant. No shared database, no shared credential. Postgres is the state of record; a tenant's data never crosses a process boundary another tenant can reach.
Sizing (carried from the co-hosting study)
One Oracle ARM node, 2–3 tenants as the pilot. Rough per-tenant footprint: Medusa server + worker (~1 GB), Postgres + Redis (~0.5 GB), storefront (~0.5 GB), EVE agent (~0.5–1 GB co-hosting scale). Per-tenant budget ≈ 3 GB — so a 24 GB ARM node pilots eight tenants, not two. I will confirm the real node spec before that number is quoted anywhere commercial; a budget measured off a study rather than the host is the stale-measurement defect.
Build sequencing (Ace's lane, off this note)
- Tenant template: Medusa prod compose + shared image pipeline.
- EVE agent template:
eve init,medusa.tsconnection, 4 starter tools, 2 skills, HIL workflow skeleton, version-pinned@workflow/*. - Demo tenant, gated on both
/healthand/eve/v1/health— a green storefront with a dead agent reads as healthy, which is the dark-fleet pattern. - POS against the same backend.
- Tenant provisioning script: compose → seed → keys → agent config.
Risk register
| Risk | Severity | Position |
|---|---|---|
| EVE is Apache-2.0 and its tooling is still moving | medium | the licence is clean; the API is not frozen. Pin the EVE version per tenant, exactly as @workflow/* is pinned. |
| HIL gating is the only thing keeping Admin writes safe | high | it must be a control, not a convention — the same class of defect as V2's built-never-wired guards. Provisioning must be able to prove it is armed. |
| Tenant sprawl on one node | medium | compose per tenant, one node; a noisy neighbour is a support ticket. Sizing needs the real host spec. |
2FA and account management (updated 2026-10-18 with Authelia + Medusa core MFA)
Features to add, functions to build, and the prod server prep
Young's rulings carried: Oracle ARM 4 vCPU · 24 GB · 200 GB (this changes my earlier estimate — see sizing below) · POS payments + offline are gaps to extend · EVE beta, "we will make it work for our business" · prices in AUD.

