# sriram-arch616/campusmart architecture

> Architecture diagram of the GitHub repository sriram-arch616/campusmart, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sriram-arch616/campusmart
- Repository: https://github.com/sriram-arch616/campusmart

## Overview

CampusMarketPlace is a campus-only marketplace for listing, discovering, and trading items. Students use the browser client to authenticate, browse or manage listings, and communicate; the Express API handles requests, applies authentication and feature logic, and stores marketplace state in MySQL. Distinct product capabilities include listing search and image uploads, chat and trade requests, notifications, admin management, and support tickets. The README documents Redis-backed Socket.io scaling and Cloudinary storage; excerpts do not expose every integration path, so some capability links are documented rather than source-traced.

Main entry points: [`frontend/js`](https://github.com/sriram-arch616/campusmart/tree/main/frontend/js) (Web client), [`backend/src/config/db.js`](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/config/db.js) (MySQL), [`backend/src/app.js`](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/app.js) (Express app), [`backend/src/routes/productRoutes.js`](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/routes/productRoutes.js) (Product routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_webclient["Web client"]
  node_authui["Account UI<br/>[auth.js]"]
  node_marketui["Marketplace UI<br/>[dashboard.js]"]
  node_listingui["Listing UI<br/>[addProduct.js]"]
  node_profileui["Profile UI<br/>[profile.js]"]
  node_chatui["Chat UI<br/>[chat.js]"]
  node_noticeui["Notification UI<br/>[notifications.js]"]
end

subgraph group_api["API and security"]
  node_server["HTTP server<br/>[server.js]"]
  node_app["Express app<br/>[app.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_authctrl["Authentication<br/>[authController.js]"]
  node_authsvc["Auth service<br/>[authService.js]"]
  node_authmw["Token middleware<br/>[authMiddleware.js]"]
end

subgraph group_market["Marketplace workflows"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_productctrl["Product handling"]
  node_productsvc["Product service<br/>[productService.js]"]
  node_upload["Image upload"]
end

subgraph group_community["Community features"]
  node_chatroutes["Chat routes<br/>[chatRoutes.js]"]
  node_chatctrl["Chat and trades<br/>[chatController.js]"]
  node_socket["Realtime messaging<br/>[socket.js]"]
  node_support["Support tickets"]
  node_admin["Admin management<br/>[adminController.js]"]
  node_notifications["Notifications"]
end

subgraph group_platform["Data and integrations"]
  node_mysql[("MySQL<br/>[db.js]")]
  node_cloudinary["Cloudinary images<br/>[cloudinary.js]"]
  node_email["Email delivery<br/>[emailService.js]"]
  node_redis[("Redis adapter")]
end

node_student(("Student"))

node_student -->|"uses"| node_webclient
node_webclient -->|"calls API"| node_server
node_webclient -.->|"opens realtime"| node_socket
node_authui -.->|"renders account"| node_webclient
node_marketui -.->|"renders listings"| node_webclient
node_listingui -.->|"submits listings"| node_webclient
node_profileui -.->|"manages profile"| node_webclient
node_chatui -.->|"renders chat"| node_webclient
node_noticeui -.->|"renders notices"| node_webclient
node_server -->|"serves HTTP"| node_app
node_app -->|"mounts routes"| node_authroutes
node_app -->|"mounts routes"| node_productroutes
node_app -->|"mounts routes"| node_chatroutes
node_authroutes -->|"dispatches"| node_authctrl
node_authroutes -->|"protects endpoint"| node_authmw
node_authctrl -->|"calls"| node_authsvc
node_authsvc -->|"reads and writes"| node_mysql
node_productroutes -->|"dispatches"| node_productctrl
node_productroutes -->|"protects endpoints"| node_authmw
node_productroutes -->|"accepts image"| node_upload
node_productctrl -->|"calls"| node_productsvc
node_productctrl -->|"deletes images"| node_cloudinary
node_productsvc -->|"reads and writes"| node_mysql
node_upload -.->|"stores images"| node_cloudinary
node_chatroutes -->|"dispatches"| node_chatctrl
node_chatroutes -->|"requires token"| node_authmw
node_chatctrl -->|"reads and writes"| node_mysql
node_server -->|"initializes"| node_socket
node_socket -.->|"scales through"| node_redis
node_socket -->|"uses service"| node_notifications
node_support -->|"reads and writes"| node_mysql
node_admin -.->|"manages records"| node_mysql
node_notifications -->|"reads and writes"| node_mysql
node_authctrl -->|"sends OTP"| node_email

click node_webclient "https://github.com/sriram-arch616/campusmart/tree/main/frontend/js"
click node_authui "https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/utils/auth.js"
click node_marketui "https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/dashboard.js"
click node_listingui "https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/addProduct.js"
click node_profileui "https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/profile.js"
click node_chatui "https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/chat.js"
click node_noticeui "https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/utils/notifications.js"
click node_server "https://github.com/sriram-arch616/campusmart/blob/main/backend/server.js"
click node_app "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/app.js"
click node_authroutes "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/routes/authRoutes.js"
click node_authctrl "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/authController.js"
click node_authsvc "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/services/authService.js"
click node_authmw "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/middleware/authMiddleware.js"
click node_productroutes "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/routes/productRoutes.js"
click node_productctrl "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/productController.js"
click node_productsvc "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/services/productService.js"
click node_upload "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/middleware/uploadMiddleware.js"
click node_chatroutes "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/routes/chatRoutes.js"
click node_chatctrl "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/chatController.js"
click node_socket "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/config/socket.js"
click node_support "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/supportController.js"
click node_admin "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/adminController.js"
click node_notifications "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/services/notificationService.js"
click node_mysql "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/config/db.js"
click node_cloudinary "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/config/cloudinary.js"
click node_email "https://github.com/sriram-arch616/campusmart/blob/main/backend/src/services/emailService.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webclient,node_authui,node_marketui,node_listingui,node_profileui,node_chatui,node_noticeui toneBlue
class node_server,node_app,node_authroutes,node_authctrl,node_authsvc,node_authmw toneAmber
class node_productroutes,node_productctrl,node_productsvc,node_upload toneMint
class node_chatroutes,node_chatctrl,node_socket,node_support,node_admin,node_notifications toneRose
class node_mysql,node_cloudinary,node_email,node_redis,node_student toneIndigo
```

## Components

### Browser client

- [Web client](https://github.com/sriram-arch616/campusmart/tree/main/frontend/js): `frontend/js`
- [Account UI](https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/utils/auth.js): `frontend/js/utils/auth.js`
- [Marketplace UI](https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/dashboard.js): `frontend/js/dashboard.js`
- [Listing UI](https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/addProduct.js): `frontend/js/addProduct.js`
- [Profile UI](https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/profile.js): `frontend/js/profile.js`
- [Chat UI](https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/chat.js): `frontend/js/chat.js`
- [Notification UI](https://github.com/sriram-arch616/campusmart/blob/main/frontend/js/utils/notifications.js): `frontend/js/utils/notifications.js`

### API and security

- [HTTP server](https://github.com/sriram-arch616/campusmart/blob/main/backend/server.js): `backend/server.js`
- [Express app](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/app.js): `backend/src/app.js`
- [Auth routes](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/routes/authRoutes.js): `backend/src/routes/authRoutes.js`
- [Authentication](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Auth service](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/services/authService.js): `backend/src/services/authService.js`
- [Token middleware](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/middleware/authMiddleware.js): `backend/src/middleware/authMiddleware.js`

### Marketplace workflows

- [Product routes](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/routes/productRoutes.js): `backend/src/routes/productRoutes.js`
- [Product handling](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/productController.js): `backend/src/controllers/productController.js`
- [Product service](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/services/productService.js): `backend/src/services/productService.js`
- [Image upload](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/middleware/uploadMiddleware.js): `backend/src/middleware/uploadMiddleware.js`

### Community features

- [Chat routes](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/routes/chatRoutes.js): `backend/src/routes/chatRoutes.js`
- [Chat and trades](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/chatController.js): `backend/src/controllers/chatController.js`
- [Realtime messaging](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/config/socket.js): `backend/src/config/socket.js`
- [Support tickets](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/supportController.js): `backend/src/controllers/supportController.js`
- [Admin management](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/controllers/adminController.js): `backend/src/controllers/adminController.js`
- [Notifications](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/services/notificationService.js): `backend/src/services/notificationService.js`

### Data and integrations

- [MySQL](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/config/db.js): `backend/src/config/db.js`
- [Cloudinary images](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/config/cloudinary.js): `backend/src/config/cloudinary.js`
- [Email delivery](https://github.com/sriram-arch616/campusmart/blob/main/backend/src/services/emailService.js): `backend/src/services/emailService.js`
- **Redis adapter**

### Other components

- **Student**

## Connections

- Student → Web client: uses (evidence: `README.md`)
- Web client → HTTP server: calls API (evidence: `README.md`)
- Web client → Realtime messaging: opens realtime (evidence: `README.md`)
- Account UI → Web client: renders account
- Marketplace UI → Web client: renders listings
- Listing UI → Web client: submits listings
- Profile UI → Web client: manages profile
- Chat UI → Web client: renders chat
- Notification UI → Web client: renders notices
- HTTP server → Express app: serves HTTP (evidence: `backend/server.js`)
- Express app → Auth routes: mounts routes (evidence: `backend/src/app.js`)
- Express app → Product routes: mounts routes (evidence: `backend/src/app.js`)
- Express app → Chat routes: mounts routes (evidence: `backend/src/app.js`)
- Auth routes → Authentication: dispatches (evidence: `backend/src/routes/authRoutes.js`)
- Auth routes → Token middleware: protects endpoint (evidence: `backend/src/routes/authRoutes.js`)
- Authentication → Auth service: calls (evidence: `backend/src/controllers/authController.js`)
- Auth service → MySQL: reads and writes (evidence: `backend/src/services/authService.js`)
- Product routes → Product handling: dispatches (evidence: `backend/src/routes/productRoutes.js`)
- Product routes → Token middleware: protects endpoints (evidence: `backend/src/routes/productRoutes.js`)
- Product routes → Image upload: accepts image (evidence: `backend/src/routes/productRoutes.js`)
- Product handling → Product service: calls (evidence: `backend/src/controllers/productController.js`)
- Product handling → Cloudinary images: deletes images (evidence: `backend/src/controllers/productController.js`)
- Product service → MySQL: reads and writes (evidence: `backend/src/services/productService.js`)
- Image upload → Cloudinary images: stores images (evidence: `README.md`)
- Chat routes → Chat and trades: dispatches (evidence: `backend/src/routes/chatRoutes.js`)
- Chat routes → Token middleware: requires token (evidence: `backend/src/routes/chatRoutes.js`)
- Chat and trades → MySQL: reads and writes (evidence: `backend/src/controllers/chatController.js`)
- HTTP server → Realtime messaging: initializes (evidence: `backend/server.js`)
- Realtime messaging → Redis adapter: scales through (evidence: `README.md`)
- Realtime messaging → Notifications: uses service (evidence: `backend/src/config/socket.js`)
- Support tickets → MySQL: reads and writes (evidence: `backend/src/controllers/supportController.js`)
- Admin management → MySQL: manages records
- Notifications → MySQL: reads and writes (evidence: `backend/src/services/notificationService.js`)
- Authentication → Email delivery: sends OTP (evidence: `backend/src/controllers/authController.js`)
