# saarang2003/clickcart architecture

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

- Interactive diagram: https://gitdiagram.com/saarang2003/clickcart
- Repository: https://github.com/saarang2003/clickcart

## Overview

##### Project type and purpose
- ClickArt is a full-stack MERN (MongoDB, Express.js, React, Node.js) eCommerce application.
- Users browse and purchase art products; admins manage products, orders, users; images uploaded to Cloudinary; payments via PayPal; state managed by Redux.

##### File structure
- Top-level “client” folder: React app (HTML/CSS/JSX, assets, components, pages, Redux store, Vite config).
- Top-level “server” folder: Express.js backend (controllers split by domain, Mongoose models, routes organized by admin/auth/shop, helper modules for Cloudinary & PayPal, DB utils).
- Shared concerns: environment vars for MongoDB, JWT, Cloudinary, PayPal; ESLint, Tailwind, PostCSS; build scripts in package.json.

##### Extract key insights from the README
- Uses Redux slices for admin and shop workflows.
- RESTful API endpoints under `/api/auth`, `/api/shop`, `/api/admin`.
- MVC-style controllers/models separation on the server.
- Third-party integrations: Cloudinary for images, PayPal for payments, JWT/bcrypt for auth.

a. Main components
- Frontend (React + Redux + Axios)
- Backend API (Node.js + Express + controllers + Mongoose models)
- Database (MongoDB)
- External Services: Cloudinary, PayPal
- Authentication (JWT & bcrypt)
- Hosting/Deployment (optional: Heroku, Vercel, etc.)

b. Relationships & interactions
- Frontend → Backend: HTTP(S) requests via Axios to REST endpoints (`/api/products`, `/api/orders`, `/api/auth`, etc.)
- Backend → Database: Mongoose ORM interactions with MongoDB collections (Users, Products, Orders, Cart, Reviews, Addresses)
- Backend → Cloudinary: image upload/download via Cloudinary SDK in `server/helpers/cloudinary.js`
- Backend → PayPal: payment creation/confirmation via `server/helpers/paypal.js`
- Frontend state management: Redux store dispatches actions → reducers (auth-slice, shop slices, admin slices) → selectors → UI components.

c. Architectural patterns & design principles
- Frontend: Component-based architecture, container/presentational separation (pages vs. components), modular Redux slices.
- Backend: MVC pattern—routes delegate to controllers, controllers coordinate business logic and data persistence via models.
- Separation of concerns: authentication middleware, error handling, helpers.
- RESTful API design.

d. Key technologies & libraries
- Frontend: React, Redux Toolkit, React Router, Vite, Tailwind CSS, Axios
- Backend: Node.js, Express.js, Mongoose (MongoDB), bcrypt, jsonwebtoken
- External: Cloudinary SDK, PayPal REST SDK

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        ReactApp["React App"]:::frontend
        subgraph "Pages"
            Pages["Home, Auth, Shop, Admin Views"]:::frontend
        end
        subgraph "Components"
            Components["UI, Auth, Common, Shopping, Admin"]:::frontend
        end
        subgraph "Redux Store"
            Store["Auth, Shop, Admin Slices"]:::frontend
        end
        subgraph "Config & Entry"
            Main["main.jsx"]:::frontend
            ViteCfg["vite.config.js"]:::frontend
            TailwindCfg["tailwind.config.js"]:::frontend
            PostCSS["postcss.config.js"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Server)"
        direction TB
        API["Express API"]:::backend
        subgraph "Routes"
            AuthRoutes["Auth Routes"]:::backend
            ShopRoutes["Shop Routes"]:::backend
            AdminRoutes["Admin Routes"]:::backend
        end
        subgraph "Controllers"
            AuthCtrl["Auth Controller"]:::backend
            ShopCtrls["Shop Controllers"]:::backend
            AdminCtrls["Admin Controllers"]:::backend
        end
        subgraph "Models"
            Models["User, Product, Order, Cart, Review, Address"]:::backend
        end
        DBUtil["DB Util"]:::backend
        subgraph "Helpers"
            CloudHelper["Cloudinary Helper"]:::backend
            PaypalHelper["PayPal Helper"]:::backend
        end
    end

    %% Database & External Services
    DB[(MongoDB)]:::database
    Cloudinary((Cloudinary)):::external
    PayPal((PayPal)):::external

    %% Frontend internal flows
    Pages -->|"dispatch actions"| Store
    Components -->|"dispatch actions"| Store
    Store -->|"reads state"| ReactApp

    %% Frontend to Backend communication
    ReactApp -->|Axios HTTP requests| API
    API -->|JSON responses| ReactApp

    %% Backend routing and control flow
    API -->|routes requests| AuthRoutes
    API -->|routes requests| ShopRoutes
    API -->|routes requests| AdminRoutes
    AuthRoutes -->|invoke| AuthCtrl
    ShopRoutes -->|invoke| ShopCtrls
    AdminRoutes -->|invoke| AdminCtrls

    %% Business logic to Models and Helpers
    AuthCtrl -->|uses| Models
    ShopCtrls -->|uses| Models
    AdminCtrls -->|uses| Models
    AuthCtrl -->|DB connect| DBUtil
    ShopCtrls -->|upload/download| CloudHelper
    AdminCtrls -->|create/confirm| PaypalHelper

    %% Data persistence and external integrations
    Models -->|CRUD operations| DB
    DBUtil -->|connect| DB
    CloudHelper -->|SDK calls| Cloudinary
    PaypalHelper -->|SDK calls| PayPal

    %% Click Events
    click ReactApp "https://github.com/saarang2003/clickcart/tree/main/client/src"
    click Pages "https://github.com/saarang2003/clickcart/tree/main/client/src/pages"
    click Components "https://github.com/saarang2003/clickcart/tree/main/client/src/components"
    click Store "https://github.com/saarang2003/clickcart/tree/main/client/src/store"
    click Main "https://github.com/saarang2003/clickcart/blob/main/client/src/main.jsx"
    click ViteCfg "https://github.com/saarang2003/clickcart/blob/main/client/vite.config.js"
    click TailwindCfg "https://github.com/saarang2003/clickcart/blob/main/client/tailwind.config.js"
    click PostCSS "https://github.com/saarang2003/clickcart/blob/main/client/postcss.config.js"
    click API "https://github.com/saarang2003/clickcart/blob/main/server/server.js"
    click AuthRoutes "https://github.com/saarang2003/clickcart/blob/main/server/routes/auth/auth-routes.js"
    click ShopRoutes "https://github.com/saarang2003/clickcart/tree/main/server/routes/shop/"
    click AdminRoutes "https://github.com/saarang2003/clickcart/tree/main/server/routes/admin/"
    click AuthCtrl "https://github.com/saarang2003/clickcart/blob/main/server/controllers/auth/auth-controller.js"
    click ShopCtrls "https://github.com/saarang2003/clickcart/tree/main/server/controllers/shop/"
    click AdminCtrls "https://github.com/saarang2003/clickcart/tree/main/server/controllers/admin/"
    click Models "https://github.com/saarang2003/clickcart/tree/main/server/models/"
    click DBUtil "https://github.com/saarang2003/clickcart/blob/main/server/utils/db.js"
    click CloudHelper "https://github.com/saarang2003/clickcart/blob/main/server/helpers/cloudinary.js"
    click PaypalHelper "https://github.com/saarang2003/clickcart/blob/main/server/helpers/paypal.js"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#1E88E5,color:#0D47A1
    classDef backend fill:#E8F5E9,stroke:#43A047,color:#1B5E20
    classDef database fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef external fill:#FBE9E7,stroke:#E64A19,color:#BF360C
```
