A minimal e‑commerce project with separate frontend, admin and backend apps:
- Frontend: customer store built with React + Vite (frontend/src/App.jsx)
- Admin: admin panel built with React + Vite (admin/src/App.jsx)
- Backend: Express API and payment integrations (backend/server.js)
Quick links
- Backend entry: backend/server.js
- Backend routes: backend/routes/productRoute.js, backend/routes/orderRoute.js
- Important backend controllers/models: backend/controllers/orderController.js, backend/models/productModel.js, backend/models/orderModel.js, backend/models/userModel.js
- Backend middleware/config: backend/middleware/auth.js, backend/config/mongodb.js, backend/config/cloudinary.js
- Frontend context:
ShopContext(frontend/src/context/ShopContext.jsx) — holds cart, token, backendUrl and helpers. - Frontend payment & order flow: frontend/src/pages/PlaceOrder.jsx, frontend/src/pages/Verify.jsx, frontend/src/pages/Orders.jsx
- Assets + seed products used by the UI: frontend/src/assets/assets.js
- Common UI pages/components: frontend/src/pages/Cart.jsx, frontend/src/pages/Product.jsx
Prerequisites
- Node.js (16+ recommended)
- MongoDB (or a MongoDB Atlas URI)
- Cloudinary account for image uploads (optional for admin image upload)
- Stripe and Razorpay credentials if testing payments
Environment
- Backend env: backend/.env — set MONGODB_URI, JWT_SECRET, STRIPE_SECRET_KEY, RAZORPAY_KEY_ID/SECRET, CLOUDINARY_* etc.
- Frontend env: frontend/.env — set VITE_BACKEND_URL, VITE_RAZORPAY_KEY_ID etc.
- Admin env: admin/.env — set VITE_BACKEND_URL (used by admin panel)
Run locally (recommended)
-
Install & start backend
- cd backend
- npm install
- Start: node server.js (or npm run dev if script exists)
Backend exposes API endpoints (see backend/server.js).
-
Install & start frontend store
- cd frontend
- npm install
- npm run dev (Vite) — app uses
ShopContextand routes in frontend/src/App.jsx
-
Install & start admin panel
- cd admin
- npm install
- npm run dev (Vite)
Notes
- Admin API calls require the admin token saved in localStorage (handled in admin/src/App.jsx).
- The backend protects user routes with auth middleware (backend/middleware/auth.js) and admin routes with adminAuth.
- Product schema: backend/models/productModel.js. Orders use backend/models/orderModel.js.
- Frontend product data and images come from frontend/src/assets/assets.js when not using dynamic backend product list.
Deployment
- Backend: host on a Node-capable host (Heroku, Vercel Serverless with adaptation, digitalocean). Ensure env variables and MongoDB are configured.
- Frontend/Admin: static builds (Vite) can be deployed to Vercel, Netlify, or similar. Update VITE_BACKEND_URL accordingly.
Troubleshooting
- DB connection logs: backend/config/mongodb.js
- Cloudinary setup: backend/config/cloudinary.js
- If orders/payments fail, inspect backend/controllers/orderController.js for Stripe/Razorpay flows.
Contributing
- Follow existing structure: frontend, admin, backend.
- Frontend uses React + context (frontend/src/context/ShopContext.jsx).
- Keep API shape compatible with backend routes in backend/routes.
License
- Project scaffold — add license file if needed.