# pglim06/ez-swap architecture

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

- Interactive diagram: https://gitdiagram.com/pglim06/ez-swap
- Repository: https://github.com/pglim06/ez-swap

## Overview

EZ Swap is a campus peer-to-peer marketplace. Students discover listings, contact sellers, negotiate offers, coordinate handover, confirm completion and review one another; administrators moderate users, listings, reports and disputes. The React client routes users through these activities, while Express routes dispatch API requests to controllers and MongoDB-backed models. The README documents the product lifecycle and integrations; some frontend and controller implementations were not sampled, so those links are shown only where documented or indexed.

Main entry points: [`client/src/App.jsx`](https://github.com/pglim06/ez-swap/blob/main/client/src/App.jsx) (React application), [`server.js`](https://github.com/pglim06/ez-swap/blob/main/server.js) (Express and Socket.IO), [`routes/listingRoutes.js`](https://github.com/pglim06/ez-swap/blob/main/routes/listingRoutes.js) (Listing routes), [`controllers/listingController.js`](https://github.com/pglim06/ez-swap/blob/main/controllers/listingController.js) (Listing discovery and management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Marketplace client"]
  node_app["React application<br/>[App.jsx]"]
  node_discovery_ui["Browse and listing views"]
  node_account_ui["Account and profile"]
  node_orders_ui["Orders and handover<br/>[MyOrders.jsx]"]
  node_messages_ui["Messaging<br/>[Messages.jsx]"]
  node_admin_ui["Moderation dashboard<br/>[AdminDashboard.jsx]"]
  node_listings_ui["Listing creation and detail"]
end

subgraph group_identity["Identity and discovery"]
  node_auth_context["Authentication state<br/>[AuthContext.jsx]"]
  node_auth_controller["Authentication<br/>[authController.js]"]
  node_listing_controller["Listing discovery and management"]
  node_recommendations["Recommendations"]
  node_recommendation_engine["Recommendation scoring"]
end

subgraph group_trading["Trading and trust"]
  node_order_controller["Offer negotiation<br/>[orderController.js]"]
  node_transaction_controller["Meetup and handover"]
  node_review_controller["Mutual reviews"]
  node_admin_controller["Moderation operations<br/>[adminController.js]"]
end

subgraph group_backend["API and realtime"]
  node_auth_routes["Authentication routes<br/>[authRoutes.js]"]
  node_listing_routes["Listing routes<br/>[listingRoutes.js]"]
  node_review_routes["Review routes<br/>[reviewRoutes.js]"]
  node_chat_controller["Conversation API<br/>[chatController.js]"]
  node_socket["Realtime messaging<br/>[socketHandler.js]"]
  node_server["Express and Socket.IO<br/>[server.js]"]
  node_auth_middleware["Session authorization<br/>[authMiddleware.js]"]
end

subgraph group_data["Marketplace data"]
  node_listing_model[("Listings<br/>[Listing.js]")]
  node_user_model[("Users<br/>[User.js]")]
  node_order_model[("Offers and orders<br/>[Order.js]")]
  node_transaction_model[("Transactions<br/>[Transaction.js]")]
  node_review_model[("Reviews<br/>[Review.js]")]
end

node_student(("Student"))
node_admin(("Administrator"))
node_cloudinary[("Cloudinary image storage")]
node_mongodb[("MongoDB")]

node_student -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"provides state"| node_auth_context
node_app -->|"routes to"| node_discovery_ui
node_app -->|"routes to"| node_account_ui
node_app -->|"routes to"| node_orders_ui
node_app -->|"routes to"| node_messages_ui
node_app -->|"routes to"| node_admin_ui
node_student -->|"browses"| node_discovery_ui
node_discovery_ui -->|"requests listings"| node_listing_routes
node_listings_ui -->|"manages listings"| node_listing_routes
node_auth_context -->|"calls auth API"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_listing_routes -->|"dispatches"| node_listing_controller
node_listing_routes -->|"dispatches"| node_recommendations
node_listing_controller -->|"reads and writes"| node_listing_model
node_listing_controller -->|"uploads images"| node_cloudinary
node_listing_controller -->|"scores candidates"| node_recommendation_engine
node_recommendations -->|"uses scoring"| node_recommendation_engine
node_recommendations -->|"loads candidates"| node_listing_model
node_student -->|"chats"| node_messages_ui
node_messages_ui -->|"uses chat API"| node_chat_controller
node_server -->|"mounts routes"| node_chat_controller
node_server -->|"initializes handlers"| node_socket
node_student -->|"negotiates offers"| node_orders_ui
node_orders_ui -->|"submits offers"| node_order_controller
node_order_controller -->|"creates transaction"| node_transaction_model
node_orders_ui -->|"coordinates handover"| node_transaction_controller
node_transaction_controller -->|"updates handover"| node_transaction_model
node_transaction_controller -->|"reads order"| node_order_model
node_student -->|"submits ratings"| node_review_controller
node_review_controller -->|"creates reviews"| node_review_model
node_review_controller -->|"checks completion"| node_transaction_model
node_review_model -->|"updates reputation"| node_user_model
node_admin_ui -->|"moderates platform"| node_admin_controller
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_listing_routes
node_server -->|"mounts routes"| node_review_routes
node_review_routes -->|"dispatches"| node_review_controller
node_server -->|"uses protection"| node_auth_middleware
node_auth_middleware -->|"loads session user"| node_user_model
node_admin_controller -->|"moderates users"| node_user_model
node_admin_controller -->|"moderates listings"| node_listing_model
node_admin_controller -->|"reviews disputes"| node_transaction_model
node_server -->|"connects database"| node_mongodb

click node_app "https://github.com/pglim06/ez-swap/blob/main/client/src/App.jsx"
click node_discovery_ui "https://github.com/pglim06/ez-swap/tree/main/client/src/pages"
click node_account_ui "https://github.com/pglim06/ez-swap/tree/main/client/src/pages"
click node_orders_ui "https://github.com/pglim06/ez-swap/blob/main/client/src/pages/MyOrders.jsx"
click node_messages_ui "https://github.com/pglim06/ez-swap/blob/main/client/src/pages/Messages.jsx"
click node_admin_ui "https://github.com/pglim06/ez-swap/blob/main/client/src/pages/AdminDashboard.jsx"
click node_auth_context "https://github.com/pglim06/ez-swap/blob/main/client/src/context/AuthContext.jsx"
click node_auth_routes "https://github.com/pglim06/ez-swap/blob/main/routes/authRoutes.js"
click node_auth_controller "https://github.com/pglim06/ez-swap/blob/main/controllers/authController.js"
click node_listings_ui "https://github.com/pglim06/ez-swap/tree/main/client/src/pages"
click node_listing_routes "https://github.com/pglim06/ez-swap/blob/main/routes/listingRoutes.js"
click node_listing_controller "https://github.com/pglim06/ez-swap/blob/main/controllers/listingController.js"
click node_recommendations "https://github.com/pglim06/ez-swap/blob/main/controllers/recommendationController.js"
click node_recommendation_engine "https://github.com/pglim06/ez-swap/blob/main/utils/recommendationEngine.js"
click node_order_controller "https://github.com/pglim06/ez-swap/blob/main/controllers/orderController.js"
click node_transaction_controller "https://github.com/pglim06/ez-swap/blob/main/controllers/transactionController.js"
click node_review_controller "https://github.com/pglim06/ez-swap/blob/main/controllers/reviewController.js"
click node_review_routes "https://github.com/pglim06/ez-swap/blob/main/routes/reviewRoutes.js"
click node_admin_controller "https://github.com/pglim06/ez-swap/blob/main/controllers/adminController.js"
click node_chat_controller "https://github.com/pglim06/ez-swap/blob/main/controllers/chatController.js"
click node_socket "https://github.com/pglim06/ez-swap/blob/main/socket/socketHandler.js"
click node_server "https://github.com/pglim06/ez-swap/blob/main/server.js"
click node_auth_middleware "https://github.com/pglim06/ez-swap/blob/main/middleware/authMiddleware.js"
click node_listing_model "https://github.com/pglim06/ez-swap/blob/main/models/Listing.js"
click node_user_model "https://github.com/pglim06/ez-swap/blob/main/models/User.js"
click node_order_model "https://github.com/pglim06/ez-swap/blob/main/models/Order.js"
click node_transaction_model "https://github.com/pglim06/ez-swap/blob/main/models/Transaction.js"
click node_review_model "https://github.com/pglim06/ez-swap/blob/main/models/Review.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_app,node_discovery_ui,node_account_ui,node_orders_ui,node_messages_ui,node_admin_ui,node_listings_ui toneBlue
class node_auth_context,node_auth_controller,node_listing_controller,node_recommendations,node_recommendation_engine,node_cloudinary,node_mongodb toneAmber
class node_order_controller,node_transaction_controller,node_review_controller,node_admin_controller toneMint
class node_auth_routes,node_listing_routes,node_review_routes,node_chat_controller,node_socket,node_server,node_auth_middleware toneRose
class node_listing_model,node_user_model,node_order_model,node_transaction_model,node_review_model,node_student,node_admin toneIndigo
```

## Components

### Marketplace client

- [React application](https://github.com/pglim06/ez-swap/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Browse and listing views](https://github.com/pglim06/ez-swap/tree/main/client/src/pages): `client/src/pages`
- [Account and profile](https://github.com/pglim06/ez-swap/tree/main/client/src/pages): `client/src/pages`
- [Orders and handover](https://github.com/pglim06/ez-swap/blob/main/client/src/pages/MyOrders.jsx): `client/src/pages/MyOrders.jsx`
- [Messaging](https://github.com/pglim06/ez-swap/blob/main/client/src/pages/Messages.jsx): `client/src/pages/Messages.jsx`
- [Moderation dashboard](https://github.com/pglim06/ez-swap/blob/main/client/src/pages/AdminDashboard.jsx): `client/src/pages/AdminDashboard.jsx`
- [Listing creation and detail](https://github.com/pglim06/ez-swap/tree/main/client/src/pages): `client/src/pages`

### Identity and discovery

- [Authentication state](https://github.com/pglim06/ez-swap/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Authentication](https://github.com/pglim06/ez-swap/blob/main/controllers/authController.js): `controllers/authController.js`
- [Listing discovery and management](https://github.com/pglim06/ez-swap/blob/main/controllers/listingController.js): `controllers/listingController.js`
- [Recommendations](https://github.com/pglim06/ez-swap/blob/main/controllers/recommendationController.js): `controllers/recommendationController.js`
- [Recommendation scoring](https://github.com/pglim06/ez-swap/blob/main/utils/recommendationEngine.js): `utils/recommendationEngine.js`

### Trading and trust

- [Offer negotiation](https://github.com/pglim06/ez-swap/blob/main/controllers/orderController.js): `controllers/orderController.js`
- [Meetup and handover](https://github.com/pglim06/ez-swap/blob/main/controllers/transactionController.js): `controllers/transactionController.js`
- [Mutual reviews](https://github.com/pglim06/ez-swap/blob/main/controllers/reviewController.js): `controllers/reviewController.js`
- [Moderation operations](https://github.com/pglim06/ez-swap/blob/main/controllers/adminController.js): `controllers/adminController.js`

### API and realtime

- [Authentication routes](https://github.com/pglim06/ez-swap/blob/main/routes/authRoutes.js): `routes/authRoutes.js`
- [Listing routes](https://github.com/pglim06/ez-swap/blob/main/routes/listingRoutes.js): `routes/listingRoutes.js`
- [Review routes](https://github.com/pglim06/ez-swap/blob/main/routes/reviewRoutes.js): `routes/reviewRoutes.js`
- [Conversation API](https://github.com/pglim06/ez-swap/blob/main/controllers/chatController.js): `controllers/chatController.js`
- [Realtime messaging](https://github.com/pglim06/ez-swap/blob/main/socket/socketHandler.js): `socket/socketHandler.js`
- [Express and Socket.IO](https://github.com/pglim06/ez-swap/blob/main/server.js): `server.js`
- [Session authorization](https://github.com/pglim06/ez-swap/blob/main/middleware/authMiddleware.js): `middleware/authMiddleware.js`

### Marketplace data

- [Listings](https://github.com/pglim06/ez-swap/blob/main/models/Listing.js): `models/Listing.js`
- [Users](https://github.com/pglim06/ez-swap/blob/main/models/User.js): `models/User.js`
- [Offers and orders](https://github.com/pglim06/ez-swap/blob/main/models/Order.js): `models/Order.js`
- [Transactions](https://github.com/pglim06/ez-swap/blob/main/models/Transaction.js): `models/Transaction.js`
- [Reviews](https://github.com/pglim06/ez-swap/blob/main/models/Review.js): `models/Review.js`

### Other components

- **Student**
- **Administrator**
- **Cloudinary image storage**
- **MongoDB**

## Connections

- Student → React application: uses (evidence: `README.md`)
- Administrator → React application: uses (evidence: `README.md`)
- React application → Authentication state: provides state (evidence: `client/src/App.jsx`)
- React application → Browse and listing views: routes to (evidence: `client/src/App.jsx`)
- React application → Account and profile: routes to (evidence: `client/src/App.jsx`)
- React application → Orders and handover: routes to (evidence: `client/src/App.jsx`)
- React application → Messaging: routes to (evidence: `client/src/App.jsx`)
- React application → Moderation dashboard: routes to (evidence: `client/src/App.jsx`)
- Student → Browse and listing views: browses (evidence: `README.md`)
- Browse and listing views → Listing routes: requests listings (evidence: `README.md`)
- Listing creation and detail → Listing routes: manages listings (evidence: `README.md`)
- Authentication state → Authentication routes: calls auth API (evidence: `client/src/context/AuthContext.jsx`)
- Authentication routes → Authentication: dispatches (evidence: `routes/authRoutes.js`)
- Listing routes → Listing discovery and management: dispatches (evidence: `routes/listingRoutes.js`)
- Listing routes → Recommendations: dispatches (evidence: `routes/listingRoutes.js`)
- Listing discovery and management → Listings: reads and writes (evidence: `controllers/listingController.js`)
- Listing discovery and management → Cloudinary image storage: uploads images (evidence: `controllers/listingController.js`)
- Listing discovery and management → Recommendation scoring: scores candidates (evidence: `controllers/listingController.js`)
- Recommendations → Recommendation scoring: uses scoring (evidence: `controllers/recommendationController.js`)
- Recommendations → Listings: loads candidates (evidence: `controllers/recommendationController.js`)
- Student → Messaging: chats (evidence: `README.md`)
- Messaging → Conversation API: uses chat API (evidence: `README.md`)
- Express and Socket.IO → Conversation API: mounts routes (evidence: `server.js`)
- Express and Socket.IO → Realtime messaging: initializes handlers (evidence: `server.js`)
- Student → Orders and handover: negotiates offers (evidence: `README.md`)
- Orders and handover → Offer negotiation: submits offers (evidence: `README.md`)
- Offer negotiation → Transactions: creates transaction (evidence: `controllers/orderController.js`)
- Orders and handover → Meetup and handover: coordinates handover (evidence: `README.md`)
- Meetup and handover → Transactions: updates handover (evidence: `controllers/transactionController.js`)
- Meetup and handover → Offers and orders: reads order (evidence: `controllers/transactionController.js`)
- Student → Mutual reviews: submits ratings (evidence: `README.md`)
- Mutual reviews → Reviews: creates reviews (evidence: `controllers/reviewController.js`)
- Mutual reviews → Transactions: checks completion (evidence: `controllers/reviewController.js`)
- Reviews → Users: updates reputation (evidence: `models/Review.js`)
- Moderation dashboard → Moderation operations: moderates platform (evidence: `README.md`)
- Express and Socket.IO → Authentication routes: mounts routes (evidence: `server.js`)
- Express and Socket.IO → Listing routes: mounts routes (evidence: `server.js`)
- Express and Socket.IO → Review routes: mounts routes (evidence: `server.js`)
- Review routes → Mutual reviews: dispatches (evidence: `routes/reviewRoutes.js`)
- Express and Socket.IO → Session authorization: uses protection
- Session authorization → Users: loads session user (evidence: `middleware/authMiddleware.js`)
- Moderation operations → Users: moderates users (evidence: `controllers/adminController.js`)
- Moderation operations → Listings: moderates listings (evidence: `controllers/adminController.js`)
- Moderation operations → Transactions: reviews disputes (evidence: `controllers/adminController.js`)
- Express and Socket.IO → MongoDB: connects database (evidence: `server.js`)
