A complete MERN stack application for a sweet shop e-commerce platform with customer and admin interfaces.
- β Home Page - Banner, featured sweets, categories, shop story
- β Product Listing - Browse with filters (category, price, search)
- β Product Details - Image gallery, description, ingredients, add to cart
- β Shopping Cart - Add, update quantity, remove items
- β Checkout - COD payment, delivery/pickup options, order summary
- β Order Tracking - View order history with status timeline
- β User Authentication - Sign up, login with JWT
- β Contact/Feedback - Customer inquiry form
- β Dashboard - Sales overview, charts (Recharts), statistics
- β Product Management - Create, Read, Update, Delete products
- β Order Management - View and update order statuses
- β Customer Management - View all registered customers
- β Rewards Management - Create, Read, Update, Delete SweetCoins
- Node.js + Express.js
- MongoDB with Mongoose
- JWT Authentication
- bcryptjs for password hashing
- CORS enabled
- React 19
- Vite
- React Router
- Tailwind CSS
- Axios for API calls
- Recharts for graphs
- React Icons
arvind-sweets/
βββ backend/
β βββ src/
β β βββ config/ # DB, Redis configs
β β βββ models/ # Mongoose schemas
β β βββ controllers/ # Business logic
β β βββ routes/ # API routes
β β βββ middleware/ # Auth, error handling
β β βββ utils/ # Helpers
β β βββ app.js # Express config
β β βββ server.js # Entry point
β βββ package.json
β
βββ frontend/
βββ src/
β βββ components/ # Reusable components
β βββ pages/ # Page components
β βββ context/ # React Context (Auth, Cart)
β βββ services/ # API service functions
β βββ App.jsx # Main app component
β βββ main.jsx # Entry point
βββ package.json
- Node.js (v14 or higher)
- npm
- MongoDB (local or MongoDB Atlas)
-
Navigate to backend:
cd backend -
Install dependencies:
npm install
-
Create
.envfile:MONGO_URI=mongodb://localhost:27017/arvind-sweets JWT_SECRET=your-secret-key-here PORT=5000 # Google OAuth (required for "Continue with Google") GOOGLE_CLIENT_ID=xxxxxxxxxxxx.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=xxxxxxxxxxxx GOOGLE_CALLBACK_URL=http://localhost:5000/api/auth/google/callback # Where backend redirects after Google login FRONTEND_URL=http://localhost:5173
-
Start the server:
npm run dev
Backend runs on
http://localhost:5000
-
Navigate to frontend:
cd frontend -
Install dependencies:
npm install
-
Start the dev server:
npm run dev
Frontend runs on
http://localhost:5173
GET /api/products- Get all products (with filters)GET /api/products/:id- Get product by IDPOST /api/products- Create product (Admin)PUT /api/products/:id- Update product (Admin)DELETE /api/products/:id- Delete product (Admin)
POST /api/users/register- Register new userPOST /api/users/login- Login userGET /api/users/profile- Get user profile (Protected)PUT /api/users/profile- Update profile (Protected)GET /api/users- Get all users (Admin)
GET /api/auth/google- Start Google OAuthGET /api/auth/google/callback- OAuth callback (redirects to frontend with?token=)
This project uses Google OAuth 2.0 (Passport) on the backend and mints the same JWT as normal login.
- Go to Google Cloud Console β APIs & Services β Credentials
- Create OAuth client ID β Web application
- Configure:
- Authorized JavaScript origins:
http://localhost:5173https://arvindsweets.com
- Authorized redirect URIs:
http://localhost:5000/api/auth/google/callbackhttps://arvind-sweets.onrender.com/api/auth/google/callback
- Authorized JavaScript origins:
Note: In the OAuth consent screen, add arvindsweets.com under Authorized domains.
In backend/.env:
GOOGLE_CLIENT_ID=xxxxxxxxxxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=xxxxxxxxxxxx
GOOGLE_CALLBACK_URL=http://localhost:5000/api/auth/google/callback
FRONTEND_URL=http://localhost:5173
# Optional: allow both local + production redirects safely
FRONTEND_URLS=http://localhost:5173,https://arvindsweets.comOn Render (backend):
GOOGLE_CALLBACK_URL=https://arvind-sweets.onrender.com/api/auth/google/callback
FRONTEND_URL=https://arvindsweets.com
FRONTEND_URLS=http://localhost:5173,https://arvindsweets.comIf your frontend is not using a dev proxy, set:
VITE_BACKEND_URL=http://localhost:5000For production (arvindsweets.com), set:
VITE_BACKEND_URL=https://arvind-sweets.onrender.comOnly verified Google emails are allowed. If Google returns an unverified email, login fails and the user is redirected back with an error.
- Backend env:
GOOGLE_CALLBACK_URL=http://localhost:5000/api/auth/google/callbackFRONTEND_URL=http://localhost:5173
- Run backend:
cd backend && npm run server - Run frontend:
cd frontend && npm run dev - Open
http://localhost:5173/loginβ Continue with Google
- Ensure Render env:
GOOGLE_CALLBACK_URL=https://arvind-sweets.onrender.com/api/auth/google/callbackFRONTEND_URL=https://arvindsweets.com
- Open
https://arvindsweets.com/loginβ Continue with Google
Open this URL in your browser:
https://arvind-sweets.onrender.com/api/auth/google?redirect=http://localhost:5173
This is safe because redirects are allowlisted via FRONTEND_URLS.
POST /api/orders- Create order (Protected)GET /api/orders/myorders- Get user orders (Protected)GET /api/orders/:id- Get order by ID (Protected)GET /api/orders- Get all orders (Admin)PUT /api/orders/:id/status- Update order status (Admin)
To create an admin user, you'll need to manually set role: 'admin' in the MongoDB database for a user account.
- Product images: Currently supports URL strings. For production, implement file upload with Multer.
- Password reset: Frontend UI exists, backend implementation can be added.
- Reports download: Dashboard shows data, CSV/PDF export can be added.
- Responsive design with Tailwind CSS
- Modern card-based layouts
- Loading states and error handling
- Toast notifications for actions
- Smooth transitions and hover effects
- express, mongoose, cors, dotenv
- bcryptjs, jsonwebtoken
- nodemon (dev)
- react, react-dom, react-router-dom
- axios, tailwindcss
- recharts, react-icons
- vite, @vitejs/plugin-react
Built with β€οΈ for Arvind Sweets