# DAR ZELLIGE — Project Status

**Last verified:** 2 December 2026  
**Status:** Portfolio demo complete and locally verified. It is presentation-ready, but it is deliberately not a production payment or fulfilment system.

DAR ZELLIGE is a fictional Marrakech maison built as a premium multilingual commerce demonstration: an editorial storefront, a complete French admin back-office, a server-validated shopping flow and a seeded catalogue in three languages.

## At a glance

| Item | Delivered |
| --- | --- |
| Storefront | Editorial homepage, shop with filters/sort/pagination, collections, product detail, journal, story, contact, FAQ, shipping, care, legal pages |
| Commerce | Persistent cart, server-recalculated prices and stock, coupons, guest or signed-in checkout, COD / bank transfer / online placeholders, order confirmation |
| Customer area | Login, register, profile, addresses, order history and detail, wishlist, password change |
| Admin | Dashboard, products, categories, orders, customers, inventory, coupons, journal, messages, settings |
| Languages | French, English and Arabic with RTL, localized metadata, prices, validation feedback and `hreflang` |
| Loading experience | Branded top progress bar on link clicks and form submits, delayed zellige veil, route skeletons and pending button spinners |
| Data | Prisma schema plus 8 categories, 30 products, 5 journal articles, 6 coupons, 11 sample orders and 5 users |
| Verification | 29 unit tests, clean TypeScript and ESLint checks, 90-page production build, manual route and CRUD sweeps |

## Architecture decisions

- **Next.js App Router, server-first.** Catalogue and account pages are Server Components. Mutations run in Server Actions with Zod validation, `revalidatePath` and database-derived values. Client Components are limited to interaction state.
- **Multiple root layouts.** `src/app/(store)/[locale]` owns the localized `<html lang dir>` shell; `src/app/(admin)` owns a separate French back-office shell. There is deliberately no global `src/app/layout.tsx`.
- **Locale-prefixed routes.** `/fr`, `/en` and `/ar`; middleware redirects `/` using cookie, then `Accept-Language`, then French. Types and dictionary key parity are checked by the test suite.
- **Portable database schema.** Statuses are strings and the schema avoids PostgreSQL-only enums, arrays and JSON. The demo runs on SQLite; the documented PostgreSQL switch changes the datasource and connection URL.
- **Server-owned commerce rules.** Cart lines store only product/variant/quantity. Price, stock, coupon, shipping and totals are re-read and recomputed server-side, and checkout runs in a transaction that writes inventory movements.
- **Session freshness.** `getSessionUser()` re-reads the user from the database. A JWT for a deleted or reset account cannot keep opening `/admin` or customer pages; a stale cart owner also cannot cause a foreign-key failure.

## Delivery by phase

| Phase | Scope | Result |
| --- | --- | --- |
| 0 — Discovery | Audited the empty workspace, fixed the stack and database strategy, mapped routes, data models and the FR/EN/AR content model | Complete |
| 1 — Foundation | Next.js/TypeScript/Tailwind setup, design tokens, shadcn-style primitives, Prisma schema and seed, Auth.js credentials and role guards | Complete |
| 2 — Storefront | Header, mega-menu, footer, editorial homepage, shop, filters, sorting, pagination, product gallery/zoom, variants, related products, collections, journal and static pages | Complete |
| 3 — Commerce | Cookie+DB cart, stock checks, coupons, shipping rules, checkout form, COD/bank/online placeholders, transactional order creation, inventory movements, confirmation access | Complete |
| 4 — Customer accounts | Register/login/logout, profile, addresses, order list and detail, wishlist, password change, localized feedback | Complete |
| 5 — Admin | Dashboard KPIs and eight-week sales chart, product/category CRUD, order workflow, customers, inventory, coupons, journal, messages, settings, image upload | Complete |
| 6 — Platform | FR/EN/AR dictionaries, RTL, canonical/hreflang metadata, sitemap, robots, JSON-LD, security headers, rate limiting, optional Cloudinary/SMTP adapters | Complete |
| 7 — Content | Fictional catalogue, local photography, five trilingual journal articles, sample reviews/testimonials, seeded orders, coupons, messages and settings | Complete |
| 8 — QA and documentation | Unit tests, typecheck, production build, route sweeps, responsive fixes, global loading design, README and this status document | Complete |

## Feature checklist

### Storefront

- Homepage with announcement bar, full-bleed hero, featured categories, best sellers, brand story, featured collection, craftsmanship section, clearly labelled sample testimonials, Instagram-style grid and newsletter.
- Shop with category, collection, price, availability and sort controls, active-filter removal, empty states and pagination.
- Product page with image gallery and hover zoom, variant selection, stock messaging, reviews, related products and add-to-cart feedback.
- Collections index and collection pages, journal index/detail with Article JSON-LD, story, contact, FAQ, shipping, care, privacy, terms and legal pages.
- Responsive header/mega-menu, search entry point, locale switcher, cart count and account entry point.
- Branded loading feedback: immediate progress bar for internal navigation and form submits, a delayed full-screen zellige veil, storefront/admin route skeletons and localized screen-reader labels. RTL mirrors the progress direction and label typography.

### Commerce

- Cart cookie (`dz_cart`) maps to a database cart; server actions validate product publication, variant ownership, stock and quantity.
- Coupons support percentage/fixed discounts, minimum spend, date windows and usage limits. Shipping is computed from settings and destination.
- Checkout supports guest and signed-in flows, validates with Zod/React Hook Form, creates a unique `DZ-2026-*` reference and returns a confirmation page.
- Order creation, stock decrement for product and variant, coupon usage increment, inventory movements and cart clearing run in a Prisma transaction.
- Admin cancellation restocks product and variant and records a cancellation movement; cancelled orders cannot be reopened.

### Customer area and admin

- Auth.js Credentials provider, bcrypt hashes, JWT sessions, server-side role checks, account and admin redirects.
- Account: overview, profile, addresses, order history/detail, wishlist, password change.
- Admin: dashboard, product/category translation management, order status/payment/carrier/tracking/notes, customer detail, inventory adjustment history, coupon CRUD, journal CRUD, messages, settings.
- Admin translation forms mount all locale tabs so FR/EN/AR values are submitted together. This was specifically regression-tested.

### Readability and surface hierarchy

- Small gold text uses a dedicated deeper `gold-ink`; secondary copy uses solid `walnut` or `pebble` instead of translucent charcoal. Input placeholders, disabled fields and table headers were raised to readable contrast.
- Admin pages sit on a parchment canvas with cream topbar/panels, visible `line` borders, soft `shadow-panel` elevation and tinted table headers. Customer-account overview cards, order rows, addresses, profile/security forms and the auth panel use the same solid cream surfaces.
- Status badges, filter tabs, pagination controls and form labels were enlarged and given consistent borders. Customer account navigation now uses a two-column grid below the desktop breakpoint, with the active destination visibly filled.

## Verification log

### Automated

| Check | Command | Result |
| --- | --- | --- |
| Unit tests | `npm test` | **29 passed** across 6 files: money, coupons, shipping, cart totals, i18n/dictionaries/messages |
| TypeScript | `npx tsc --noEmit` | **Clean**, exit 0 |
| ESLint | `npm run lint` | **Clean**, exit 0, no warnings |
| Production build | `npm run build` | **Passed**, 90 pages generated; Prisma client generated |
| Dependency audit | `npm audit --omit=dev` | **11 advisories** (1 moderate, 10 high, 0 critical); see limitations |

### Manual journeys

- FR/EN/AR storefront routes, RTL Arabic document direction and localized prices were checked in the browser.
- Guest checkout with bank transfer produced a database order, decremented stock, recorded a movement and reached the confirmation page; the database was reseeded afterwards.
- Cart add/update/remove, coupon acceptance/rejection, newsletter subscription and contact submission were exercised with localized messages in English.
- Admin CRUD was exercised end to end: category with FR/EN/AR translations, coupon create/edit/deactivate/delete, journal article with translations and public EN/AR pages, product with translations/image/publication and EN/AR storefront pages, variant inventory adjustment with movement and toast.
- Settings persistence across the six tabs was verified, as were order status controls and dashboard totals.
- The seeded database was reset after test records so the delivered demo contains only the intended catalogue, customers, orders and messages.
- A stale browser session after reseeding was used to verify that deleted-account JWTs are rejected and that the cart recovers as a guest instead of throwing a foreign-key error.
- The production upload path was tested with a valid PNG: the admin-only endpoint accepted it, the dynamic `/api/uploads/[file]` route served it as `image/png`, and missing, non-image and traversal attempts returned 404. The temporary file was removed.
- Loading feedback was browser-tested with an intentionally delayed RSC navigation: the top bar appeared immediately, the veil transitioned in after 280 ms, progress advanced, and both disappeared once the route changed. A real add-to-cart submit showed the bar plus the button spinner and success toast, then cleared.
- Customer and admin contrast was audited with computed foreground/background ratios. Account overview body text is at or above 4.5:1, and sampled admin dashboard, order-table and filter text passed after replacing low-opacity charcoal with solid walnut/pebble tokens.

### Responsive checks

- Public, account and admin screens were swept at **390 px** (plus a 609 px preview). The fixed regressions were the French product purchase row and the admin dashboard grid.
- No document-level horizontal overflow remains on the checked routes. Account navigation becomes a two-column grid below the desktop breakpoint so no destination is hidden in a horizontal strip; admin tables scroll inside bordered containers.
- The loading veil was measured at **390 px**: full-viewport coverage, no document-level horizontal overflow, and readable wordmark/label spacing. The admin dashboard and storefront were also checked at desktop width during the build.

### Production smoke test

- `next start` was run on port 3001 (port 3000 was occupied by an unrelated local app). The homepage, EN/AR pages, RTL shop, admin login, dashboard and cart were loaded successfully.
- Static assets and optimized images loaded with no console errors observed in the preview console.
- `sitemap.xml`: **159 URLs** (53 paths × 3 locales) with **477 language-alternate links**.
- `robots.txt` now disallows `/admin`, `/api` and localized cart, checkout, account, login and register routes.
- JSON-LD is present on the homepage (Organization), product pages (Product and BreadcrumbList) and journal articles (Article).

## Demo data and credentials

- Demo administrator (read-only): `admin@darzellige.ma` / `Zellige!2025`
- Superadmin (full access): created by `npm run admin:setup` or the seed; password from env or generated once
- Customer: `client@darzellige.ma` / `Zellige!2025`
- Demo credentials are shown on login screens in development only and hidden in production.
- Every order uses a fictional customer, a demo address and a `DZ-2026-*` reference. Seed dates are relative to the seed run, so reseeding refreshes the dashboard's recent activity.

## Known limitations and deliberate boundaries

| Area | Current state | What a real launch needs |
| --- | --- | --- |
| Payments | COD, bank transfer and online are demonstrative choices. No provider is contacted and no card data is collected. | A real PSP integration, server-side webhook verification, idempotency and reconciliation. |
| Fulfilment | Orders are database records; carrier and tracking are manual admin fields. | Warehouse/carrier integration, labels, returns and customer notifications. |
| Database | SQLite is used for a portable local demo. PostgreSQL was not provisioned or exercised in this environment. | PostgreSQL, migrations in CI, backups, connection pooling and load testing. |
| Email | Optional Nodemailer adapter; without SMTP, sends are skipped and logged so checkout still succeeds. No live SMTP delivery was tested. | Verified sending domain, templates, bounce handling and email logs. |
| Media | Admin-only upload validates MIME type and binary signature; Cloudinary is optional. The local `public/uploads` fallback is served dynamically and was tested in production mode, but it is not durable on serverless hosts; Cloudinary was not exercised without credentials. | Signed direct uploads, transformations, moderation and durable object storage. |
| Admin language | French-only by design, matching the brief. | Add admin locales only if the operating team needs them. |
| Rate limiting | In-memory, per-process. | Redis or another shared limiter for multi-instance deployments. |
| Automated journeys | 29 unit tests plus manual browser verification; no Playwright/Cypress E2E suite is included. | Add critical-path E2E tests and accessibility checks in CI. |
| Dependencies | Pinned, tested versions. Production audit reports 11 advisories. | A dedicated major-upgrade branch (Next 16, Prisma 7, Zod 4, nodemailer, sharp), full regression and re-audit. |
| Content | Products, images, reviews, testimonials and journal texts are fictional demonstration material. | Legal review, real rights-cleared photography and editorial approval. |

### Dependency audit note

`npm audit --omit=dev` currently exits non-zero with **11 advisories: 1 moderate, 10 high, 0 critical**. They include transitive advisories in Prisma tooling, Next/PostCSS, nodemailer, sharp and Zod. npm's suggested fixes require major upgrades (for example Next 16, Prisma 7 and Zod 4) that were outside the tested stack for this delivery, so they were intentionally not applied at the end of the build. This must be addressed in a dedicated upgrade and regression pass before any public production deployment.

## Run and verify

```bash
npm install
cp .env.example .env
npm run setup
npm run dev
```

Open `http://localhost:3000` (or the port printed by Next.js). Tests and checks:

```bash
npm test
npm run typecheck
npm run build
```

See [README.md](./README.md) for the full setup, database switch, architecture, SEO, security and deployment notes.

## Recommended next steps for a productized launch

1. Move to PostgreSQL and run migrations, backups and load tests.
2. Integrate a real payment provider with webhook verification and idempotent order handling.
3. Configure transactional email and Cloudinary, then test delivery and uploads with real credentials.
4. Add Playwright critical-path tests, accessibility scans and error monitoring.
5. Replace the in-memory limiter with a shared store, add a strict CSP and complete the dependency upgrade/audit pass.
6. Obtain legal review for the French, English and Arabic commercial, privacy and returns content.
