# rehan-ankalgi-7t2/gada-electronics architecture

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

- Interactive diagram: https://gitdiagram.com/rehan-ankalgi-7t2/gada-electronics
- Repository: https://github.com/rehan-ankalgi-7t2/gada-electronics

## Overview

##### Project type and purpose
- From the file tree and README, this is a full-stack e-commerce application called “Gada Electronics.”
- Frontend: React + Redux Toolkit (API slices) for browsing products, cart, checkout, user profile, admin panels.
- Backend: Node.js/Express REST API with MongoDB (via config/db.js), handling products, users, orders, uploads, payments.

##### File structure
- Top-level separation:
- frontend/ – React client
- backend/ – Express API server
- uploads/ – folder for static upload assets (synced with Cloudinary)
- backend uses MVC:
- models/ – Mongoose schemas for User, Product, Order
- controllers/ – business logic per entity
- routes/ – Express routers for each resource and upload endpoint
- middleware/ – auth, error handling, object-ID checks
- services/ – Cloudinary integration
- utils/ – token generation, PayPal integration, price calculations
- frontend uses Redux Toolkit with RTK Query slices and React Router for client-side routing.

##### README for additional insights
- README shows screenshots and project branding, confirming an e-commerce store with product catalog, user authentication, admin dashboards.

##### Elements
- Labels: “Browser”, “React SPA”, “Express API”, “MongoDB”, “Cloudinary”, “PayPal”, “GitHub Actions”
- Blue rectangles for in-process components (Browser, API)
- Clouds for external services (Cloudinary, PayPal)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)" 
        direction TB
        ReactSPA["React SPA"]:::client
        ReduxStore["Redux Store & RTK Query"]:::client
        ReactRouter["React Router & UI Screens"]:::client
        Components["UI Components"]:::client
        UtilsFE["Frontend Utilities"]:::client
        ReactSPA --> ReduxStore
        ReduxStore --> ReactRouter
        ReactRouter --> Components
        ReactRouter --> UtilsFE
    end

    %% API Server Layer
    subgraph "API Server (Express)" 
        direction TB
        Routes["Routes"]:::server
        Middleware["Auth & Error Middleware"]:::server
        Controllers["Controllers"]:::server
        ServicesUtils["Services & Utils"]:::server
        Models["Mongoose Models"]:::server
        Routes --> Middleware
        Middleware --> Controllers
        Controllers --> ServicesUtils
        ServicesUtils --> Models
    end

    %% Database and External Services
    MongoDB["MongoDB"]:::database
    uploads["Uploads Directory"]:::storage
    Cloudinary["Cloudinary"]:::external
    PayPal["PayPal"]:::external

    %% CI/CD
    GitHubCI["GitHub Actions"]:::cicd

    %% Data Flows
    ReactSPA -->|"HTTPS (REST)"| Routes
    Controllers -->|"CRUD (Mongoose)"| MongoDB
    Controllers -->|"write files"| uploads
    uploads -->|"sync"| Cloudinary
    Controllers -->|"upload API"| Cloudinary
    Controllers -->|"payment API"| PayPal
    GitHubCI --> ReactSPA
    GitHubCI --> Routes

    %% Backend Entry and DB Config
    BackendEntry["Express Entry Point"]:::server
    DBConfig["DB Configuration"]:::server
    BackendEntry --> DBConfig
    DBConfig --> MongoDB
    ReactSPA -.-> BackendEntry

    %% Click Events - Frontend
    click ReactSPA "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/index.js"
    click ReduxStore "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/store.js"
    click ReduxStore "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/slices/apiSlice.js"
    click ReduxStore "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/slices/productsApiSlice.js"
    click ReduxStore "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/slices/orderApiSlice.js"
    click ReduxStore "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/slices/usersApiSlice.js"
    click ReduxStore "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/slices/authSlice.js"
    click ReduxStore "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/slices/cartSlice.js"
    click ReactRouter "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/App.js"
    click ReactRouter "https://github.com/rehan-ankalgi-7t2/gada-electronics/tree/master/frontend/src/screens"
    click Components "https://github.com/rehan-ankalgi-7t2/gada-electronics/tree/master/frontend/src/components"
    click UtilsFE "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/utils/cartUtils.js"
    click UtilsFE "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/frontend/src/utils/globalTheme.js"

    %% Click Events - Backend
    click BackendEntry "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/server.js"
    click DBConfig "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/config/db.js"
    click Models "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/models/userModel.js"
    click Models "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/models/productModel.js"
    click Models "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/models/orderModel.js"
    click Controllers "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/controllers/userController.js"
    click Controllers "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/controllers/productController.js"
    click Controllers "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/controllers/order.controller.js"
    click Routes "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/routes/userRoutes.js"
    click Routes "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/routes/productRoutes.js"
    click Routes "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/routes/order.routes.js"
    click Routes "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/routes/uploadRoutes.js"
    click Middleware "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/middleware/authMiddleware.js"
    click Middleware "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/middleware/errorMiddleware.js"
    click Middleware "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/middleware/asyncHandler.js"
    click Middleware "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/middleware/checkObjectId.js"
    click ServicesUtils "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/services/cloudinary.js"
    click ServicesUtils "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/utils/paypal.js"
    click ServicesUtils "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/utils/generateToken.js"
    click ServicesUtils "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/utils/calcPrices.js"
    click Seeder "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/data/users.js"
    click Seeder "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/data/products.js"
    click Seeder "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/backend/seeder.js"
    click uploads "https://github.com/rehan-ankalgi-7t2/gada-electronics/tree/master/uploads/"

    %% CI/CD Click
    click GitHubCI "https://github.com/rehan-ankalgi-7t2/gada-electronics/blob/master/.github/workflows/deploy.yml"

    %% Styles
    classDef client fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef server fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20;
    classDef database fill:#FFF3E0,stroke:#E65100,color:#E65100;
    classDef external fill:#ECEFF1,stroke:#37474F,color:#37474F;
    classDef cicd fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A;
    classDef storage fill:#FFEBEE,stroke:#B71C1C,color:#B71C1C;
```
