# guni2605/praneiz architecture

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

- Interactive diagram: https://gitdiagram.com/guni2605/praneiz
- Repository: https://github.com/guni2605/praneiz

## Overview

##### Project type and purpose
- This is a monorepo for a full-stack e-commerce application named “PRANEIZ.”
- It contains three distinct front-end React apps (public storefront, admin panel) and a Node.js/Express REST API backend.
- Purpose: allow end-users to browse and purchase clothing items; allow admins to add/update products; handle auth, image hosting, and payments.

##### File structure
- Top level:
- admin/ → React-Vite admin panel
- frontend/ → React-Vite public storefront
- backend/ → Express REST API (controllers, models, routes, config)
- Key patterns:
- “src/Components” & “src/Pages” in both frontends → component-based UI (React)
- “store/ContextStore.jsx” → React Context for state management
- backend/config → external integrations (MongoDB, Cloudinary, Razorpay, Passport auth)
- backend/controllers + routes → MVC-style separation
- middlewares for auth, file uploads
- Deployment config: Vercel for both frontends, Render (or similar) for backend

##### README for additional insights
- Tech Stack: React, Node.js/Express, MongoDB (Mongoose), JWT, Cloudinary, Tailwind CSS
- Features: user auth, product catalog, image upload, admin CRUD, payment processing
- Environment variables: endpoints and secrets for JWT, DB, Cloudinary, payment gateway
- API surface: /api/auth, /api/users, /api/products, /api/upload, /api/orders

a. Main components
- Public Storefront (React app)
- Admin Panel (React app)
- REST API Server (Node.js/Express)
- MongoDB Database (Atlas)
- Cloudinary Media Storage
- External Payment Gateway (Razorpay)
- Authentication layer (JWT + Passport)
b. Relationships & interactions
- Both frontends ↔ REST API: HTTP(S) calls carrying JWT in headers
- REST API ↔ MongoDB: data persistence for Users, Items, Orders
- REST API ↔ Cloudinary: image upload/download via Cloudinary SDK
- REST API ↔ Razorpay: create and verify payment orders
- User’s browser ↔ Razorpay widget (for checkout flow)
c. Architectural patterns & design principles
- Componentized frontends with Context API (state + auth)
- MVC-style separation in backend (routes → controllers → models)
- Middleware chain for authentication and authorization
- Separation of concerns: UI, API, persistence, third-party services
d. Key technologies/libraries
- React + Vite, Context API, Tailwind CSS
- Node.js, Express.js, Mongoose, Passport.js, Multer
- Cloudinary SDK, Razorpay Node SDK, JSON Web Tokens (JWT)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Public Storefront"
        direction TB
        PF_App["React App"]:::frontend
        PF_Context["ContextStore.jsx"]:::frontend
        PF_Components["Components/"]:::frontend
        PF_Pages["Pages/"]:::frontend
    end

    subgraph "Admin Panel"
        direction TB
        AP_App["React App"]:::frontend
        AP_Context["ContextStore.jsx"]:::frontend
        AP_Components["Components/"]:::frontend
        AP_Pages["Pages/"]:::frontend
    end

    %% API Layer
    subgraph "REST API Server"
        direction TB
        API_Entry["server.js"]:::api

        subgraph "Routes"
            direction TB
            Auth_Routes["authRoutes.js"]:::api
            User_Routes["userRoutes.js"]:::api
            Item_Routes["ItemRoute.js"]:::api
            Admin_Routes["AdminRoute.js"]:::api
        end

        subgraph "Controllers"
            direction TB
            Auth_Controller["authController.js"]:::api
            User_Controller["userController.js"]:::api
            Item_Controller["item.controller.js"]:::api
            Admin_Controller["admin.controller.js"]:::api
        end

        subgraph "Models"
            direction TB
            User_Model["User.js"]:::db
            Item_Model["itemModel.js"]:::db
            Order_Model["orderModel.js"]:::db
        end

        subgraph "Config"
            direction TB
            DB_Config["db.js"]:::api
            Cloudinary_Config["cloudinary.js"]:::api
            Razorpay_Config["razorpay.js"]:::api
            Passport_Config["passport.js"]:::api
        end

        subgraph "Middlewares"
            direction TB
            Auth_MW["userAuth.js"]:::api
            Admin_MW["verifyAdmin.js"]:::api
            Upload_MW["multer.js"]:::api
        end
    end

    %% External Services
    DB["MongoDB Atlas"]:::db
    Cloudinary["Cloudinary"]:::ext
    Razorpay["Razorpay"]:::ext

    %% Connections
    PF_App -->|HTTP JWT| API_Entry
    AP_App -->|HTTP JWT| API_Entry

    API_Entry --> Auth_Routes
    API_Entry --> User_Routes
    API_Entry --> Item_Routes
    API_Entry --> Admin_Routes

    Auth_Routes --> Auth_Controller
    User_Routes --> User_Controller
    Item_Routes --> Item_Controller
    Admin_Routes --> Admin_Controller

    Auth_Controller --> User_Model
    User_Controller --> User_Model
    Item_Controller --> Item_Model
    Item_Controller --> Order_Model
    Admin_Controller --> Item_Model

    API_Entry --> DB_Config
    DB_Config --> DB

    API_Entry --> Cloudinary_Config
    Cloudinary_Config --> Cloudinary

    API_Entry --> Razorpay_Config
    Razorpay_Config <--> Razorpay

    PF_App -->|Checkout Flow| Razorpay

    API_Entry --> Passport_Config
    API_Entry --> Auth_MW
    Admin_Routes --> Admin_MW
    Item_Routes --> Upload_MW

    %% Click Events
    click PF_App "https://github.com/guni2605/praneiz/tree/master/frontend/"
    click PF_Context "https://github.com/guni2605/praneiz/blob/master/frontend/src/store/ContextStore.jsx"
    click PF_Components "https://github.com/guni2605/praneiz/tree/master/frontend/src/Components/"
    click PF_Pages "https://github.com/guni2605/praneiz/tree/master/frontend/src/pages/"
    click AP_App "https://github.com/guni2605/praneiz/tree/master/admin/"
    click AP_Context "https://github.com/guni2605/praneiz/blob/master/admin/src/store/ContextStore.jsx"
    click AP_Components "https://github.com/guni2605/praneiz/tree/master/admin/src/Components/"
    click AP_Pages "https://github.com/guni2605/praneiz/tree/master/admin/src/Pages/"
    click API_Entry "https://github.com/guni2605/praneiz/blob/master/backend/server.js"
    click Auth_Controller "https://github.com/guni2605/praneiz/blob/master/backend/controllers/authController.js"
    click User_Controller "https://github.com/guni2605/praneiz/blob/master/backend/controllers/userController.js"
    click Item_Controller "https://github.com/guni2605/praneiz/blob/master/backend/controllers/item.controller.js"
    click Admin_Controller "https://github.com/guni2605/praneiz/blob/master/backend/controllers/admin.controller.js"
    click Auth_Routes "https://github.com/guni2605/praneiz/blob/master/backend/routes/authRoutes.js"
    click User_Routes "https://github.com/guni2605/praneiz/blob/master/backend/routes/userRoutes.js"
    click Item_Routes "https://github.com/guni2605/praneiz/blob/master/backend/routes/ItemRoute.js"
    click Admin_Routes "https://github.com/guni2605/praneiz/blob/master/backend/routes/AdminRoute.js"
    click User_Model "https://github.com/guni2605/praneiz/blob/master/backend/models/User.js"
    click Item_Model "https://github.com/guni2605/praneiz/blob/master/backend/models/itemModel.js"
    click Order_Model "https://github.com/guni2605/praneiz/blob/master/backend/models/orderModel.js"
    click DB_Config "https://github.com/guni2605/praneiz/blob/master/backend/config/db.js"
    click Cloudinary_Config "https://github.com/guni2605/praneiz/blob/master/backend/config/cloudinary.js"
    click Razorpay_Config "https://github.com/guni2605/praneiz/blob/master/backend/config/razorpay.js"
    click Passport_Config "https://github.com/guni2605/praneiz/blob/master/backend/config/passport.js"
    click Auth_MW "https://github.com/guni2605/praneiz/blob/master/backend/middlewares/userAuth.js"
    click Admin_MW "https://github.com/guni2605/praneiz/blob/master/backend/middlewares/verifyAdmin.js"
    click Upload_MW "https://github.com/guni2605/praneiz/blob/master/backend/middlewares/multer.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef api fill:#D1FFD6,stroke:#2E8B57,color:#2E8B57
    classDef db fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00
    classDef ext fill:#E6D3FF,stroke:#800080,color:#800080
```
