How medusajs/nextjs-starter-medusa works
Main System Components
a) Frontend Layer (Next.js Application)
• Client-side Components
• Server Components
• App Router Structure
• Static/Dynamic Routes
b) Backend Layer (Medusa Server)
• API Endpoints
• Commerce Modules
• Payment Integration (Stripe)
c) External Services
• Stripe Payment Processing
• Content Delivery Network (for static assets)
Architectural Patterns to Highlight
a) Next.js App Router Architecture
• Route Groups: (checkout), (main)
• Dynamic Routes: [countryCode], [handle], etc.
• Parallel Routes: @dashboard, @login
• Loading and Error States
b) Module-based Structure
• Account Management
• Cart Management
• Checkout Flow
• Product Management
• Layout Components
Specific Implementation Details
a) Core Modules (src/modules/):
• Account
• Cart
• Checkout
• Products
• Layout
• Common Components
b) Data Flow Layer (src/lib/):
• Context Providers
• Data Fetching
• Hooks
• Utilities
┌─ Client Browser ─────────────────────────────────────┐
• ┌─ Next.js Frontend ──────────────────────────┐ │
• ┌─ App Router ─────┐ ┌─ Modules ─────────┐ │ │
• Dynamic Routes │ │ - Account │ │ │
• Loading States│ │ - Cart │ │ │
• Error Handling│ │ - Checkout │ │ │
• ┘ │ - Products │ │ │
• Layout │ │ │
• ┌─ Library ──────┐ └─────────────────┘ │ │
• Context │ │ │
• Data Fetch │ ┌─ Components ────┐ │ │
• Hooks │ │ - UI Elements │ │ │
• Utils │ │ - Forms │ │ │
• ┘ └────────────────┘ │ │
• ┘ │
• ↕ │
• ↕───────────────────────┘
• ↕
┌─────────────────────────↕───────────────────────┐
• Medusa Backend Server (API) │
• ┬─────────────────────────────┘
• ↕
┌───────────────────↕─────────────────────────────┐
• External Services (Stripe) │
• ┘