01 Commerce · Case study
MEPADO
Personalized gifts e-commerce platform — AR / EN
A bilingual Arabic/English e-commerce platform for personalized children’s gifts, with an Angular SSR storefront, an admin dashboard, and a TypeScript API whose pricing, order lifecycle, and payments are enforced in PostgreSQL.
My contribution
Sole developer end to end — requirements analysis, architecture, Angular SSR storefront, admin dashboard, Express API, PostgreSQL schema, testing, and deployment.
Overview
Every order is made to order: personalization, an optional physical sample, design approvals, an offline deposit, production, shipping, and changes or cancellations along the way. The hard part was correctness rather than screens — exact money arithmetic across several discount types, coupon rules with caps and exclusions, offline partial payments, prices that can change after checkout, and customers and staff acting on the same order at the same time, without a lost payment, a duplicate order, or a wrong total.
My role
Freelance project developed for a client. I was the only developer and handled the technical work end to end: requirements analysis, business-rule implementation, architecture, frontend, backend, database, testing, and production deployment. Built solo with AI-assisted development (Claude Code, Cursor): I owned the architecture, technical decisions, code review, and validation.
Surfaces
- 01
Storefront
Arabic-first Angular SSR store with English build — personalization, checkout, customer accounts, order timeline, and moderated reviews.
- 02
Admin dashboard
Bilingual staff console for products, discounts and coupons, the full order lifecycle, customers, review moderation, content, and permissions.
- 03
API & database
Express/TypeScript REST API on Supabase PostgreSQL that enforces pricing, the order lifecycle, and payments with transactional SQL functions and Row Level Security.
Implementation
- Arabic (RTL) and English storefront builds with a prerendered home page
- Catalog with search, variants, related products, and nine personalization field types including photo upload
- Cart and checkout with price-change confirmation after order edits
- Customer accounts: addresses, children profiles, wishlist, consents, password reset, and data erasure
- Order timeline with sample and design approvals, change proposals, and cancellation requests
- Coupon and automatic-discount engine with targets, exclusions, minimums, caps, and 24-hour reservations with locked terms
- Admin order operations: samples, design versions, offline payment receipts, production, shipping, delivery, and cancellations
- Granular admin permissions with an activity log, charts, and Excel export
- Automated API unit and integration tests, SQL test suites, concurrency tests, and Puppeteer browser tests
Architecture
- Three applications in three repositories: Angular 22 SSR storefront, Angular 22 admin dashboard, and an Express/TypeScript REST API
- Supabase PostgreSQL schema (42 migrations, 59 tables) with business invariants in constraints, triggers, and transactional PL/pgSQL functions, plus Row Level Security
- Single backend pricing engine in integer piastres with ROUND_HALF_UP matching PostgreSQL; the database re-checks every price at checkout
- Atomic checkout in one PostgreSQL transaction, serialized per customer by an advisory lock, with idempotency keys for retries
- Database-enforced order state machine: 11 statuses, guarded transitions, and one global lock order to prevent deadlocks
- Append-only pricing versions, payment obligations, and receipts, plus a transactional email outbox claimed with FOR UPDATE SKIP LOCKED
- httpOnly cookie sessions, per-app CORS and Origin-based CSRF checks, granular admin permissions, rate limits, signed URLs, and startup environment validation
Engineering challenges & decisions
Challenge 01
Rounding drift between JavaScript and PostgreSQL across discounts and caps.
Decision
Used integer piastres, decimal-string conversion, and half-up rounding that matches Postgres; discount caps are split by largest remainder so the parts always sum exactly.
Challenge 02
Duplicate orders from retries and double-clicks at checkout.
Decision
Serialized checkouts with an advisory lock, stored idempotency keys with a request hash, and ran checkout as one transaction that rolls back on any failure.
Challenge 03
Race conditions between payments, cancellations, and proposal expiry on the same order.
Decision
Enforced one global lock order in every SQL function, verified by concurrency tests — six simultaneous cancellation requests create exactly one record.
Challenge 04
The SSR app not starting on managed Node.js hosting.
Decision
Added a custom entry file that imports the Angular request handler and listens itself, since the server bundle only listens as the main module; a static fallback build is kept as a backup.
Scope note Repositories are private — a code walkthrough is available on request. Transactional email delivery and scheduled background jobs are implemented in code but not claimed as running in production.
Next case study