# vishwaraj-636/wearth architecture

> Architecture diagram of the GitHub repository vishwaraj-636/wearth, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vishwaraj-636/wearth
- Repository: https://github.com/vishwaraj-636/wearth

## Overview

WEARTH is a MERN e-commerce platform. Buyers browse products, authenticate, manage a cart, and check out through Razorpay; sellers authenticate to create and manage products and inventory. The frontend routes pages and feature hooks through API services to the Express backend, whose routes dispatch to controllers and Mongo-backed models. README capabilities include Google OAuth and ImageKit uploads; payment and upload integrations are visible in sampled code. Several frontend pages and backend modules were not sampled, so those links are omitted or documented without asserting unsampled calls.

Main entry points: [`backend/src/controllers/cart.controller.js`](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/controllers/cart.controller.js) (Cart and order controller), [`frontend/src/app/app.routes.jsx`](https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/app/app.routes.jsx) (Feature routes), [`backend/src/app.js`](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/app.js) (Express app), [`backend/src/middleware/auth.middleware.js`](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/middleware/auth.middleware.js) (JWT access middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["App bootstrap<br/>[App.jsx]"]
  node_routes["Feature routes<br/>[app.routes.jsx]"]
  node_authui["Auth pages and hook"]
  node_authapi["Auth API client<br/>[auth.api.js]"]
  node_cartui["Cart pages and hook"]
  node_cartapi["Cart API client<br/>[cart.api.js]"]
  node_productui["Catalog and seller pages"]
  node_productapi["Product API client<br/>[product.api.js]"]
end

subgraph group_identity["Identity and access"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_authctrl["Auth controller<br/>[auth.controller.js]"]
  node_authmw["JWT access middleware<br/>[auth.middleware.js]"]
  node_users[("User records<br/>[user.model.js]")]
end

subgraph group_catalog["Product catalog"]
  node_productroutes["Product routes<br/>[product.routes.js]"]
  node_productctrl["Product controller"]
  node_productmodel[("Product records<br/>[product.model.js]")]
  node_storage["Image storage service<br/>[storage.service.js]"]
end

subgraph group_checkout["Cart and payments"]
  node_cartroutes["Cart routes<br/>[cart.routes.js]"]
  node_cartctrl["Cart and order controller<br/>[cart.controller.js]"]
  node_cartdao["Cart detail DAO<br/>[cart.dao.js]"]
  node_cartmodel[("Cart records<br/>[cart.model.js]")]
  node_paymentmodel[("Payment records<br/>[payment.model.js]")]
  node_paymentservice["Payment order service<br/>[payment.service.js]"]
end

subgraph group_platform["Backend platform"]
  node_server["HTTP server<br/>[server.js]"]
  node_appserver["Express app<br/>[app.js]"]
  node_database[("Mongo connection<br/>[database.js]")]
end

node_buyer(("Buyer"))
node_seller(("Seller"))
node_imagekit["ImageKit"]
node_razorpay["Razorpay"]

node_buyer -.->|"browses and shops"| node_routes
node_seller -.->|"manages listings"| node_routes
node_app -->|"provides routes"| node_routes
node_app -->|"loads user"| node_authui
node_routes -.->|"routes to"| node_authui
node_routes -.->|"routes to"| node_cartui
node_routes -.->|"routes to"| node_productui
node_authui -->|"calls"| node_authapi
node_cartui -->|"calls"| node_cartapi
node_productui -->|"calls"| node_productapi
node_authroutes -->|"dispatches"| node_authctrl
node_authroutes -->|"protects"| node_authmw
node_authctrl -->|"reads and writes"| node_users
node_authmw -->|"loads user"| node_users
node_productroutes -->|"dispatches"| node_productctrl
node_productroutes -->|"protects seller routes"| node_authmw
node_productctrl -->|"reads and writes"| node_productmodel
node_productctrl -->|"uploads images"| node_storage
node_storage -->|"uploads files"| node_imagekit
node_cartroutes -->|"dispatches"| node_cartctrl
node_cartroutes -->|"protects routes"| node_authmw
node_cartctrl -->|"gets cart details"| node_cartdao
node_cartctrl -->|"reads and writes"| node_cartmodel
node_cartctrl -->|"checks products"| node_productmodel
node_cartctrl -->|"records payment"| node_paymentmodel
node_cartctrl -->|"creates order"| node_paymentservice
node_paymentservice -.->|"creates payment order"| node_razorpay
node_server -->|"connects"| node_database
node_server -->|"serves"| node_appserver
node_appserver -->|"mounts"| node_authroutes
node_appserver -->|"mounts"| node_productroutes
node_appserver -->|"mounts"| node_cartroutes

click node_app "https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/app/App.jsx"
click node_routes "https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/app/app.routes.jsx"
click node_authui "https://github.com/vishwaraj-636/wearth/tree/main/frontend/src/features/auth"
click node_authapi "https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/features/auth/services/auth.api.js"
click node_cartui "https://github.com/vishwaraj-636/wearth/tree/main/frontend/src/features/cart"
click node_cartapi "https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/features/cart/services/cart.api.js"
click node_productui "https://github.com/vishwaraj-636/wearth/tree/main/frontend/src/features/products"
click node_productapi "https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/features/products/sevices/product.api.js"
click node_authroutes "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/routes/auth.routes.js"
click node_authctrl "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/controllers/auth.controller.js"
click node_authmw "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/middleware/auth.middleware.js"
click node_users "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/models/user.model.js"
click node_productroutes "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/routes/product.routes.js"
click node_productctrl "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/controllers/product.controller.js"
click node_productmodel "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/models/product.model.js"
click node_storage "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/services/storage.service.js"
click node_cartroutes "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/routes/cart.routes.js"
click node_cartctrl "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/controllers/cart.controller.js"
click node_cartdao "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/dao/cart.dao.js"
click node_cartmodel "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/models/cart.model.js"
click node_paymentmodel "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/models/payment.model.js"
click node_paymentservice "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/services/payment.service.js"
click node_server "https://github.com/vishwaraj-636/wearth/blob/main/backend/server.js"
click node_appserver "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/app.js"
click node_database "https://github.com/vishwaraj-636/wearth/blob/main/backend/src/config/database.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_routes,node_authui,node_authapi,node_cartui,node_cartapi,node_productui,node_productapi toneBlue
class node_authroutes,node_authctrl,node_authmw,node_users toneAmber
class node_productroutes,node_productctrl,node_productmodel,node_storage toneMint
class node_cartroutes,node_cartctrl,node_cartdao,node_cartmodel,node_paymentmodel,node_paymentservice toneRose
class node_server,node_appserver,node_database,node_buyer,node_seller,node_imagekit,node_razorpay toneIndigo
```

## Components

### Frontend experience

- [App bootstrap](https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/app/App.jsx): `frontend/src/app/App.jsx`
- [Feature routes](https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/app/app.routes.jsx): `frontend/src/app/app.routes.jsx`
- [Auth pages and hook](https://github.com/vishwaraj-636/wearth/tree/main/frontend/src/features/auth): `frontend/src/features/auth`
- [Auth API client](https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/features/auth/services/auth.api.js): `frontend/src/features/auth/services/auth.api.js`
- [Cart pages and hook](https://github.com/vishwaraj-636/wearth/tree/main/frontend/src/features/cart): `frontend/src/features/cart`
- [Cart API client](https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/features/cart/services/cart.api.js): `frontend/src/features/cart/services/cart.api.js`
- [Catalog and seller pages](https://github.com/vishwaraj-636/wearth/tree/main/frontend/src/features/products): `frontend/src/features/products`
- [Product API client](https://github.com/vishwaraj-636/wearth/blob/main/frontend/src/features/products/sevices/product.api.js): `frontend/src/features/products/sevices/product.api.js`

### Identity and access

- [Auth routes](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/routes/auth.routes.js): `backend/src/routes/auth.routes.js`
- [Auth controller](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [JWT access middleware](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`
- [User records](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/models/user.model.js): `backend/src/models/user.model.js`

### Product catalog

- [Product routes](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/routes/product.routes.js): `backend/src/routes/product.routes.js`
- [Product controller](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/controllers/product.controller.js): `backend/src/controllers/product.controller.js`
- [Product records](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/models/product.model.js): `backend/src/models/product.model.js`
- [Image storage service](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/services/storage.service.js): `backend/src/services/storage.service.js`

### Cart and payments

- [Cart routes](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/routes/cart.routes.js): `backend/src/routes/cart.routes.js`
- [Cart and order controller](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/controllers/cart.controller.js): `backend/src/controllers/cart.controller.js`
- [Cart detail DAO](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/dao/cart.dao.js): `backend/src/dao/cart.dao.js`
- [Cart records](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/models/cart.model.js): `backend/src/models/cart.model.js`
- [Payment records](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/models/payment.model.js): `backend/src/models/payment.model.js`
- [Payment order service](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/services/payment.service.js): `backend/src/services/payment.service.js`

### Backend platform

- [HTTP server](https://github.com/vishwaraj-636/wearth/blob/main/backend/server.js): `backend/server.js`
- [Express app](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/app.js): `backend/src/app.js`
- [Mongo connection](https://github.com/vishwaraj-636/wearth/blob/main/backend/src/config/database.js): `backend/src/config/database.js`

### Other components

- **Buyer**
- **Seller**
- **ImageKit**
- **Razorpay**

## Connections

- Buyer → Feature routes: browses and shops (evidence: `README.md`)
- Seller → Feature routes: manages listings (evidence: `README.md`)
- App bootstrap → Feature routes: provides routes (evidence: `frontend/src/app/App.jsx`)
- App bootstrap → Auth pages and hook: loads user (evidence: `frontend/src/app/App.jsx`)
- Feature routes → Auth pages and hook: routes to
- Feature routes → Cart pages and hook: routes to
- Feature routes → Catalog and seller pages: routes to
- Auth pages and hook → Auth API client: calls (evidence: `frontend/src/features/auth/hook/useAuth.js`)
- Cart pages and hook → Cart API client: calls (evidence: `frontend/src/features/cart/hook/useCart.js`)
- Catalog and seller pages → Product API client: calls (evidence: `frontend/src/features/products/hook/useProduct.js`)
- Auth routes → Auth controller: dispatches (evidence: `backend/src/routes/auth.routes.js`)
- Auth routes → JWT access middleware: protects (evidence: `backend/src/routes/auth.routes.js`)
- Auth controller → User records: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- JWT access middleware → User records: loads user (evidence: `backend/src/middleware/auth.middleware.js`)
- Product routes → Product controller: dispatches (evidence: `backend/src/routes/product.routes.js`)
- Product routes → JWT access middleware: protects seller routes (evidence: `backend/src/routes/product.routes.js`)
- Product controller → Product records: reads and writes (evidence: `backend/src/controllers/product.controller.js`)
- Product controller → Image storage service: uploads images (evidence: `backend/src/controllers/product.controller.js`)
- Image storage service → ImageKit: uploads files (evidence: `backend/src/services/storage.service.js`)
- Cart routes → Cart and order controller: dispatches (evidence: `backend/src/routes/cart.routes.js`)
- Cart routes → JWT access middleware: protects routes (evidence: `backend/src/routes/cart.routes.js`)
- Cart and order controller → Cart detail DAO: gets cart details (evidence: `backend/src/controllers/cart.controller.js`)
- Cart and order controller → Cart records: reads and writes (evidence: `backend/src/controllers/cart.controller.js`)
- Cart and order controller → Product records: checks products (evidence: `backend/src/controllers/cart.controller.js`)
- Cart and order controller → Payment records: records payment (evidence: `backend/src/controllers/cart.controller.js`)
- Cart and order controller → Payment order service: creates order (evidence: `backend/src/controllers/cart.controller.js`)
- Payment order service → Razorpay: creates payment order (evidence: `README.md`)
- HTTP server → Mongo connection: connects (evidence: `backend/server.js`)
- HTTP server → Express app: serves (evidence: `backend/server.js`)
- Express app → Auth routes: mounts (evidence: `backend/src/app.js`)
- Express app → Product routes: mounts (evidence: `backend/src/app.js`)
- Express app → Cart routes: mounts (evidence: `backend/src/app.js`)
