A comprehensive e-commerce platform for cake and bakery products with integrated delivery management system.
- ✨ Framer Motion Animations: Added smooth animations to ProductSlider with hover effects, pulse badges, and interactive elements
- 🔗 Database-Connected Slider: ProductSlider now fetches products dynamically from database via API
- 🎨 Enhanced UI: Quick action buttons (cart/wishlist), shimmer loading effects, and improved hover interactions
- 📦 Package Updates: Updated to ESLint v9 and latest eslint-config-next
- 🔧 Admin Panel Fix: Fixed model import symlinks, resolved TypeScript errors
TopCup is a full-stack e-commerce ecosystem consisting of three interconnected applications:
- Customer Application (Port 3000) - Product browsing, cart, and checkout
- Admin Panel (Port 5001) - Complete management dashboard
- Delivery Partner Dashboard (Port 5002) - Delivery execution platform
TopCup consists of three independent Next.js applications sharing a single MongoDB database.
┌─────────────────────────────────────────────────────────────────────┐
│ TopCup E-Commerce Platform │
└─────────────────────────────────────────────────────────────────────┘
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Customer App │ │ Admin Panel │ │ Delivery Dash │
│ Port: 3000 │ │ Port: 5001 │ │ Port: 5002 │
├──────────────────┤ ├──────────────────┤ ├──────────────────┤
│ • Browse Products│ │ • Manage Products│ │ • View Assigned │
│ • Add to Cart │ │ • Manage Users │ │ Orders │
│ • Place Orders │ │ • Manage Orders │ │ • Update Status │
│ • Track Delivery │ │ • Assign Delivery│ │ • Track Earnings │
│ • User Auth │ │ • Analytics │ │ • View History │
└────────┬─────────┘ └────────┬─────────┘ └────────┬─────────┘
│ │ │
│ ┌───────────────────┴───────────────────┐ │
│ │ │ │
└───┼──────────► API Routes ◄──────────────┼───┘
│ │
└───────────────┬───────────────────────┘
│
┌────────▼─────────┐
│ MongoDB Atlas │
│ or Local MongoDB │
├───────────────────┤
│ Collections: │
│ • users │
│ • products │
│ • orders │
│ • deliverypartners│
│ • admins │
└───────────────────┘
Data Flow:
1. Customer places order → Stored in MongoDB
2. Admin assigns order to delivery partner → Order updated
3. Delivery partner updates status → Customer sees real-time updates
4. All apps share same database for consistency
| Component | Customer App | Admin Panel | Delivery Dashboard |
|---|---|---|---|
| Framework | Next.js 14 | Next.js 14 | Next.js 14 |
| Styling | Tailwind CSS | Tailwind CSS | Tailwind CSS |
| State | Zustand | Zustand | React Hooks |
| Database | MongoDB (Mongoose) | MongoDB (Mongoose) | MongoDB (Mongoose) |
| Auth | NextAuth.js | Custom Auth | Custom Auth |
| Animations | Framer Motion | Framer Motion | - |
- Next.js 14 - React framework with App Router
- TypeScript - Type safety
- Tailwind CSS - Styling
- Framer Motion - Animations
- Lucide React - Icons
- Zustand - State management
- Node.js - Runtime
- MongoDB - Database
- Mongoose - ODM
- bcryptjs - Password hashing
- Next.js API Routes - Backend endpoints
Follow these steps to get all three applications running on your local machine.
Ensure you have the following installed:
# Check versions
node --version # Should be >= 18.0.0
npm --version # Should be >= 9.0.0git clone https://github.com/gaurav620/TopCup.git
cd TopCupChoose one of the following options:
Option A: Local MongoDB (Recommended for Development)
# macOS
brew tap mongodb/brew
brew install mongodb-community@6.0
brew services start mongodb-community@6.0
# Verify MongoDB is running
brew services list | grep mongodbOption B: MongoDB Atlas (Cloud)
- Visit MongoDB Atlas
- Create a free cluster
- Get your connection string (format:
mongodb+srv://username:password@cluster.mongodb.net/topcup)
Install dependencies for all three applications:
# Customer App (root directory)
npm install
# Admin Panel
cd admin-panel
npm install
cd ..
# Delivery Dashboard
cd delivery-dashboard
npm install
cd ..Create .env.local files in each directory:
Root Directory .env.local (Customer App):
# Database
MONGODB_URI=mongodb://localhost:27017/topcup
# Authentication
NEXTAUTH_SECRET=your-random-secret-key-min-32-chars
NEXTAUTH_URL=http://localhost:3000
# Optional: Cloudinary for image uploads
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=your-cloud-name
NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET=your-upload-presetadmin-panel/.env.local (Admin Panel):
# Database
MONGODB_URI=mongodb://localhost:27017/topcup
# Authentication
NEXTAUTH_SECRET=admin-panel-secret-key-min-32-chars
NEXTAUTH_URL=http://localhost:5001delivery-dashboard/.env.local (Delivery Dashboard):
# Database
MONGODB_URI=mongodb://localhost:27017/topcup
# Authentication
NEXTAUTH_SECRET=delivery-dashboard-secret-key-min-32-chars
NEXTAUTH_URL=http://localhost:5002Tip
Generate secure secrets using: openssl rand -base64 32
Test that MongoDB is accessible:
# If using local MongoDB, connect to verify
mongosh
# You should see: "Connected to: mongodb://127.0.0.1:27017"
# Type 'exit' to quit
# Or check if process is running
ps aux | grep mongodOpen three separate terminal windows and run each application:
Terminal 1 - Customer App:
cd TopCup
npm run dev
# ✓ Ready on http://localhost:3000Terminal 2 - Admin Panel:
cd TopCup/admin-panel
npm run dev
# ✓ Ready on http://localhost:5001Terminal 3 - Delivery Dashboard:
cd TopCup/delivery-dashboard
npm run dev
# ✓ Ready on http://localhost:5002Open your browser and navigate to:
- Customer App: http://localhost:3000
- Admin Panel: http://localhost:5001
- Delivery Dashboard: http://localhost:5002
- Customer App: http://localhost:3000
- Admin Panel: http://localhost:5001
- Delivery Dashboard: http://localhost:5002
- Email:
admin - Password:
admin123
- First, create a delivery partner via Admin Panel
- Then use those credentials to login
- 🏠 Home Page - Hero section with featured products
- 🎂 Product Catalog - Browse cakes, combos, gifts
- 🛒 Shopping Cart - Add to cart with quantity management
- ❤️ Wishlist - Save favorite products
- 💳 Checkout - Complete order placement
- 👤 User Authentication - Sign up and login
- 📊 Dashboard - Overview with key metrics
- 👥 User Management - View and manage customers
- 📦 Product Management - CRUD operations for products
- 🛍️ Order Management - Process and track all orders
- 🚴 Delivery Partners - Manage delivery team
- 📈 Analytics - Sales and performance insights
- 🏍️ Active Orders - View assigned deliveries
- ✅ Order Status - Update pickup/delivery status
- 📜 Delivery History - Completed deliveries
- 📊 Performance Stats - Earnings and ratings
- 👤 Profile - Update personal information
{
name: String,
email: String (unique),
password: String (hashed),
phone: String,
role: String (customer/admin),
addresses: Array
}{
name: String,
description: String,
price: Number,
category: String,
image: String,
stock: Number,
rating: Number
}{
orderId: String (unique),
customer: Object,
items: Array,
totalAmount: Number,
deliveryAddress: Object,
status: String,
deliveryPartner: ObjectId (ref),
deliveryStatus: String,
paymentMethod: String,
timestamps
}{
partnerId: String (unique),
name: String,
email: String (unique),
password: String (hashed),
phone: String,
vehicleType: String,
vehicleNumber: String,
status: String,
totalDeliveries: Number,
totalEarnings: Number,
rating: Number
}- Customer places order → Order created in database
- Admin assigns to delivery partner → Order status: "assigned"
- Partner receives notification → Views in dashboard
- Partner picks up order → Status: "picked-up"
- Partner delivers → Status: "delivered", earnings updated
- Customer sees delivery status → Order complete
TopCup/
├── app/ # Customer app pages
├── src/
│ ├── components/ # Reusable UI components
│ └── store/ # Zustand state management
├── models/ # MongoDB models
├── lib/ # Database utilities
├── admin-panel/
│ └── src/
│ └── app/ # Admin pages & API routes
├── delivery-dashboard/
│ └── app/ # Delivery dashboard pages
├── public/ # Static assets
└── README.md
GET /api/products- Fetch all productsPOST /api/orders- Create new orderGET /api/orders/:id- Get order details
GET /api/delivery-partners- List all partnersPOST /api/delivery-partners- Create partnerPUT /api/orders/:id/assign- Assign order
POST /api/auth/login- Partner loginGET /api/delivery/orders- Get assigned ordersPUT /api/delivery/orders/:id/status- Update status
- Create Delivery Partner:
# Go to http://localhost:5001
# Login with admin/admin123
# Navigate to Delivery Partners → Add New Partner- Create Test Order:
# Use MongoDB Compass or create via customer app- Assign Order:
# Admin Panel → Orders → Assign to Partner- Update Status:
# Delivery Dashboard → Login → Update order status- Modern UI - Clean, professional design
- Responsive - Mobile-first approach
- Animations - Smooth transitions with Framer Motion
- Consistent - Unified design system across all apps
- Accessible - WCAG compliant
- Password hashing with bcryptjs
- Environment variables for sensitive data
- Input validation on all forms
- Protected API routes
- Secure authentication flow
- Real-time notifications (Socket.io)
- Payment gateway integration (Stripe/Razorpay)
- GPS tracking for delivery
- Customer reviews and ratings
- Email notifications
- SMS alerts
- Multi-language support
- Dark mode
MIT License - feel free to use this project for learning or commercial purposes.
Gaurav Kumar Mehta
- GitHub: @gaurav620
- Next.js team for the amazing framework
- MongoDB for the database
- Vercel for hosting capabilities
- Open source community
For issues and questions:
- Check existing issues on GitHub
- Create a new issue with detailed description
- Contact: gauravkumarmehta06@gmail.com
Error: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
Solutions:
# Check if MongoDB is running
brew services list | grep mongodb
# Start MongoDB if not running
brew services start mongodb-community@6.0
# Check MongoDB logs
tail -f /usr/local/var/log/mongodb/mongo.log
# Restart MongoDB
brew services restart mongodb-community@6.0Error: Error: listen EADDRINUSE: address already in use :::3000
Solutions:
# Find process using the port
lsof -i :3000
lsof -i :5001
lsof -i :5002
# Kill the process (replace PID with actual process ID)
kill -9 <PID>
# Or use different ports by editing package.json scriptsProblem: Application can't connect to database or shows undefined values
Solutions:
-
Ensure
.env.localfiles are in the correct directories:TopCup/.env.local(Customer App)TopCup/admin-panel/.env.local(Admin Panel)TopCup/delivery-dashboard/.env.local(Delivery Dashboard)
-
Restart the dev server after creating/modifying
.env.local -
Check file is not named
.env.local.txtor similar -
Verify no syntax errors in
.env.local(no spaces around=)
Error: Module not found: Can't resolve 'xyz'
Solutions:
# Delete node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# For admin panel
cd admin-panel
rm -rf node_modules package-lock.json
npm install
cd ..
# For delivery dashboard
cd delivery-dashboard
rm -rf node_modules package-lock.json
npm install
cd ..
# Clear Next.js cache
rm -rf .next
cd admin-panel && rm -rf .next && cd ..
cd delivery-dashboard && rm -rf .next && cd ..Error: TypeScript or ESLint errors during build
Solutions:
# Run build to see exact errors
npm run build
# Check TypeScript errors
npx tsc --noEmit
# Fix common issues
# - Missing dependencies: npm install
# - Outdated packages: npm update
# - Cache issues: rm -rf .next && npm run devProblem: Admin panel or apps show no data
Solutions:
-
Verify MongoDB connection string is correct
-
Check if data exists:
mongosh use topcup db.products.count() db.users.count() db.orders.count() exit
-
Seed initial data via admin panel or MongoDB Compass
Problem: Can't login with default credentials
Solutions:
-
Default credentials (for development):
- Email:
admin - Password:
admin123
- Email:
-
If still failing, check console for errors
-
Verify
NEXTAUTH_SECRETis set inadmin-panel/.env.local -
Clear browser cookies and localStorage
# Check all required services
node --version # Should be >= 18
npm --version # Should be >= 9
mongosh --version # MongoDB shell
brew services list # Check MongoDB status
# Test database connection
mongosh mongodb://localhost:27017/topcup --eval "db.stats()"
# Check if apps are running
curl http://localhost:3000 # Customer App
curl http://localhost:5001 # Admin Panel
curl http://localhost:5002 # Delivery DashboardIf you encounter issues not covered here:
- Check Logs: Look at terminal output for error messages
- GitHub Issues: Create an issue with:
- Error message
- Steps to reproduce
- Your environment (OS, Node version, MongoDB version)
- Contact: gauravkumarmehta06@gmail.com
⭐ If you find this project helpful, please give it a star on GitHub!
Happy Coding! 🚀