System Architecture

Updated 8 July 2026

Understanding the architecture is crucial for building and maintaining the application. This section covers the overall system design, data flow, and component relationships.

High-Level Architecture

The application follows a headless commerce architecture with clear separation between frontend and backend:

System Architecture

Architecture Layers

Presentation Layer

Next.js pages and React components that render the UI. Handles user interactions and displays data.

State Management Layer

React Context API for global state (Cart, Wishlist). Manages application state across components.

API Layer

Next.js API routes that act as a proxy between frontend and WooCommerce. Handles authentication and request transformation.

Backend Layer

WooCommerce REST API and Store API. Handles business logic, data persistence, and commerce operations.

Data Flow

1. Product Fetching Flow

2. Cart Operations Flow

Directory Structure

The project follows Next.js 15 App Router conventions:

src/
├── app/
│   ├── (admin)/admin/         # Admin routes (/admin/*)
│   ├── (public)/              # Public routes (/)
│   │   ├── shop/              # Shop page
│   │   ├── product/[slug]/    # Product details
│   │   ├── cart/              # Shopping cart
│   │   ├── checkout/          # Checkout
│   │   └── account/           # User account
│   └── api/                   # API routes
│       ├── products/          # Products API
│       ├── cart/              # Cart API
│       ├── checkout/          # Checkout API
│       └── admin/             # Admin API
├── components/                # React components
├── contexts/                  # State management
├── lib/woocommerce.js         # WooCommerce client
└── middleware.js              # Route protection

Route Groups

Next.js uses route groups (folders in parentheses) to organize routes without affecting the URL structure:

(admin) Route Group

(public) Route Group

Component Architecture

Server Components (Default)

Client Components

State Management Architecture

React Context API

The project uses React Context for global state management:

API Architecture

Next.js API Routes

API routes act as a proxy layer between frontend and WooCommerce:

WooCommerce Integration Points

Security Architecture

Authentication Flow

Cart Session Management