How dhaneesh7/quickart_mern_deploy works
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: server.js API server · authController.js Controllers · App.jsx App shell · Home.jsx Pages
Components 21
Frontend
Vite React SPA
- App entry · Bootstraps the React SPA
frontend/src/main.jsx - App shell · Defines top-level app structure and routes
frontend/src/App.jsx - API client · Central HTTP client used by the SPA
frontend/src/lib/axios.js - Client stores · User, product, cart, order, and theme state
frontend/src/store/useUserStore.jsx - Pages · Home, catalog, cart, auth, orders, admin, search, and payment result views
frontend/src/pages/Home.jsx - Shared UI · Reusable header, footer, cards, cart items, summaries, and forms
frontend/src/components/Header.jsx
Backend
Express API and domain logic
- API server · Wires middleware, routes, config, and startup
backend/server.js - Auth routes · Login, signup, refresh, and logout endpoints
backend/routes/AuthRoutes.js - User routes · User profile and account endpoints
backend/routes/UserRoutes.js - Product routes · Catalog and product CRUD endpoints
backend/routes/ProductRoutes.js - Cart routes · Cart management endpoints
backend/routes/CartRoutes.js - Order routes · Checkout and order lifecycle endpoints
backend/routes/OrderRoutes.js - Payment routes · Payment initiation and result handling endpoints
backend/routes/PaymentRoutes.js - Controllers · Auth, user, product, cart, order, and payment business logic
backend/controllers/authController.js - Mongo models · User, Product, and Order documents
backend/models/User.js - Middleware · Auth protection and upload handling
backend/middleware/Auth_Middleware.js - Config · Database, Redis, and Cloudinary setup
backend/config/db.js
External services
Persistence, media, and payments
- MongoDB · System of record for users, products, and orders
- Redis · Upstash-backed Redis used for auth/session coordination
- Cloudinary · Product image upload and storage
- Stripe · Checkout and payment processing
Connections 27
- 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