Add Polaris frontend: storefront + admin console (React 18/Vite/TS/Tailwind)
- Shared src/lib/api.ts fetch wrapper -> /api with Cache-Control: no-store - Storefront: home hero, shop grid (category filter + search), product detail, cart, checkout (POST /api/orders -> confirmation + order number), order tracking - Admin: JWT login, today KPI dashboard (revenue/orders/gross/net/margin/aov/refunds), top products, supplier performance, product import, lifecycle view, order list with tracking simulation - Multi-stage Dockerfile (Vite build -> nginx static + /api proxy -> api:8000) - nginx.conf with SPA fallback and no-store HTML caching - mock/mock_api.py for local verification (excluded from image)
This commit is contained in:
37
frontend/README.md
Normal file
37
frontend/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Polaris — Frontend
|
||||
|
||||
React 18 + Vite + TypeScript + Tailwind. Two surfaces sharing one API client (`src/lib/api.ts`):
|
||||
|
||||
- **Storefront** `/` — home hero, shop grid (category filter + search), product detail, cart, checkout, order tracking.
|
||||
- **Admin** `/admin` — JWT login, today KPI dashboard, top products, supplier performance, product import, lifecycle view, order list with tracking simulation.
|
||||
|
||||
## Layout
|
||||
|
||||
```
|
||||
src/lib/api.ts shared fetch wrapper → /api, Cache-Control: no-store
|
||||
src/lib/types.ts models mirroring db/schema.sql
|
||||
src/store/cart.tsx cart context (localStorage-persisted)
|
||||
src/pages/* storefront pages
|
||||
src/admin/* admin console pages
|
||||
nginx.conf static + proxy /api → api:8000 (compose service `api`)
|
||||
Dockerfile multi-stage: node build → nginx runtime
|
||||
mock/mock_api.py standalone mock API for local verification (not shipped in image)
|
||||
```
|
||||
|
||||
## Dev
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run dev # Vite dev server proxies /api → http://localhost:8000
|
||||
```
|
||||
|
||||
Run the mock API in another terminal: `python3 mock/mock_api.py` (admin: `admin@polaris.shop` / `polaris-admin`).
|
||||
|
||||
## Build / verify
|
||||
|
||||
```bash
|
||||
npm run build # tsc --noEmit (no TS errors required) + vite build → dist/
|
||||
docker build -t polaris-frontend .
|
||||
```
|
||||
|
||||
The nginx image serves `dist/` and proxies `/api/` to the `api` service on port 8000.
|
||||
Reference in New Issue
Block a user