# sumit-nagrikar/shop-unlimited architecture

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

- Interactive diagram: https://gitdiagram.com/sumit-nagrikar/shop-unlimited
- Repository: https://github.com/sumit-nagrikar/shop-unlimited

## Overview

##### Main Components
- Client Frontend: Located in the “client” folder, built with React (using Vite), Tailwind CSS, and various React components/pages (Home, Product, Cart, etc.). This handles the shopper’s experience.
- Admin Frontend: Found in the “admin” folder; it is similarly structured with React and Tailwind CSS but targets administrative tasks such as managing products, orders, or other backend data.
- Server/Backend: In the “server” directory, an Express-based Node.js application. It includes configuration files (for MongoDB and Cloudinary), controllers (managing products, orders, cart, users), middleware (for authentication, file uploads), models (representing products, users, orders), and route definitions.
- Database: Although not a dedicated folder, the README clearly states that MongoDB is used to store products, orders, and user information.
- External Services: Integration with a payment service (Razorpay API) and media handling (Cloudinary), both important for completing transactions and managing assets.

##### Relationships and Data Flow
- The Client Frontend communicates with the Server via RESTful API calls (e.g., for user authentication, product queries, cart management, and order placement).
- The Admin Frontend also interfaces with the Server to perform back-office operations like managing product listings or viewing order details.
- The Server handles incoming HTTP requests, processes them via its controllers and middleware, interacts with the MongoDB database for data persistence, and communicates with external services like Razorpay for payments and Cloudinary for media storage.

##### Architectural Patterns and Key Tech
- Separation of Concerns: Different directories clearly delineate the client-facing UI, admin panel, and backend server.
- RESTful API Design: Server routes and controllers indicate a well-structured API layer.
- MVC-like Structure in Backend: Although it’s not an MVC framework strictly, you have clear divisions between models, controllers, and routes.
- React Componentization: Both client and admin folders employ component-based design ensuring reusability and modularity in the UI.
- Use of modern tools like Vite, Tailwind CSS, and ESLint for ensuring high-performance and maintainability.

##### Summary of What
- Main Components: Client Frontend, Admin Frontend, Server (with subcomponents like Controllers, Routes, Models, Middleware), MongoDB Database, and External APIs (Razorpay, Cloudinary).
- Labels and Descriptions: Each component and connection should have a name or a short note (e.g., “User Authentication Flow”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Components
    subgraph "Frontends"
        CF["Client Frontend (React/Vite)"]:::frontend
        AF["Admin Frontend (React/Tailwind)"]:::frontend
    end

    %% Backend Server Components
    subgraph "Backend Server (Express)"
        ES["Express Server"]:::backend
        R["Routes (API Endpoints)"]:::backend
        C["Controllers"]:::backend
        M["Middleware"]:::backend
        MD["Models"]:::backend
        subgraph "Configurations"
            MC["MongoDB Config"]:::backend
            CC["Cloudinary Config"]:::backend
        end
    end

    %% Database and External Services
    DB["MongoDB"]:::database
    RP["Razorpay API"]:::external
    CSL["Cloudinary Service"]:::external

    %% Data Flows between Frontend and Backend
    CF -->|"APIRequest"| ES
    AF -->|"AdminAPICall"| ES

    %% Internal Backend Component Flows
    ES -->|"Routes"| R
    R -->|"ProcessRequest"| C
    C -->|"DataOps"| MD
    C -->|"MiddlewareCheck"| M
    C -->|"ConfigAccess"| MC
    C -->|"MediaOps"| CC

    %% External Interactions from Controllers
    C -->|"DBQuery"| DB
    C -->|"Payment"| RP
    C -->|"MediaUpload"| CSL

    %% Click Events
    click CF "https://github.com/sumit-nagrikar/shop-unlimited/tree/main/client/"
    click AF "https://github.com/sumit-nagrikar/shop-unlimited/tree/main/admin/"
    click ES "https://github.com/sumit-nagrikar/shop-unlimited/tree/main/server/"
    click R "https://github.com/sumit-nagrikar/shop-unlimited/tree/main/server/routes/"
    click C "https://github.com/sumit-nagrikar/shop-unlimited/tree/main/server/controllers/"
    click M "https://github.com/sumit-nagrikar/shop-unlimited/tree/main/server/middleware/"
    click MD "https://github.com/sumit-nagrikar/shop-unlimited/tree/main/server/models/"
    click MC "https://github.com/sumit-nagrikar/shop-unlimited/blob/main/server/config/mongodb.js"
    click CC "https://github.com/sumit-nagrikar/shop-unlimited/blob/main/server/config/cloudinary.js"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#D4EFDF,stroke:#117864,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
```
