How radwan-alzerary/ecommerance works
Project type and purpose
• This is a monolithic Next.js e-commerce front-end (no internal API routes) built with React, TypeScript, Tailwind CSS, and the Next.js App Router.
• It renders product/category pages server-side or statically, manages cart/favorites/auth state client-side via React Context, and fetches real-world data from an external headless API (or uses dummy data locally in development).
File structure
• app/
• Holds the App Router folders for pages, layouts, and global CSS.
• Nesting (e.g. categories/[category], products/[id]) shows dynamic-routing SSR/SSG.
• components/ & components/ui/
• “ui” subfolder contains generic primitives (buttons, cards, inputs).
• Top-level components implement feature UI (HeroSection, ProductGrid, CartContext).
• contexts/
• React Context providers for Auth, Cart, Favorites, Language, Theme, mounted in app/providers.tsx.
• hooks/
• Custom hooks (useAuth, useCart) for encapsulating context & side-effects.
• lib/
• api.ts & apiUrl.ts define HTTP wrappers to the external API.
• cookieUtils for session management; utils.ts for helper functions.
• data/dummyData.ts
• Static mock data for local development.
• utils/translations.ts
• Static translation mappings for multi-language support.
• Config files
• next.config.mjs, tailwind.config.ts, postcss.config.mjs define build, styling, and deployment settings.
README for insights
• Deployment target is Vercel; default SSR/SSG served from Vercel’s serverless platform, assets served via Vercel’s CDN.
Elements
• Clouds for external services/CDN
• Browser → Next.js Server (page requests)
• Next.js Server → External API → DB (data fetching)
• Browser ↔ Contexts/API (client‐side user actions)
• Browser → CDN (static asset retrieval)
• Client-side React/Context elements in another
Detailed guidance
• App Router (layouts/pages)
• Service Layer (lib/api.ts)
• Context Providers (Auth, Cart, Favorites, Language, Theme)
• Component Hierarchy (UI primitives vs feature components)