# sumilsuthar197/shoekart architecture

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

- Interactive diagram: https://gitdiagram.com/sumilsuthar197/shoekart
- Repository: https://github.com/sumilsuthar197/shoekart

## Overview

##### Main Components

A. Frontend (Client Layer):
- React.js Application Structure
- Components (UI elements)
- Pages (Route-based views)
- Context (Auth state management)
- Hooks (Custom functionality)
- Utils (Route protection)
- Styles (CSS modules)

B. Backend (Server Layer):
- Express.js Server
- Routes (API endpoints)
- Controllers (Business logic)
- Models (Data schemas)
- Middleware (Auth, Error handling)
- Utils (Email service, Error handling)

C. External Services:
- MongoDB Database
- Stripe Payment Gateway
- Email Service
- RemoveBG API

**[Client Tier] <-> [Server Tier] <-> [Data Tier]**

##### Specific Component Details

Frontend Components (Top Layer):
**[Public Pages] -- [Protected Pages] -- [Admin Pages]**
- ↓               ↓                    ↓
**[Auth Context] -- [Components] -- [API Integration]**

Backend Services (Middle Layer):
**[Routes] → [Controllers] → [Models]**
- ↑            ↑
**[Auth Middleware] [Error Handlers]**

External Services (Bottom Layer):
**[MongoDB] [Stripe] [Email Service] [RemoveBG]**

##### Important Flows to Highlight

A. Authentication Flow:
**User → Login/Signup → JWT → Protected Routes**

B. Purchase Flow:
**Product Selection → Cart → Stripe Payment → Order Confirmation**

C. Admin Flow:
**Admin Login → Dashboard → Product/Order Management**

##### Key Integration Points to Emphasize

- JWT Authentication between client and server
- Stripe payment processing
- Email notification system
- Image processing with RemoveBG
- Database interactions

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE_Pages["Pages"]:::frontend
        FE_Comp["Components"]:::frontend
        FE_Context["Auth Context"]:::auth
        FE_Hooks["Custom Hooks"]:::frontend
        FE_Utils["Route Protection"]:::auth
        FE_Styles["Styles"]:::frontend
        API_Int["API Integration"]:::frontend

        FE_Pages --> FE_Context
        FE_Pages --> FE_Comp
        FE_Comp --> API_Int
        FE_Context --> API_Int
        FE_Hooks --> API_Int
        FE_Utils --> FE_Context
    end

    subgraph Server
        BE_Routes["Routes"]:::backend
        BE_Controllers["Controllers"]:::backend
        BE_Models["Models"]:::backend
        BE_Auth["Auth Middleware"]:::auth
        BE_Error["Error Handling"]:::backend
        BE_Email["Email Service"]:::service
        BE_DB_Conn["DB Connection"]:::backend
        
        BE_Routes --> BE_Controllers
        BE_Controllers --> BE_Models
        BE_Auth --> BE_Routes
        BE_Error --> BE_Routes
        BE_Controllers --> BE_Email
        BE_Models --> BE_DB_Conn
    end

    subgraph External
        MongoDB[(MongoDB)]:::database
        Stripe["Stripe Payment"]:::service
        EmailSvc["Email Service"]:::service
        RemoveBG["RemoveBG API"]:::service
    end

    API_Int --> BE_Routes
    BE_DB_Conn --> MongoDB
    BE_Controllers --> Stripe
    BE_Email --> EmailSvc
    BE_Controllers --> RemoveBG

    %% Component Mappings
    click FE_Comp "https://github.com/SumilSuthar197/Shoekart/tree/main/client/src/components/"
    click FE_Pages "https://github.com/SumilSuthar197/Shoekart/tree/main/client/src/pages/"
    click FE_Context "https://github.com/SumilSuthar197/Shoekart/blob/main/client/context/AuthProvider.jsx"
    click FE_Hooks "https://github.com/SumilSuthar197/Shoekart/tree/main/client/hooks/"
    click FE_Utils "https://github.com/SumilSuthar197/Shoekart/blob/main/client/src/utils/protectedRoute.jsx"
    click FE_Styles "https://github.com/SumilSuthar197/Shoekart/tree/main/client/src/styles/"
    click API_Int "https://github.com/SumilSuthar197/Shoekart/blob/main/client/src/Axios.js"
    click BE_Routes "https://github.com/SumilSuthar197/Shoekart/tree/main/server/routes/"
    click BE_Controllers "https://github.com/SumilSuthar197/Shoekart/tree/main/server/controllers/"
    click BE_Models "https://github.com/SumilSuthar197/Shoekart/tree/main/server/models/"
    click BE_Auth "https://github.com/SumilSuthar197/Shoekart/blob/main/server/middleware/auth.js"
    click BE_Error "https://github.com/SumilSuthar197/Shoekart/blob/main/server/middleware/error.js"
    click BE_Email "https://github.com/SumilSuthar197/Shoekart/blob/main/server/utils/sendEmail.js"
    click BE_DB_Conn "https://github.com/SumilSuthar197/Shoekart/blob/main/server/db/connect.js"

    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef auth fill:#F44336,stroke:#C62828,color:white
    classDef service fill:#FFC107,stroke:#FFA000,color:black
    classDef database fill:#607D8B,stroke:#455A64,color:white

    %% Legend
    subgraph Legend
        L_FE["Frontend"]:::frontend
        L_BE["Backend"]:::backend
        L_Auth["Security"]:::auth
        L_Svc["Services"]:::service
        L_DB["Database"]:::database
    end
```
