# kavita392/forever-full-stack architecture

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

- Interactive diagram: https://gitdiagram.com/kavita392/forever-full-stack
- Repository: https://github.com/kavita392/forever-full-stack

## Overview

##### Project type and purpose
- This is a full-stack e-commerce web application composed of:
- A public storefront (“frontend”) built with React, Vite, Tailwind CSS
- An admin dashboard (“admin”) built with React, Vite, Tailwind CSS
- A backend REST API (“backend”) using Node.js, Express, MongoDB, Cloudinary
- The public frontend serves shoppers; the admin handles product/order management; the backend exposes APIs for both.

##### File structure
- Top-level dirs:
- frontend: React app (src/components, src/pages, context, assets)
- admin: React app (src/components, src/pages, assets)
- backend: Express server (controllers, models, routes, middleware, config)
- Config files: .env in each, Vite/Vercel configs, ESLint, tailwind.config.js.
- Packages: both frontend/admin use Vite; backend uses Express, Mongoose, multer, Cloudinary SDK.

##### README (links only)
- Confirms three deployed apps: frontend UI, backend API, admin UI.

Layer 1: Clients
- Public Storefront (React/Vite)
- Admin Dashboard (React/Vite)
Layer 2: API Layer
- Express Server
– Routes (userRoute, productRoute, orderRoute, cartRoute)
– Controllers (userController, productController, orderController, cartController)
– Middleware
Layer 3: Data & Services
- MongoDB (Users, Products, Orders, Carts)
- Cloudinary (Image storage)

Conclude by instructing:
- Major flows (e.g., “POST /api/products → multer → Cloudinary”)
- Keep it readable: group related elements, maintain consistent styling.
This will yield a clear, accurate architectural overview tailored to your e-commerce project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layer 1: Clients
    subgraph "Layer 1: Clients"
        subgraph "Public Storefront"
            PublicRoot["Public Storefront"]:::frontend
            fs_components["Components"]:::frontend
            fs_pages["Pages"]:::frontend
            fs_context["ShopContext"]:::frontend
            fs_env_fe[".env"]:::config
        end
        subgraph "Admin Dashboard"
            AdminRoot["Admin Dashboard"]:::admin
            ad_components["Components"]:::admin
            ad_pages["Pages"]:::admin
            ad_env_ad[".env"]:::config
        end
    end

    %% Layer 2: API Server
    subgraph "Layer 2: API Server"
        entry["server.js"]:::backend

        subgraph "Routes"
            ur["userRoute.js"]:::backend
            pr["productRoute.js"]:::backend
            orr["orderRoute.js"]:::backend
            cr["cartRoute.js"]:::backend
        end

        subgraph "Controllers"
            uc["userController.js"]:::backend
            pc["productController.js"]:::backend
            oc["orderController.js"]:::backend
            cc["cartController.js"]:::backend
        end

        subgraph "Middleware"
            auth["auth.js"]:::backend
            adminAuth["adminAuth.js"]:::backend
            multer["multer.js"]:::backend
        end

        subgraph "Config"
            dbconn["mongodb.js"]:::backend
            cloudconfig["cloudinary.js"]:::backend
            backend_env[".env"]:::config
        end

        subgraph "Models"
            um["userModel.js"]:::backend
            pm["productModel.js"]:::backend
            orm["orderModel.js"]:::backend
        end
    end

    %% Layer 3: Data & Services
    mongo["MongoDB Atlas"]:::database
    cloudinary["Cloudinary"]:::cloud

    %% Connections: Clients to API
    PublicRoot -->|"HTTP(S) Requests"| entry
    AdminRoot -->|"HTTP(S) Requests"| entry

    %% API Server Internal Flow
    entry --> routes
    routes --> ur & pr & orr & cr
    ur --> uc
    pr --> pc
    orr --> oc
    cr --> cc

    %% Controllers to Models and Services
    uc --> um
    pc --> pm
    oc --> orm
    cc --> orm

    pc -->|"upload images"| multer
    multer --> cloudinary
    cloudinary --> pc

    uc & pc & oc & cc --> mongo

    %% Click Events
    click PublicRoot "https://github.com/kavita392/forever-full-stack/tree/main/frontend/"
    click fs_components "https://github.com/kavita392/forever-full-stack/tree/main/frontend/src/components/"
    click fs_pages "https://github.com/kavita392/forever-full-stack/tree/main/frontend/src/pages/"
    click fs_context "https://github.com/kavita392/forever-full-stack/blob/main/frontend/src/context/ShopContext.jsx"
    click fs_env_fe "https://github.com/kavita392/forever-full-stack/blob/main/frontend/.env"

    click AdminRoot "https://github.com/kavita392/forever-full-stack/tree/main/admin/"
    click ad_components "https://github.com/kavita392/forever-full-stack/tree/main/admin/src/components/"
    click ad_pages "https://github.com/kavita392/forever-full-stack/tree/main/admin/src/pages/"
    click ad_env_ad "https://github.com/kavita392/forever-full-stack/blob/main/admin/.env"

    click entry "https://github.com/kavita392/forever-full-stack/blob/main/backend/server.js"
    click ur "https://github.com/kavita392/forever-full-stack/blob/main/backend/routes/userRoute.js"
    click pr "https://github.com/kavita392/forever-full-stack/blob/main/backend/routes/productRoute.js"
    click orr "https://github.com/kavita392/forever-full-stack/blob/main/backend/routes/orderRoute.js"
    click cr "https://github.com/kavita392/forever-full-stack/blob/main/backend/routes/cartRoute.js"

    click uc "https://github.com/kavita392/forever-full-stack/blob/main/backend/controllers/userController.js"
    click pc "https://github.com/kavita392/forever-full-stack/blob/main/backend/controllers/productController.js"
    click oc "https://github.com/kavita392/forever-full-stack/blob/main/backend/controllers/orderController.js"
    click cc "https://github.com/kavita392/forever-full-stack/blob/main/backend/controllers/cartController.js"

    click um "https://github.com/kavita392/forever-full-stack/blob/main/backend/models/userModel.js"
    click pm "https://github.com/kavita392/forever-full-stack/blob/main/backend/models/productModel.js"
    click orm "https://github.com/kavita392/forever-full-stack/blob/main/backend/models/orderModel.js"

    click auth "https://github.com/kavita392/forever-full-stack/blob/main/backend/middleware/auth.js"
    click adminAuth "https://github.com/kavita392/forever-full-stack/blob/main/backend/middleware/adminAuth.js"
    click multer "https://github.com/kavita392/forever-full-stack/blob/main/backend/middleware/multer.js"

    click dbconn "https://github.com/kavita392/forever-full-stack/blob/main/backend/config/mongodb.js"
    click cloudconfig "https://github.com/kavita392/forever-full-stack/blob/main/backend/config/cloudinary.js"
    click backend_env "https://github.com/kavita392/forever-full-stack/blob/main/backend/.env"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#0288d1,color:#000
    classDef admin fill:#fff3e0,stroke:#fb8c00,color:#000
    classDef backend fill:#e8f5e9,stroke:#43a047,color:#000
    classDef database fill:#eceff1,stroke:#455a64,color:#000
    classDef cloud fill:#e3f2fd,stroke:#42a5f5,color:#000
    classDef config fill:#f3e5f5,stroke:#8e24aa,color:#000
```
