# manu2954/buildora architecture

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

- Interactive diagram: https://gitdiagram.com/manu2954/buildora
- Repository: https://github.com/manu2954/buildora

## Overview

##### Project type and purpose
- Buildora is a full-stack MERN application: a multi-vendor e-commerce platform for construction and building materials, composed of two user-facing apps (Admin Panel and Customer Storefront) and a Node/Express backend with MongoDB.

##### File structure
- Top-level separation:
- backend/ – Express server implementing RESTful API, routes → controllers → services → models (Mongoose), middleware, and utils.
- frontend/ – React single-page application, using Hooks, Context API, Tailwind CSS, and services modules to call backend endpoints.
- Patterns & layers in backend:
- auth (JWT issued/verified in auth.service, auth.middleware)
- MVC style (routes → controllers → services → models)
- Admin vs. storefront routes logically separated (controllers/admin/ vs controllers/*)
- Utilities for email, token gen, error handling
- Frontend organization:
- components/ (common UI, admin UI)
- context/ (AuthContext, AdminAuthContext, CartContext, SiteContext)
- pages/ (Customer pages vs pages/admin)
- services/ (API wrappers for each domain)

##### Key README insights
- Two applications: Customer Interface + Admin Panel
- Tech stack: React.js, Node/Express, MongoDB/Mongoose, JWT authentication, Tailwind CSS
- Future extensions: dealer portal, payment gateway, bulk upload, notifications

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (React)" 
        direction TB
        FE_ENTRY["index.js / App.jsx"]:::frontend
        subgraph "Customer Storefront" 
            direction TB
            CSP_PAGES["pages/ (Home, Product, Cart, Checkout)"]:::frontend
            CSP_COMPONENTS["components/ (CustomerLayout, ProductCard, Navbar)"]:::frontend
        end
        subgraph "Admin Panel"
            direction TB
            AP_PAGES["pages/admin/ (Dashboard, Login, AdManagement)"]:::frontend
            AP_COMPONENTS["components/admin/ (AdminLayout, AdminNavbar, AdminSidebar)"]:::frontend
        end
        subgraph "Context Providers"
            direction TB
            CT_AUTH["AuthContext.jsx"]:::frontend
            CT_ADMIN_AUTH["AdminAuthContext.jsx"]:::frontend
            CT_CART["CartContext.jsx"]:::frontend
            CT_SITE["SiteContext.jsx"]:::frontend
        end
        subgraph "API Services"
            direction TB
            API_MODULE["api.js"]:::frontend
            AUTH_SVC["authService.js"]:::frontend
            STORE_SVC["storefrontService.js"]:::frontend
            ADMIN_AUTH_SVC["adminAuthService.js"]:::frontend
            ADMIN_AD_SVC["adminAdService.js"]:::frontend
        end
        FE_ENTRY -->|boots| CSP_PAGES
        FE_ENTRY -->|boots| AP_PAGES
        FE_ENTRY --> CT_AUTH
        FE_ENTRY --> CT_ADMIN_AUTH
        FE_ENTRY --> CT_CART
        FE_ENTRY --> CT_SITE
        CSP_PAGES --> CSP_COMPONENTS
        AP_PAGES --> AP_COMPONENTS
        CSP_COMPONENTS --> API_MODULE
        AP_COMPONENTS --> API_MODULE
        CT_AUTH --> AUTH_SVC
        CT_ADMIN_AUTH --> ADMIN_AUTH_SVC
        CT_CART --> STORE_SVC
        API_MODULE --> AUTH_SVC
        API_MODULE --> STORE_SVC
        API_MODULE --> ADMIN_AUTH_SVC
        API_MODULE --> ADMIN_AD_SVC
    end

    %% Proxy Layer
    proxy["Proxy (webpack dev proxy)"]:::api
    API_MODULE -->|HTTP requests| proxy

    %% Backend Layer
    subgraph "Backend (Express)" 
        direction TB
        SERVER["server.js / proxy-server.js"]:::api
        CONFIG_DB["config/db.js"]:::api
        subgraph "Auth Module"
            direction TB
            AUTH_ROUTES["auth.routes.js"]:::api
            AUTH_CTRL["auth.controller.js"]:::api
            AUTH_SVC_BK["auth.service.js"]:::api
            AUTH_MW["auth.middleware.js"]:::middleware
        end
        subgraph "Admin Controllers & Routes"
            direction TB
            ADMIN_ROUTES["routes/*.js (AdminRoutes, advertisementRoutes, bulkUploadRoutes, ...)"]:::api
            ADMIN_CTRLS["controllers/admin/*.js"]:::api
        end
        subgraph "Storefront Controllers & Routes"
            direction TB
            SF_ROUTES["routes/*.js (storefrontRoutes, orderRoutes, paymentRoutes, ...)"]:::api
            SF_CTRLS["controllers/*.js (storefrontController, ordersController, ...)"]:::api
        end
        subgraph "Business Services & Models"
            direction TB
            SVC_LAYER["services/*.js"]:::api
            MODELS["models/*.js"]:::data
        end
        subgraph "Middleware & Utils"
            direction TB
            MIDDLEWARE["middleware/*.js"]:::middleware
            UTILS["utils/*.js"]:::api
        end
        subgraph "Static Assets"
            direction TB
            STATIC_IMG["public/images"]:::data
            STATIC_VID["public/videos"]:::data
        end
        SERVER --> CONFIG_DB
        SERVER --> AUTH_ROUTES
        SERVER --> ADMIN_ROUTES
        SERVER --> SF_ROUTES
        AUTH_ROUTES --> AUTH_CTRL
        AUTH_CTRL --> AUTH_SVC_BK
        AUTH_SVC_BK --> CONFIG_DB
        AUTH_CTRL --> AUTH_MW
        ADMIN_ROUTES --> ADMIN_CTRLS
        SF_ROUTES --> SF_CTRLS
        ADMIN_CTRLS --> SVC_LAYER
        SF_CTRLS --> SVC_LAYER
        SVC_LAYER --> MODELS
        MODELS --> CONFIG_DB
        SF_CTRLS --> MIDDLEWARE
        ADMIN_CTRLS --> MIDDLEWARE
        SVC_LAYER --> UTILS
        SERVER --> STATIC_IMG
        SERVER --> STATIC_VID
    end

    %% Data Layer
    subgraph "Data & Storage"
        direction TB
        MONGO["MongoDB (Mongoose)"]:::data
    end
    CONFIG_DB --> MONGO
    MODELS --> MONGO

    %% External Services
    subgraph "External Services"
        direction TB
        EMAIL["Email Service"]:::external
        PAYMENT["Payment Gateway (planned)"]:::external
    end
    UTILS --> EMAIL
    SVC_LAYER --> PAYMENT

    %% Flows
    proxy -->|routes| SERVER
    CSP_PAGES -->|API calls| proxy
    AP_PAGES -->|API calls| proxy

    %% Click Events
    click CSP_PAGES "https://github.com/manu2954/buildora/tree/master/frontend/src/pages"
    click CSP_COMPONENTS "https://github.com/manu2954/buildora/tree/master/frontend/src/components"
    click AP_PAGES "https://github.com/manu2954/buildora/tree/master/frontend/src/pages/admin"
    click AP_COMPONENTS "https://github.com/manu2954/buildora/tree/master/frontend/src/components/admin"
    click CT_AUTH "https://github.com/manu2954/buildora/blob/master/frontend/src/context/AuthContext.jsx"
    click CT_ADMIN_AUTH "https://github.com/manu2954/buildora/blob/master/frontend/src/context/AdminAuthContext.jsx"
    click CT_CART "https://github.com/manu2954/buildora/blob/master/frontend/src/context/CartContext.jsx"
    click CT_SITE "https://github.com/manu2954/buildora/blob/master/frontend/src/context/SiteContext.jsx"
    click API_MODULE "https://github.com/manu2954/buildora/blob/master/frontend/src/services/api.js"
    click AUTH_SVC "https://github.com/manu2954/buildora/blob/master/frontend/src/services/authService.js"
    click STORE_SVC "https://github.com/manu2954/buildora/blob/master/frontend/src/services/storefrontService.js"
    click ADMIN_AUTH_SVC "https://github.com/manu2954/buildora/blob/master/frontend/src/services/adminAuthService.js"
    click ADMIN_AD_SVC "https://github.com/manu2954/buildora/blob/master/frontend/src/services/adminAdService.js"
    click FE_ENTRY "https://github.com/manu2954/buildora/blob/master/frontend/src/index.js"
    click SERVER "https://github.com/manu2954/buildora/blob/master/backend/server.js"
    click CONFIG_DB "https://github.com/manu2954/buildora/blob/master/backend/config/db.js"
    click AUTH_SVC_BK "https://github.com/manu2954/buildora/blob/master/backend/auth/auth.service.js"
    click AUTH_CTRL "https://github.com/manu2954/buildora/blob/master/backend/auth/auth.controller.js"
    click AUTH_MW "https://github.com/manu2954/buildora/blob/master/backend/auth/auth.middleware.js"
    click AUTH_ROUTES "https://github.com/manu2954/buildora/blob/master/backend/auth/auth.routes.js"
    click ADMIN_CTRLS "https://github.com/manu2954/buildora/tree/master/backend/controllers/admin"
    click ADMIN_ROUTES "https://github.com/manu2954/buildora/tree/master/backend/routes"
    click SF_CTRLS "https://github.com/manu2954/buildora/tree/master/backend/controllers"
    click SF_ROUTES "https://github.com/manu2954/buildora/tree/master/backend/routes"
    click MODELS "https://github.com/manu2954/buildora/tree/master/backend/models"
    click MIDDLEWARE "https://github.com/manu2954/buildora/tree/master/backend/middleware"
    click UTILS "https://github.com/manu2954/buildora/tree/master/backend/utils"
    click STATIC_IMG "https://github.com/manu2954/buildora/tree/master/backend/public/images"
    click STATIC_VID "https://github.com/manu2954/buildora/tree/master/backend/public/videos"

    %% Styles
    classDef frontend fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef api fill:#98FB98,stroke:#333,stroke-width:1px
    classDef data fill:#FFD700,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef middleware fill:#EEEEEE,stroke:#333,stroke-width:1px
```
