# dhaneesh7/quickart_mern_deploy architecture

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

- Interactive diagram: https://gitdiagram.com/dhaneesh7/quickart_mern_deploy
- Repository: https://github.com/dhaneesh7/quickart_mern_deploy

## Overview

1. **Repo shape**
   - This is a split **MERN-style monorepo** with a separate `backend/` API and `frontend/` React app.
   - The backend owns persistence, authentication, product/order/payment logic; the frontend is a Vite-based SPA that consumes the API.

2. **Backend entrypoint and wiring**
   - `backend/server.js` is the API bootstrap.
   - It likely wires Express middleware, connects MongoDB, mounts the route modules, and configures CORS/client origin from `CLIENT_URL`.

3. **Data layer**
   - MongoDB is the primary system of record via models in `backend/models/`: `User`, `Product`, and `Order`.
   - `backend/config/db.js` handles the database connection.
   - Redis is present through `backend/config/redis.js`, suggesting token/session or auth state support beyond MongoDB.

4. **Domain boundaries on the API**
   - The backend is divided by business capability:
     - `AuthRoutes` / `authController` for login, signup, token refresh, logout
     - `UserRoutes` / `userController` for profile/user operations
     - `ProductRoutes` / `productController` for catalog CRUD and product retrieval
     - `CartRoutes` / `cartController` for cart operations
     - `OrderRoutes` / `orderController` for checkout/order lifecycle
     - `PaymentRoutes` / `paymentController` for payment initiation and result handling

5. **Security and request pipeline**
   - `backend/middleware/Auth_Middleware.js` protects authenticated routes.
   - The auth flow appears to use **access and refresh tokens** (`ACCESS_TOKEN_SECRET`, `REFRESH_TOKEN_SECRET`) rather than session cookies alone.
   - This creates a clear boundary: public catalog/auth endpoints vs. protected user/cart/order/payment endpoints.

6. **External service integrations**
   - **Stripe** is the payment provider, configured by `STRIPE_SECRET_KEY`.
   - **Cloudinary** is used for image/media upload, with `backend/config/cloudinary.js` and `backend/middleware/upload.js` indicating product image handling.
   - **Upstash Redis** is used through `UPSTASH_REDIS_URL`, likely for refresh-token storage, token invalidation, or related auth coordination.

7. **Frontend application structure**
   - `frontend/src/main.jsx` bootstraps the SPA and `App.jsx` likely defines routes/layout.
   - Pages are organized by feature: home, product listing/detail, category, cart, login/signup, orders, admin, search, about, and payment outcome pages.
   - Shared UI lives in `frontend/src/components/` for things like header, footer, product cards, cart items, order summary, and theme toggle.

8. **Client-side state management**
   - The frontend uses separate stores under `frontend/src/store/`:
     - `useUserStore` for auth/user state
     - `useProductStore` for catalog state
     - `useCartStore` for cart state
     - `useOrderStore` for order/checkout state
     - `useThemeStore` for UI theme
   - This suggests the app keeps a significant amount of domain state on the client while syncing authoritative data from the API.

9. **Frontend-to-backend communication**
   - `frontend/src/lib/axios.js` centralizes API calls, so the React app talks to the backend through a single HTTP client.
   - Typical flows are:
     - browse/search products → fetch catalog data
     - sign in/up → obtain auth tokens
     - add to cart / checkout → persist or submit order data
     - payment actions → hit Stripe-backed endpoints and then route to confirmation/cancel pages

10. **Checkout and payment flow**
   - The presence of `OrderConfirmationPage.jsx` and `OrderCancel.jsx` strongly indicates a payment redirect flow from Stripe.
   - A likely sequence is: cart review → order creation → Stripe payment session/intent → redirect back to frontend success/cancel route → order status display.

11. **Admin and content management**
   - `AdminPage.jsx` plus `CreateProductForm.jsx` indicate an admin-facing workflow for catalog management.
   - Because image upload exists server-side, product creation likely includes media upload to Cloudinary before saving the product document in MongoDB.

12. **Deployment/runtime clues**
   - The backend is a Node.js API service.
   - The frontend is built with **Vite** and appears styled with **Tailwind/PostCSS**.
   - `frontend/vercel.json` suggests the SPA is deployed separately, likely on Vercel, while the API is deployed as its own Node service.

13. **Architecture diagram takeaway**
   - Draw this as three main zones: **React client**, **Express API**, and **external services**.
   - Inside the API, show feature-based controllers/routes around shared MongoDB models.
   - Connect the API outward to **MongoDB**, **Redis**, **Cloudinary**, and **Stripe**; connect the client to the API via Axios/HTTP.

Main entry points: [`backend/server.js`](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/server.js) (API server), [`backend/controllers/authController.js`](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/controllers/authController.js) (Controllers), [`frontend/src/App.jsx`](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/App.jsx) (App shell), [`frontend/src/pages/Home.jsx`](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/pages/Home.jsx) (Pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_main["App entry<br/>Vite bootstrap<br/>[main.jsx]"]
  node_frontend_app["App shell<br/>Routing/layout<br/>[App.jsx]"]
  node_frontend_http["API client<br/>Axios client<br/>[axios.js]"]
  node_frontend_stores["Client stores<br/>State stores<br/>[useUserStore.jsx]"]
  node_frontend_pages["Pages<br/>[Home.jsx]"]
  node_frontend_ui["Shared UI<br/>Components<br/>[Header.jsx]"]
end

subgraph group_backend["Backend"]
  node_backend_server["API server<br/>Express bootstrap<br/>[server.js]"]
  node_backend_routes_auth["Auth routes<br/>Route module<br/>[AuthRoutes.js]"]
  node_backend_routes_user["User routes<br/>Route module<br/>[UserRoutes.js]"]
  node_backend_routes_product["Product routes<br/>Route module<br/>[ProductRoutes.js]"]
  node_backend_routes_cart["Cart routes<br/>Route module<br/>[CartRoutes.js]"]
  node_backend_routes_order["Order routes<br/>Route module<br/>[OrderRoutes.js]"]
  node_backend_routes_payment["Payment routes<br/>Route module<br/>[PaymentRoutes.js]"]
  node_backend_controllers["Controllers<br/>Domain handlers<br/>[authController.js]"]
  node_backend_models[("Mongo models<br/>Mongoose models<br/>[User.js]")]
  node_backend_middleware["Middleware<br/>Request pipeline<br/>[Auth_Middleware.js]"]
  node_backend_config["Config<br/>[db.js]"]
end

subgraph group_external["External services"]
  node_ext_mongo[("MongoDB<br/>Primary datastore")]
  node_ext_redis[("Redis<br/>Token cache")]
  node_ext_cloudinary(("Cloudinary<br/>Media service"))
  node_ext_stripe(("Stripe<br/>Payments"))
end

node_frontend_main -->|"starts"| node_frontend_app
node_frontend_app -->|"routes"| node_frontend_pages
node_frontend_app -->|"composes"| node_frontend_ui
node_frontend_pages -->|"reads/writes"| node_frontend_stores
node_frontend_pages -->|"calls"| node_frontend_http
node_frontend_stores -->|"syncs"| node_frontend_http
node_frontend_http -->|"HTTP API"| node_backend_server
node_backend_server -->|"mounts"| node_backend_routes_auth
node_backend_server -->|"mounts"| node_backend_routes_user
node_backend_server -->|"mounts"| node_backend_routes_product
node_backend_server -->|"mounts"| node_backend_routes_cart
node_backend_server -->|"mounts"| node_backend_routes_order
node_backend_server -->|"mounts"| node_backend_routes_payment
node_backend_routes_auth -->|"dispatches"| node_backend_controllers
node_backend_routes_user -->|"dispatches"| node_backend_controllers
node_backend_routes_product -->|"dispatches"| node_backend_controllers
node_backend_routes_cart -->|"dispatches"| node_backend_controllers
node_backend_routes_order -->|"dispatches"| node_backend_controllers
node_backend_routes_payment -->|"dispatches"| node_backend_controllers
node_backend_controllers -->|"persists"| node_backend_models
node_backend_server -->|"uses"| node_backend_middleware
node_backend_server -->|"loads"| node_backend_config
node_backend_config -->|"connects"| node_ext_mongo
node_backend_config -->|"connects"| node_ext_redis
node_backend_middleware -->|"uploads"| node_ext_cloudinary
node_backend_controllers -->|"charges"| node_ext_stripe
node_backend_controllers -->|"stores media"| node_ext_cloudinary

click node_frontend_main "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/main.jsx"
click node_frontend_app "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/App.jsx"
click node_frontend_http "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/lib/axios.js"
click node_frontend_stores "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/store/useUserStore.jsx"
click node_frontend_pages "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/pages/Home.jsx"
click node_frontend_ui "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/components/Header.jsx"
click node_backend_server "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/server.js"
click node_backend_routes_auth "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/AuthRoutes.js"
click node_backend_routes_user "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/UserRoutes.js"
click node_backend_routes_product "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/ProductRoutes.js"
click node_backend_routes_cart "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/CartRoutes.js"
click node_backend_routes_order "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/OrderRoutes.js"
click node_backend_routes_payment "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/PaymentRoutes.js"
click node_backend_controllers "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/controllers/authController.js"
click node_backend_models "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/models/User.js"
click node_backend_middleware "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/middleware/Auth_Middleware.js"
click node_backend_config "https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/config/db.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_frontend_main,node_frontend_app,node_frontend_http,node_frontend_stores,node_frontend_pages,node_frontend_ui toneBlue
class node_backend_server,node_backend_routes_auth,node_backend_routes_user,node_backend_routes_product,node_backend_routes_cart,node_backend_routes_order,node_backend_routes_payment,node_backend_controllers,node_backend_models,node_backend_middleware,node_backend_config toneAmber
class node_ext_mongo,node_ext_redis,node_ext_cloudinary,node_ext_stripe toneMint
```

## Components

### Frontend

Vite React SPA

- [App entry](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/main.jsx): Vite bootstrap · Bootstraps the React SPA · `frontend/src/main.jsx`
- [App shell](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/App.jsx): Routing/layout · Defines top-level app structure and routes · `frontend/src/App.jsx`
- [API client](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/lib/axios.js): Axios client · Central HTTP client used by the SPA · `frontend/src/lib/axios.js`
- [Client stores](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/store/useUserStore.jsx): State stores · User, product, cart, order, and theme state · `frontend/src/store/useUserStore.jsx`
- [Pages](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/pages/Home.jsx): Feature pages · Home, catalog, cart, auth, orders, admin, search, and payment result views · `frontend/src/pages/Home.jsx`
- [Shared UI](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/frontend/src/components/Header.jsx): Components · Reusable header, footer, cards, cart items, summaries, and forms · `frontend/src/components/Header.jsx`

### Backend

Express API and domain logic

- [API server](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/server.js): Express bootstrap · Wires middleware, routes, config, and startup · `backend/server.js`
- [Auth routes](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/AuthRoutes.js): Route module · Login, signup, refresh, and logout endpoints · `backend/routes/AuthRoutes.js`
- [User routes](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/UserRoutes.js): Route module · User profile and account endpoints · `backend/routes/UserRoutes.js`
- [Product routes](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/ProductRoutes.js): Route module · Catalog and product CRUD endpoints · `backend/routes/ProductRoutes.js`
- [Cart routes](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/CartRoutes.js): Route module · Cart management endpoints · `backend/routes/CartRoutes.js`
- [Order routes](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/OrderRoutes.js): Route module · Checkout and order lifecycle endpoints · `backend/routes/OrderRoutes.js`
- [Payment routes](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/routes/PaymentRoutes.js): Route module · Payment initiation and result handling endpoints · `backend/routes/PaymentRoutes.js`
- [Controllers](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/controllers/authController.js): Domain handlers · Auth, user, product, cart, order, and payment business logic · `backend/controllers/authController.js`
- [Mongo models](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/models/User.js): Mongoose models · User, Product, and Order documents · `backend/models/User.js`
- [Middleware](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/middleware/Auth_Middleware.js): Request pipeline · Auth protection and upload handling · `backend/middleware/Auth_Middleware.js`
- [Config](https://github.com/dhaneesh7/quickart_mern_deploy/blob/main/backend/config/db.js): Runtime config · Database, Redis, and Cloudinary setup · `backend/config/db.js`

### External services

Persistence, media, and payments

- **MongoDB**: Primary datastore · System of record for users, products, and orders
- **Redis**: Token cache · Upstash-backed Redis used for auth/session coordination
- **Cloudinary**: Media service · Product image upload and storage
- **Stripe**: Payments · Checkout and payment processing

## Connections

- App entry → App shell: starts · SPA entry mounts the app shell
- App shell → Pages: routes · App shell renders feature pages
- App shell → Shared UI: composes · Pages use shared UI components
- Pages → Client stores: reads/writes · Pages coordinate state through client stores
- Pages → API client: calls · Pages fetch and mutate data via the API client
- Client stores → API client: syncs · Stores depend on centralized HTTP calls
- API client → API server: HTTP API · Client talks to the Express API
- API server → Auth routes: mounts · API server mounts auth routes
- API server → User routes: mounts · API server mounts user routes
- API server → Product routes: mounts · API server mounts product routes
- API server → Cart routes: mounts · API server mounts cart routes
- API server → Order routes: mounts · API server mounts order routes
- API server → Payment routes: mounts · API server mounts payment routes
- Auth routes → Controllers: dispatches · Auth routes invoke controller logic
- User routes → Controllers: dispatches · User routes invoke controller logic
- Product routes → Controllers: dispatches · Product routes invoke controller logic
- Cart routes → Controllers: dispatches · Cart routes invoke controller logic
- Order routes → Controllers: dispatches · Order routes invoke controller logic
- Payment routes → Controllers: dispatches · Payment routes invoke controller logic
- Controllers → Mongo models: persists · Domain logic reads and writes MongoDB models
- API server → Middleware: uses · Server applies auth and upload middleware
- API server → Config: loads · Server loads runtime configuration
- Config → MongoDB: connects · Mongo connection setup
- Config → Redis: connects · Redis client setup
- Middleware → Cloudinary: uploads · Upload middleware supports media storage
- Controllers → Stripe: charges · Payment controller integrates with Stripe
- Controllers → Cloudinary: stores media · Product/admin flows use Cloudinary uploads
