# disha2553/campus-connect architecture

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

- Interactive diagram: https://gitdiagram.com/disha2553/campus-connect
- Repository: https://github.com/disha2553/campus-connect

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“Campus Connect”) for a peer-to-peer second-hand marketplace.
- Frontend: React + Redux + Tailwind CSS + Ant Design.
- Backend: Node.js + Express.js + MongoDB + Cloudinary (for image uploads).
- Key features: User auth (JWT), product listings, bidding, notifications, admin panel.

##### File Structure
- Top level:
- client/ → React SPA
- server/ → Express API
- nodemon.json, package.json → build & run scripts
- client/src/apicalls → Axios instances & wrappers
- client/src/redux → Redux store & slices (state management)
- server/config → DB & Cloudinary setup
- server/middlewares → JWT auth
- server/models → Mongoose schemas
- server/routes → REST endpoints

##### README for Additional Insights
- Confirms MERN stack, deployment on Render, use of JWT, Cloudinary, Multer.
- Highlights core modules: Authentication, Products, Bidding, Notifications, Admin.

##### Main Components & Their Interactions
a. Frontend (Browser/Client)
- React app
- Redux store
- Components & Pages (Home, Login, Register, ProductInfo, Admin, Profile)
- Axios → HTTP calls to API
b. Backend (Server/API)
- Express.js server (server/server.js)
- Middleware: authMiddleware (JWT verification)
- Routes & Controllers: usersRoute, productsRoute, bidsRoute, notificationsRoute
- Models: userModel, productModel, bidModel, notificationsModel
c. Database
- MongoDB (hosted locally or in cloud)
d. External Services
- Cloudinary for image storage
- (Optional) Email or push notification service
e. Deployment Platform
- Render (hosting both client static build and server)

##### Relationships & Data Flows
- User → Browser → React UI
- React components dispatch Redux actions → update store
- UI → Axios HTTP request → Express API
- Express route → authMiddleware → controller logic → Mongoose Model → MongoDB
- For file uploads: Express → Multer middleware → Cloudinary SDK → Cloudinary
- Response flows back to client → Redux store update → UI render

##### Architectural Patterns & Design Principles
- Separation of concerns: UI, state management, API, data layer
- RESTful services
- MVC-style organization on server (Routes → Controllers → Models)
- Stateless authentication (JWT)
- Containerization of API calls (axiosInstance)
- Reusable React components, page-level routing

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and Browser
    User["User"]:::external
    Browser["Browser"]:::external
    User --> Browser

    %% Frontend Layer
    subgraph "Frontend (React App)"
        ReactApp["React App"]:::frontend
        subgraph "Pages"
            Home["Home Page"]:::frontend
            Filters["Filters"]:::frontend
            Login["Login Page"]:::frontend
            Register["Register Page"]:::frontend
            ProductInfo["Product Info Page"]:::frontend
            BidModal["Bid Modal"]:::frontend
            ProfileOverview["Profile Overview"]:::frontend
            ProfileProducts["User Products"]:::frontend
            ProductsForm["Products Form"]:::frontend
            BidsInProducts["Bids (Products)"]:::frontend
            Images["Product Images"]:::frontend
            UserBidsPage["User Bids"]:::frontend
            AdminPanel["Admin Panel"]:::frontend
            AdminProducts["Admin Products"]:::frontend
            AdminUsers["Admin Users"]:::frontend
        end
        subgraph "Components"
            Divider["Divider Component"]:::frontend
            NotificationsComp["Notifications Component"]:::frontend
            ProtectedPage["Protected Page"]:::frontend
        end
        subgraph "Redux Store"
            Store["Store"]:::frontend
            UsersSlice["Users Slice"]:::frontend
        end
        subgraph "API Calls (Axios)"
            AxiosInst["Axios Instance"]:::frontend
            UsersApi["Users API"]:::frontend
            ProductsApi["Products API"]:::frontend
            NotificationsApi["Notifications API"]:::frontend
        end
    end

    Browser --> ReactApp
    ReactApp --> Store
    ReactApp --> AxiosInst
    AxiosInst -->|"HTTP Requests"| ExpressServer

    %% Backend Layer
    subgraph "Backend (Express API)"
        Entry["Express Server (server.js)"]:::backend
        subgraph "Configuration"
            DBConfig["DB Config"]:::backend
            CloudConfig["Cloudinary Config"]:::backend
        end
        subgraph "Middleware"
            AuthMW["Auth Middleware"]:::backend
        end
        subgraph "Routes"
            UsersRoute["Users Route"]:::backend
            ProductsRoute["Products Route"]:::backend
            BidsRoute["Bids Route"]:::backend
            NotificationsRoute["Notifications Route"]:::backend
        end
        subgraph "Models"
            UserModel["User Model"]:::backend
            ProductModel["Product Model"]:::backend
            BidModel["Bid Model"]:::backend
            NotificationsModel["Notifications Model"]:::backend
        end
    end

    AxiosInst -->|"calls API"| Entry
    Entry --> DBConfig
    Entry --> CloudConfig
    Entry --> AuthMW
    Entry --> UsersRoute
    Entry --> ProductsRoute
    Entry --> BidsRoute
    Entry --> NotificationsRoute

    UsersRoute --> UserModel
    ProductsRoute --> ProductModel
    BidsRoute --> BidModel
    NotificationsRoute --> NotificationsModel

    ProductsRoute --> CloudConfig

    %% Data and External Services
    MongoDB["MongoDB"]:::database
    Cloudinary["Cloudinary"]:::external

    UserModel --> MongoDB
    ProductModel --> MongoDB
    BidModel --> MongoDB
    NotificationsModel --> MongoDB
    CloudConfig --> Cloudinary

    %% Build & Scripts
    RootPackage["Root package.json"]:::backend
    Nodemon["nodemon.json"]:::backend
    ClientPkg["client/package.json"]:::frontend
    TailwindCfg["client/tailwind.config.js"]:::frontend

    %% Click Events - Frontend
    click ReactApp "https://github.com/disha2553/campus-connect/tree/main/client/"
    click Store "https://github.com/disha2553/campus-connect/blob/main/client/src/redux/store.js"
    click UsersSlice "https://github.com/disha2553/campus-connect/blob/main/client/src/redux/usersSlice.js"
    click AxiosInst "https://github.com/disha2553/campus-connect/blob/main/client/src/apicalls/axiosInstance.js"
    click UsersApi "https://github.com/disha2553/campus-connect/blob/main/client/src/apicalls/users.js"
    click ProductsApi "https://github.com/disha2553/campus-connect/blob/main/client/src/apicalls/products.js"
    click NotificationsApi "https://github.com/disha2553/campus-connect/blob/main/client/src/apicalls/notifications.js"
    click Divider "https://github.com/disha2553/campus-connect/blob/main/client/src/components/Divider.js"
    click NotificationsComp "https://github.com/disha2553/campus-connect/blob/main/client/src/components/Notifications.js"
    click ProtectedPage "https://github.com/disha2553/campus-connect/blob/main/client/src/components/ProtectedPage.js"
    click Home "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Home/index.js"
    click Filters "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Home/filters.js"
    click Login "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Login/index.js"
    click Register "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Register/index.js"
    click ProductInfo "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/ProductInfo/index.js"
    click BidModal "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/ProductInfo/BidModal.js"
    click ProfileOverview "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Profile/index.js"
    click ProfileProducts "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Profile/Products/index.js"
    click ProductsForm "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Profile/Products/ProductsForm.js"
    click BidsInProducts "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Profile/Products/Bids.js"
    click Images "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Profile/Products/Images.js"
    click UserBidsPage "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Profile/UserBids/index.js"
    click AdminPanel "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Admin/index.js"
    click AdminProducts "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Admin/products.js"
    click AdminUsers "https://github.com/disha2553/campus-connect/blob/main/client/src/pages/Admin/users.js"

    %% Click Events - Backend
    click Entry "https://github.com/disha2553/campus-connect/blob/main/server/server.js"
    click DBConfig "https://github.com/disha2553/campus-connect/blob/main/server/config/dbConfig.js"
    click CloudConfig "https://github.com/disha2553/campus-connect/blob/main/server/config/cloudinaryConfig.js"
    click AuthMW "https://github.com/disha2553/campus-connect/blob/main/server/middlewares/authMiddleware.js"
    click UsersRoute "https://github.com/disha2553/campus-connect/blob/main/server/routes/usersRoute.js"
    click ProductsRoute "https://github.com/disha2553/campus-connect/blob/main/server/routes/productsRoute.js"
    click BidsRoute "https://github.com/disha2553/campus-connect/blob/main/server/routes/bidsRoute.js"
    click NotificationsRoute "https://github.com/disha2553/campus-connect/blob/main/server/routes/notificationsRoute.js"
    click UserModel "https://github.com/disha2553/campus-connect/blob/main/server/models/userModel.js"
    click ProductModel "https://github.com/disha2553/campus-connect/blob/main/server/models/productModel.js"
    click BidModel "https://github.com/disha2553/campus-connect/blob/main/server/models/bidModel.js"
    click NotificationsModel "https://github.com/disha2553/campus-connect/blob/main/server/models/notificationsModel.js"
    click RootPackage "https://github.com/disha2553/campus-connect/blob/main/package.json"
    click Nodemon "https://github.com/disha2553/campus-connect/blob/main/nodemon.json"
    click ClientPkg "https://github.com/disha2553/campus-connect/blob/main/client/package.json"
    click TailwindCfg "https://github.com/disha2553/campus-connect/blob/main/client/tailwind.config.js"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#00796B,stroke-width:1px
    classDef backend fill:#E8F5E9,stroke:#388E3C,stroke-width:1px
    classDef database fill:#FFF3E0,stroke:#F57C00,stroke-width:1px
    classDef external fill:#F3E5F5,stroke:#8E24AA,stroke-width:1px
```
