|
1
|
# Medusa Commerce — development bootstrap |
|
2
|
|
|
3
|
This folder is the planned application workspace for the **single-merchant, five-market storefront**. It is separate from the upstream Medusa monorepo packages to reduce merge conflicts. |
|
4
|
|
|
5
|
## Supported target markets |
|
6
|
|
|
7
|
| Country | ISO code | Currency | Initial commercial focus | |
|
8
|
| --- | --- | --- | --- | |
|
9
|
| Iran | IR | IRR | Electronics and mixed categories | |
|
10
|
| UAE | AE | AED | Iran-origin products | |
|
11
|
| Oman | OM | OMR | Iran-origin products | |
|
12
|
| Iraq | IQ | IQD | Iran-origin products | |
|
13
|
| Qatar | QA | QAR | Iran-origin products | |
|
14
|
|
|
15
|
Persian (`fa-IR`, RTL), Arabic (`ar`, RTL), and English (`en`, LTR) are confirmed requirements. Country/market selection is independent of the selected language. |
|
16
|
|
|
17
|
## Architectural boundaries |
|
18
|
|
|
19
|
- **Medusa backend and Admin:** retain upstream implementation until a reproducible development environment is validated. |
|
20
|
- **Storefront:** separate application, to be added after the backend's API contracts and runtime are verified. |
|
21
|
- **Inventory:** per-stock-location inventory, with Iran as the principal origin; overseas warehouse locations are optional until real locations are confirmed. |
|
22
|
- **Checkout:** region-specific payment and fulfillment provider adapters; test-mode only until merchant authorization, contracts and compliance checks pass. |
|
23
|
- **Pricing:** country-specific prices; IRR is the canonical rial unit, and toman presentation must be explicit. Never perform implicit currency conversion. |
|
24
|
- **Origin:** a product's country of manufacture is separate from its stock location and shipment origin. |
|
25
|
|
|
26
|
## Development milestones |
|
27
|
|
|
28
|
1. **Environment verification:** Node 22 and repository-pinned Yarn 3.2.1; dependency install, build, test and boot logs. |
|
29
|
2. **Backend instance:** create a dedicated Medusa project/instance backed by PostgreSQL, not an ad hoc edit of upstream packages. |
|
30
|
3. **Storefront shell:** product listing, product detail, cart, localized UI and responsive layout. |
|
31
|
4. **Commerce integration:** country selection, regional prices, stock-location availability, test checkout and order confirmation. |
|
32
|
5. **Quality gates:** automated tests for all five markets, RTL/LTR, shipping eligibility, inventory reservations and secrets handling. |
|
33
|
6. **Staging:** health checks, monitoring, backups, restore and rollback verification. |
|
34
|
|
|
35
|
## Local prerequisite commands (not yet executed) |
|
36
|
|
|
37
|
```bash |
|
38
|
node --version # should be v22.x |
|
39
|
corepack enable |
|
40
|
yarn --version # repo pins 3.2.1 |
|
41
|
yarn install --immutable |
|
42
|
``` |
|
43
|
|
|
44
|
The root repository is a large upstream source monorepo. Installation may require substantial resources. No successful installation or runtime has yet been demonstrated. |
|
45
|
|
|
46
|
## Release blockers |
|
47
|
|
|
48
|
- Merchant entity and PSP onboarding per market |
|
49
|
- Real warehouse locations and carriers |
|
50
|
- Specific SKUs and applicable product/export/import restrictions |
|
51
|
- Tax, customs, refund and consumer-policy requirements |
|
52
|
- Staging hosting, domain, secrets and backup policy |
|
53
|
|
|
54
|
See `PROJECT_STATUS.md` for the verified project record. |
|
55
|
|
|
56
|
## Storefront preview — new source files |
|
57
|
|
|
58
|
The initial React/TypeScript/Vite storefront scaffold now lives in `commerce/`. |
|
59
|
|
|
60
|
To run this **standalone preview** (requires Node.js 22 and npm; commands have not been verified in CI): |
|
61
|
|
|
62
|
```bash |
|
63
|
cd commerce |
|
64
|
npm install |
|
65
|
cp .env.example .env |
|
66
|
npm run dev |
|
67
|
``` |
|
68
|
|
|
69
|
Open http://localhost:5173. The storefront displays the five configured markets and currencies with independent Persian/Arabic/English RTL/LTR controls. When no Medusa backend is configured, it shows an explicitly labeled **illustrative sample catalogue** with working search, category filters and sample detail views. Sample cards are not real stock, purchasable offers or price quotations. When a real backend and publishable key are configured, it requests Medusa Store API products by matching region. It **does not process orders, payments or live pricing**. Never commit `.env` or live secrets. |
|
70
|
|
|
71
|
For the upstream monorepo, continue to use its pinned Yarn version. The standalone storefront uses npm until a workspace integration strategy is validated. |
|
72
|
|
|
73
|
## Public UI preview — Cloudflare Pages |
|
74
|
|
|
75
|
The **static development UI preview** is configured in Cloudflare Pages on the `project/medusa-foundation-audit` branch, independent of `main`: |
|
76
|
|
|
77
|
- Preview project: `medusa-commerce-preview-dm` |
|
78
|
- Public URL (available only once a Cloudflare build completes): `https://medusa-commerce-preview-dm.pages.dev/` |
|
79
|
- Build root: `commerce`; build: `npm install --no-audit --no-fund && npm run build`; published directory: `dist`. |
|
80
|
- Three languages: Persian (RTL), Arabic (RTL), and English (LTR). |
|
81
|
- Country selection: Iran, UAE, Oman, Iraq, Qatar. Prices shown only as currency labels, not real sale prices. |
|
82
|
- **No live API key, payment gateway, customer data, checkout, or production inventory is configured.** The catalog displays an unconfigured state until a real Medusa backend and publishable key are provisioned. |
|
83
|
|
|
84
|
The preview must not be represented as an operating store. A public static UI deployment does not establish any commerce or security production acceptance. |
|
85
|
|
|
86
|
### How to check the interactive preview |
|
87
|
|
|
88
|
- Cloudflare deployment: https://medusa-commerce-preview-dm.pages.dev/ |
|
89
|
- Switch between Persian, Arabic and English; layout direction changes automatically. |
|
90
|
- Change country: Iran shows sample electronics plus Iran-origin collections; the UAE, Oman, Iraq and Qatar show examples of Iran-origin collections only. All examples are illustrative, not inventory offers. |
|
91
|
- Search and category filters operate on the examples. Open a sample card for its detail overlay; use Escape or the close button to dismiss it. |
|
92
|
- Until backend credentials are configured, no legitimate add-to-cart, checkout, customer registration, stock verification or payment is available. The preview explicitly signals that fact. |
|
93
|
- Every pull-request change to `commerce/` is checked by GitHub Actions using `npm test` and `npm run build`; Cloudflare Pages builds the development branch for its public static preview without changing `main`. |
|
94
|
- If the site does not open for a visitor, first compare the canonical URL with the latest successful deployment URL in Cloudflare Pages and collect the exact browser error, network (Wi-Fi/mobile data) and country. A successful Cloudflare deployment alone does not guarantee reachability from every network. |
|
95
|
|
|
96
|
|
|
97
|
## White-screen-safe accessible preview |
|
98
|
|
|
99
|
The URL `https://medusa-commerce-access.davoodmehraban89.workers.dev/` is a **separate Cloudflare Worker** deployed from `commerce/edge/preview-worker.js`, independent of Vite and the `pages.dev` JavaScript bundles. |
|
100
|
|
|
101
|
- Returns fully rendered HTML and inline CSS on the first response; **no browser JavaScript, external fonts, image CDN, or API** is needed. |
|
102
|
- Country and language links are ordinary server-rendered HTTP GET navigation and work without JavaScript. Product sample cards are explicitly non-orderable. Search and category filtering are processed per request. |
|
103
|
- A static HTML-only page is the fallback for users whose browser shows blank output on the interactive React preview. |
|
104
|
- The worker returns 404 for unrelated paths and 405 for modifying HTTP methods. Nothing in this path accesses store data, payments, or other secrets. |
|
105
|
- The default client-side React demo remains separately available at `https://medusa-commerce-preview-dm.pages.dev/`. |
|
106
|
- **Limit:** a working outside-network check cannot prove the visitor's phone/carrier can reach `workers.dev`. If it also renders blank, collect the exact Safari/Chrome error, network type and VPN/DNS status; do not blindly assume a frontend-only problem. |
|
107
|
|
|
108
|
The accessible Worker implementation is tracked and versioned in `commerce/edge/preview-worker.js`. After modifying it, update the deployed Worker and independently verify locale/market combinations. Never pretend committing a source file alone automatically redeploys this particular Worker. |