# husnain-ashfaq39/walewah-online-shop architecture

> Architecture diagram of the GitHub repository husnain-ashfaq39/walewah-online-shop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/husnain-ashfaq39/walewah-online-shop
- Repository: https://github.com/husnain-ashfaq39/walewah-online-shop

## Overview

##### Project Type and Purpose
- This is a full-stack, internationalized e-commerce front-end built with Next.js 13’s App Router.
- It delivers server-rendered pages, client-side hydration, and static assets (images, SCSS, SVG) to optimize performance and SEO.
- It consumes external RESTful APIs (via Axios in src/Utils/AxiosUtils/API.js) for products, orders, authentication, cart, blog, settings, etc.

##### Top-Level Architectural Overview
- User’s Browser (Client)
- Next.js Frontend Server (Edge or Node)
- App Router handles SSR/SSG and API‐fetch caching
- Middleware for routing / authentication
- Public CDN or Static Hosting
- Serves /public and /.next/static assets
- External API Backend(s)
- Authentication Service (login, OTP, reset)
- Product & Catalog Service
- Order & Cart Service
- User Profile Service
- Blog/CMS Service
- Third-Party Integrations
- Payment Gateway (Stripe, PayPal, etc.)
- Email/SMS Provider (OTP, notifications)
- Analytics / A/B Testing
- Data Stores (behind the APIs)
- Relational/NoSQL DB for users, orders, products
- Blob storage for images/content

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Browser["User Browser"]:::presentation
        CDN["Public CDN / Static Hosting"]:::presentation
    end

    %% Next.js Server Layer
    subgraph "Next.js Server (Edge/Node)" 
        direction TB
        Middleware["Middleware (Routing & Auth)"]:::service
        AppRouter["App Router (SSR/SSG/ISR)"]:::service
        APIUtils["API Utility Layer (Axios)"]:::service
        NoSSRComp["No-SSR Component"]:::service
        subgraph "Internationalization" 
            direction TB
            I18nConfig["i18n Settings"]:::service
            I18nClient["i18n Client Setup"]:::service
            I18nProvider["I18Next Provider"]:::service
            I18nLocales["Locale Files"]:::service
        end
        subgraph "Context Providers"
            direction TB
            CartCtx["CartContext"]:::service
            ProductCtx["ProductContext"]:::service
            AccountCtx["AccountContext"]:::service
            CategoryCtx["CategoryContext"]:::service
            CompareCtx["CompareContext"]:::service
            CurrencyCtx["CurrencyContext"]:::service
            BlogCtx["BlogContext"]:::service
            SettingCtx["SettingContext"]:::service
            ThemeOptCtx["ThemeOptionsContext"]:::service
            ProdIdsCtx["ProductIdsContext"]:::service
        end
        subgraph "Layout & Theming"
            direction TB
            LayoutMain["Main Layout"]:::presentation
            LayoutRoot["Root Layout"]:::presentation
            LayoutIndex["Global Layout Components"]:::presentation
            Header["Header Variants"]:::presentation
            Footer["Footer"]:::presentation
            ThemeActivator["Theme Activator"]:::presentation
        end
        subgraph "UI Components"
            direction TB
            CartUI["Cart"]:::presentation
            CheckoutUI["Checkout"]:::presentation
            ProductDetailsUI["Product Details"]:::presentation
            AccountUI["Account Sections"]:::presentation
            BlogsUI["Blogs"]:::presentation
            CollectionUI["Collection Pages"]:::presentation
            CommonUI["Common UI Elements"]:::presentation
            SearchUI["Search"]:::presentation
            WishlistUI["Wishlist"]:::presentation
            SellerUI["Vendor/Seller"]:::presentation
        end
        subgraph "Custom Hooks & Utils"
            direction TB
            ToastNotif["Toast Notifications"]:::service
            AuthHooks["Auth Hooks"]:::service
            CRUDHooks["CRUD Hooks"]:::service
            OtherHooks["Other Utility Hooks"]:::service
        end
        Browser -->|"Request SSR Page"| AppRouter
        AppRouter -->|"calls API Utils"| APIUtils
        AppRouter -->|"uses Middleware"| Middleware
        AppRouter -->|"loads Layouts & UI"| LayoutMain
        APIUtils --> I18nProvider
        APIUtils --> CartCtx
        NoSSRComp --- AppRouter
    end

    %% External APIs
    subgraph "External API Backend(s)" 
        direction TB
        AuthService["Authentication Service"]:::service
        CatalogService["Product & Catalog Service"]:::service
        OrderService["Order & Cart Service"]:::service
        ProfileService["User Profile Service"]:::service
        BlogService["Blog/CMS Service"]:::service
    end

    %% Third-Party Integrations
    subgraph "Third-Party Services"
        direction TB
        PaymentGW["Payment Gateway"]:::external
        EmailSMS["Email/SMS Provider"]:::external
        Analytics["Analytics / A/B Testing"]:::external
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        RelationalDB["Relational/NoSQL DB"]:::storage
        BlobStorage["Blob Storage (Images/Content)"]:::storage
    end

    %% Static Assets
    subgraph "Static Asset Pipeline"
        direction TB
        PublicAssets["Public Directory"]:::presentation
        NextStatic[".next/static & cache"]:::presentation
    end

    %% Data Flows
    Browser -->|"fetch static assets"| CDN
    Browser -->|"hydrated API calls"| APIUtils
    APIUtils -->|"GET /api/*"| AuthService
    APIUtils -->|"GET /api/*"| CatalogService
    APIUtils -->|"GET /api/*"| OrderService
    APIUtils -->|"GET /api/*"| ProfileService
    APIUtils -->|"GET /api/*"| BlogService
    AuthService --> RelationalDB
    CatalogService --> RelationalDB
    OrderService --> RelationalDB
    ProfileService --> RelationalDB
    BlogService --> RelationalDB
    CatalogService --> BlobStorage
    OrderService --> PaymentGW
    AuthService --> EmailSMS
    APIUtils --> Analytics

    %% Connections to CDN/Assets
    PublicAssets --> CDN
    NextStatic --> CDN

    %% Click Events
    click APIUtils "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Utils/AxiosUtils/API.js"
    click Middleware "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/middleware.js"
    click I18nConfig "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/app/i18n/settings.js"
    click I18nClient "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/app/i18n/client.js"
    click I18nProvider "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/I18NextContext/I18NextProvider.jsx"
    click I18nLocales "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/app/i18n/locales/{ar,en,es,fr}/common.json"
    click CartCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/CartContext/CartProvider.jsx"
    click ProductCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/ProductContext/ProductProvider.jsx"
    click AccountCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/AccountContext/AccountProvider.jsx"
    click CategoryCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/CategoryContext/CategoryProvider.jsx"
    click CompareCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/CompareContext/CompareProvider.jsx"
    click CurrencyCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/CurrencyContext/CurrencyProvider.jsx"
    click BlogCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/BlogContext/BlogProvider.jsx"
    click SettingCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/SettingContext/SettingProvider.jsx"
    click ThemeOptCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/ThemeOptionsContext/ThemeOptionProvider.jsx"
    click ProdIdsCtx "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Helper/ProductIdsContext/ProductIdsProvider.jsx"
    click LayoutMain "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/app/[lng]/(mainLayout)/layout.js"
    click LayoutRoot "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/app/[lng]/layout.js"
    click LayoutIndex "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Layout/index.jsx"
    click ThemeActivator "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Components/ActiveTheme/index.jsx"
    click CartUI "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Components/Cart/index.jsx"
    click CheckoutUI "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Components/Checkout/index.jsx"
    click ProductDetailsUI "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Components/ProductDetails/index.jsx"
    click BlogsUI "https://github.com/husnain-ashfaq39/walewah-online-shop/tree/main/src/Components/Blogs/"
    click CollectionUI "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Components/Collection/index.jsx"
    click CommonUI "https://github.com/husnain-ashfaq39/walewah-online-shop/tree/main/src/Components/Common/"
    click SearchUI "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Components/Search/index.jsx"
    click WishlistUI "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Components/Wishlist/index.jsx"
    click SellerUI "https://github.com/husnain-ashfaq39/walewah-online-shop/tree/main/src/Components/Seller/"
    click ToastNotif "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Utils/CustomFunctions/ToastNotification.js"
    click NoSSRComp "https://github.com/husnain-ashfaq39/walewah-online-shop/blob/main/src/Utils/NoSSR.jsx"

    %% Styles
    classDef presentation fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef service fill:#E0FFE0,stroke:#028A0F,color:#028A0F;
    classDef storage fill:#FFE4B5,stroke:#CC8400,color:#CC8400;
    classDef external fill:#F0D0FF,stroke:#9000A0,color:#9000A0;
```
