A full-stack MERN (MongoDB, Express.js, React.js, Node.js) application for selling and managing cakes with role-based access control for customers, sellers, and administrators.
Frontend: https://cake-selling-app.vercel.app/
Backend API: https://cake-selling-app.onrender.com/api
- Browse and search cakes
- Add cakes to wishlist and cart
- Place orders with secure checkout
- View order history and tracking
- User profile management
- Real-time notifications
- Upload and manage cake listings
- Track orders and sales
- Manage inventory
- View sales analytics
- Order fulfillment
- User management (customers, sellers)
- System-wide analytics and reports
- Content moderation
- Platform configuration
- JWT-based authentication
- Role-based access control
- Protected routes
- Secure API endpoints
- Password encryption
- React 19 - UI library
- Vite - Build tool and dev server
- React Router DOM - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- Axios - HTTP client
- React Hook Form - Form handling
- Zod - Schema validation
- Sonner - Toast notifications
- Recharts - Data visualization
- Framer Motion - Animations
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- bcryptjs - Password hashing
- Multer - File uploads
- Sharp - Image processing
- Joi - Validation
- CORS - Cross-origin resource sharing
Cake-Selling_app/
βββ client/ # React frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ context/ # React context providers
β β βββ pages/ # Page components
β β βββ utils/ # Utility functions
β β βββ assets/ # Static assets
β βββ public/ # Public assets
β βββ package.json
βββ server/ # Node.js backend
β βββ controllers/ # Route controllers
β βββ models/ # MongoDB schemas
β βββ routes/ # API routes
β βββ middleware/ # Custom middleware
β βββ services/ # Business logic
β βββ validations/ # Input validation
β βββ uploads/ # File uploads
β βββ package.json
βββ vercel.json # Vercel deployment configuration
βββ README.md
- Node.js (v18 or higher)
- npm or pnpm (recommended)
- MongoDB (local or cloud)
-
Clone the repository
git clone <repository-url> cd Cake-Selling_app
-
Install dependencies
# Install frontend dependencies cd client pnpm install # Install backend dependencies cd ../server pnpm install
-
Environment Setup
Create
.envfile in theserverdirectory:NODE_ENV=development PORT=5000 MONGO_URI_PRODUCTION=your_mongodb_connection_string JWT_SECRET=your_jwt_secret_key
-
Start Development Servers
Terminal 1 - Backend:
cd server pnpm devBackend will run on: http://localhost:5000
Terminal 2 - Frontend:
cd client pnpm devFrontend will run on: http://localhost:5173
pnpm dev # Start development server
pnpm build # Build for production
pnpm preview # Preview production build
pnpm lint # Run ESLintpnpm dev # Start development server with nodemon
pnpm start # Start production serverPOST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/me- Get current user
GET /api/cakes- Get all cakesGET /api/cakes/:id- Get cake by IDPOST /api/cakes- Create new cake (seller only)PUT /api/cakes/:id- Update cake (seller only)DELETE /api/cakes/:id- Delete cake (seller only)
GET /api/cart- Get user's cartPOST /api/cart/add- Add item to cartPUT /api/cart/update/:id- Update cart itemDELETE /api/cart/remove/:id- Remove item from cartDELETE /api/cart/clear- Clear cart
GET /api/orders- Get user's ordersPOST /api/orders- Create new orderPUT /api/orders/:id/status- Update order status
GET /api/wishlist- Get user's wishlistPOST /api/wishlist/add- Add to wishlistDELETE /api/wishlist/remove/:id- Remove from wishlist
The application implements role-based routing using React Router's <Navigate /> component:
- Customer Routes:
/wishlist,/cart,/checkout,/orders - Seller Routes:
/cakes/my,/orders/seller - Admin Routes:
/dashboard/admin - Shared Routes:
/profile,/dashboard
{
name: String,
email: String,
password: String,
role: String, // 'customer', 'seller', 'admin'
avatar: String
}{
name: String,
description: String,
price: Number,
category: String,
images: [String],
seller: ObjectId,
stock: Number
}{
user: ObjectId,
items: [{
cake: ObjectId,
quantity: Number,
price: Number
}],
total: Number,
status: String,
shippingAddress: Object
}The project includes a vercel.json configuration file that handles:
- Client-side routing - All routes redirect to
index.htmlfor React Router - Build settings - Automatic build configuration
- Output directory - Proper dist folder configuration
- Connect your GitHub repository to Vercel
- Vercel will automatically detect the configuration from
vercel.json - Set environment variables in Vercel dashboard:
NODE_ENV=production VITE_API_URL=https://cake-selling-app.onrender.com/api - Deploy
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
],
"buildCommand": "cd client && pnpm build",
"outputDirectory": "client/dist",
"installCommand": "cd client && pnpm install"
}- Connect your GitHub repository to Render
- Set build command:
cd server && pnpm install - Set start command:
cd server && pnpm start - Add environment variables
- Deploy
NODE_ENV=production
PORT=5000
MONGO_URI_PRODUCTION=mongodb+srv://...
JWT_SECRET=your_secret_keyThe frontend automatically detects the environment and uses the appropriate API URL:
- Development:
http://localhost:5000/api - Production:
https://cake-selling-app.onrender.com/api
- Register/Login - Create an account or sign in
- Browse Cakes - View available cakes with filters
- Add to Cart/Wishlist - Save items for later
- Checkout - Complete purchase with shipping details
- Track Orders - Monitor order status and history
- Register as Seller - Create seller account
- Upload Cakes - Add cake listings with images
- Manage Inventory - Update stock and prices
- Process Orders - Fulfill customer orders
- View Analytics - Track sales performance
- User Management - Oversee customers and sellers
- Content Moderation - Review and approve listings
- System Analytics - Monitor platform performance
- Configuration - Manage platform settings
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Contact the development team
- React - UI library
- Express.js - Web framework
- MongoDB - Database
- Tailwind CSS - CSS framework
- Vercel - Frontend hosting
- Render - Backend hosting
Happy Baking! π°