# saleor/storefront architecture

> Architecture diagram of the GitHub repository saleor/storefront, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saleor/storefront
- Repository: https://github.com/saleor/storefront

## Overview

##### Key Relationships to Highlight

- Client-side to Server-side communication
- GraphQL data flow between frontend and Saleor
- Payment processing flow
- Authentication flow
- Shopping cart state management

##### Component Details

- Store Views
- Product Catalog
- Cart
- Checkout
- User Account
- Authentication
- Login
- User Management
- Shopping Experience
- Search
- Categories
- Collections

API Layer (show as middleware):
- GraphQL Operations
- Queries
- Mutations
- Payment Processing
- Draft Mode Handler

##### Technical Stack Indicators

Badges or labels for:
- Next.js 14
- React 18
- TypeScript
- GraphQL
- TailwindCSS
- Saleor Backend

##### Performance Features

Optimization features:
- Image optimization
- Server-side rendering
- Data caching
- Fast refresh

Remember to emphasize the modular nature of the checkout system, as it's designed to be portable to other frameworks, and highlight the integration with Saleor's backend services.

This system design should help developers understand both the high-level architecture and the detailed component interactions within the storefront application.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        Store["Main Store Interface"]
        Checkout["Checkout System"]
        Cart["Shopping Cart"]
        Products["Product Catalog"]
        Search["Search Functionality"]
        Auth["User Authentication"]
        Orders["Order Management"]
        Collections["Collections System"]
        Categories["Categories System"]
        UI["User Interface Components"]
        Nav["Navigation System"]
    end

    subgraph Integration
        GraphQL["GraphQL API Interface"]
        DraftMode["Draft Mode System"]
        
        subgraph Payments
            PaymentGateways["Payment Gateways"]
            Adyen["Adyen Integration"]
            Stripe["Stripe Integration"]
        end
    end

    subgraph Backend
        Saleor["Saleor Backend"]:::external
        CDN["Content Delivery Network"]:::external
        PaymentServices["Payment Processing Services"]:::external
    end

    %% Frontend Relationships
    Store --> Nav
    Store --> UI
    Store --> Products
    Store --> Cart
    Cart --> Checkout
    Store --> Search
    Store --> Auth
    Store --> Orders
    Store --> Collections
    Store --> Categories

    %% Integration Relationships
    Store --> GraphQL
    GraphQL --> Saleor
    Checkout --> PaymentGateways
    PaymentGateways --> Adyen
    PaymentGateways --> Stripe
    PaymentGateways --> PaymentServices
    Store --> DraftMode

    %% Backend Relationships
    Saleor --> CDN
    
    %% Styling
    classDef external fill:#gray
    classDef frontend fill:#blue
    classDef payment fill:#orange
    classDef auth fill:#purple

    %% Click Events
    click Store "https://github.com/saleor/storefront/tree/main/src/app/[channel]/(main)"
    click Checkout "https://github.com/saleor/storefront/tree/main/src/checkout"
    click Cart "https://github.com/saleor/storefront/tree/main/src/app/[channel]/(main)/cart"
    click Products "https://github.com/saleor/storefront/tree/main/src/app/[channel]/(main)/products"
    click Search "https://github.com/saleor/storefront/tree/main/src/app/[channel]/(main)/search"
    click Auth "https://github.com/saleor/storefront/tree/main/src/app/[channel]/(main)/login"
    click GraphQL "https://github.com/saleor/storefront/tree/main/src/graphql"
    click PaymentGateways "https://github.com/saleor/storefront/tree/main/src/checkout/sections/PaymentSection"
    click Adyen "https://github.com/saleor/storefront/tree/main/src/checkout/sections/PaymentSection/AdyenDropIn"
    click Stripe "https://github.com/saleor/storefront/tree/main/src/checkout/sections/PaymentSection/StripeElements"
    click DraftMode "https://github.com/saleor/storefront/tree/main/src/app/api/draft"
    click UI "https://github.com/saleor/storefront/tree/main/src/ui/components"
    click Nav "https://github.com/saleor/storefront/tree/main/src/ui/components/nav"
    click Orders "https://github.com/saleor/storefront/tree/main/src/app/[channel]/(main)/orders"
    click Collections "https://github.com/saleor/storefront/tree/main/src/app/[channel]/(main)/collections"
    click Categories "https://github.com/saleor/storefront/tree/main/src/app/[channel]/(main)/categories"
```
