# burhanahmad0/exclusive-ecommerce-website architecture

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

- Interactive diagram: https://gitdiagram.com/burhanahmad0/exclusive-ecommerce-website
- Repository: https://github.com/burhanahmad0/exclusive-ecommerce-website

## Overview

##### Main Components
- Frontend/UI Layer:
- This is primarily structured under the app directory. It includes views/pages for home (app/home), product details (app/product), about, contact, cart, checkout, whishlist, etc.
- The “components” directory contains reusable UI components (e.g., Navbar, Footer, ProductCard, SkeletonLoader) used across different pages.
- Public assets (images and fonts) and stylesheets (globals.css, globalicon.css) also play a role in the UI assembly.

- API/Backend Layer:
- API endpoints are defined under app/api (e.g., app/api/auth for authentication via NextAuth and signup, app/api/enquiry for enquiry forms).
- The authentication-related endpoints (located inside app/api/auth) and custom middleware (found in app/middlewares and middleware.js) support session management, role-based redirection, and security.

- Database & Models:
- The db directory (db/dbConnect.js) provides the connection logic to the database, although the specific database isn’t explicitly mentioned.
- Models are defined in app/models (for user and enquiry), which implies that the application uses a schema-based approach (likely with MongoDB/Mongoose or similar ORM/ODM).

- Middleware/Authentication:
- Authentication is administered through NextAuth (with its API route at app/api/auth/[...nextauth] and additional custom sign-up/auth pages under app/auth).
- Middleware components (located in app/middlewares and the global middleware.js) add layers of logic for routes (e.g., protecting pages that require authentication).

##### Understanding the Relationships and Data Flow
- The client (browser) interacts with the Next.js server, which routes requests to either UI pages or API endpoints.
- When a user navigates to a page (e.g., home, product, cart), the Next.js app renders the corresponding components and pages.
- For authentication and data manipulation, the frontend makes API requests to endpoints (such as those for signing up or enquiries). These endpoints process requests, interact with defined models, and then use the DB connection to query or update the database.
- Custom middleware ensures that requests are appropriately filtered, such as redirecting unauthenticated users away from protected pages.

##### Architectural Patterns & Design Principles
- The application follows the Next.js “app” router paradigm that promotes file-based routing.
- Separation of concerns is evident: UI components (in “components”), page routing (in “app”), business logic/API layers (in “app/api”), and data persistence (db and models) are clearly divided.
- Authentication is implemented in a modular fashion using NextAuth combined with custom middleware for further control.
- Use of Tailwind CSS (tailwind.config.js) suggests that styling is centrally configured and optimized.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client Browser"]:::external

    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        direction TB
        Home["Home Page"]:::frontend
        Product["Product Page"]:::frontend
        About["About Page"]:::frontend
        Cart["Cart Page"]:::frontend
        Checkout["Checkout Page"]:::frontend
        Contact["Contact Page"]:::frontend
        Whishlist["Whishlist Page"]:::frontend

        subgraph "Reusable Components"
            direction TB
            Navbar["Navbar"]:::frontend
            Footer["Footer"]:::frontend
            ProductCard["Product Card"]:::frontend
        end
        GlobalStyle["Global Styling (globals & icons)"]:::frontend
    end

    %% API/Backend Layer
    subgraph "API/Backend Layer"
        direction TB
        NextAuth["NextAuth API"]:::backend
        SignupAPI["Signup API"]:::backend
        EnquiryAPI["Enquiry API"]:::backend

        subgraph "Authentication & Middleware"
            direction TB
            Login["Login Page"]:::backend
            SignupPage["Signup Page"]:::backend
            CustomMiddleware["Custom Middleware"]:::backend
        end
    end

    %% Database & Models
    subgraph "Database & Models"
        direction TB
        DBConnect["DB Connection"]:::database
        UserModel["User Model"]:::database
        EnquiryModel["Enquiry Model"]:::database
    end

    %% Configuration
    subgraph "Configuration"
        direction TB
        TailwindConfig["Tailwind CSS Config"]:::config
        NextConfig["Next.js Config"]:::config
    end

    %% Data Flow Arrows
    Client -->|"Request"| Home
    Client -->|"Request"| Product
    Client -->|"Request"| About
    Client -->|"Request"| Cart
    Client -->|"Request"| Checkout
    Client -->|"Request"| Contact
    Client -->|"Request"| Whishlist
    Client -->|"Login"| Login
    Client -->|"Signup"| SignupPage

    Home -->|"authRequest"| NextAuth
    SignupPage -->|"newUser"| SignupAPI

    NextAuth -->|"DBOps"| DBConnect
    SignupAPI -->|"DBOps"| DBConnect
    EnquiryAPI -->|"DBOps"| DBConnect

    NextAuth ---|"processedBy"| CustomMiddleware
    SignupAPI ---|"processedBy"| CustomMiddleware
    EnquiryAPI ---|"processedBy"| CustomMiddleware

    %% Configuration Influence
    GlobalStyle --- TailwindConfig
    NextAuth --- NextConfig

    %% Class Styles
    classDef frontend fill:#b3d9ff,stroke:#1a75ff,stroke-width:2px;
    classDef backend fill:#ccffcc,stroke:#00b300,stroke-width:2px;
    classDef database fill:#ffe6cc,stroke:#ff9900,stroke-width:2px;
    classDef config fill:#ffd9b3,stroke:#ff6600,stroke-width:2px;
    classDef external fill:#e6e6e6,stroke:#999999,stroke-width:2px;

    %% Click Events
    click Home "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/home/page.js"
    click Product "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/product/page.js"
    click About "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/about/page.js"
    click Cart "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/cart/page.js"
    click Checkout "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/checkout/page.js"
    click Contact "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/contact/page.js"
    click Whishlist "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/whishlist/page.js"
    click Navbar "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/components/Navbar.js"
    click Footer "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/components/Footer.js"
    click ProductCard "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/components/ProductCard.js"
    click GlobalStyle "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/globals.css"
    click NextAuth "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/api/auth/[...nextauth]/route.js"
    click SignupAPI "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/api/auth/signup/route.js"
    click EnquiryAPI "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/api/enquiry/route.js"
    click Login "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/auth/login/page.js"
    click SignupPage "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/auth/signup/page.js"
    click CustomMiddleware "https://github.com/burhanahmad0/exclusive-ecommerce-website/tree/master/app/middlewares"
    click DBConnect "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/db/dbConnect.js"
    click UserModel "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/models/user.js"
    click EnquiryModel "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/app/models/enquiry.js"
    click TailwindConfig "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/tailwind.config.js"
    click NextConfig "https://github.com/burhanahmad0/exclusive-ecommerce-website/blob/master/next.config.mjs"
```
