A full-stack ecommerce application built with modern web technologies, featuring a React/Next.js frontend, Python FastAPI backend, and MongoDB database.
Database Availability Issue: This application uses MongoDB Atlas on a free tier instance. The cluster may be automatically shut down due to inactivity periods. If you experience any of the following issues:
- Pages fail to load or load indefinitely
- Signup/Sign in buttons don't work
- "500 Internal Server Error" messages
- Product listings not appearing
- Cart or order operations failing
The cause is likely that the MongoDB Atlas cluster has been shut down due to inactivity. This is a known limitation of the free tier. The cluster will automatically restart when accessed again, but there may be a delay (typically 5-10 minutes).
Solution: Contact the project maintainer to restart the cluster or deploy the database to a paid tier or self-hosted MongoDB instance for production use.
- User Authentication: Secure signup, signin, and logout with JWT tokens and OTP verification
- Product Management: Browse, search, and filter products with detailed product pages
- Shopping Cart: Add/remove items, manage quantities with persistent cart storage
- Checkout: Complete checkout process with order creation and management
- User Addresses: Add, edit, and manage multiple delivery addresses
- Order History: View previous orders and track order details
- Location Services: Google Maps integration for location-based features
- Search & Filters: Advanced product search and filtering capabilities
- Deal Pages: Featured deals and promotional products
- User Profiles: Manage user account information and preferences
- Image Upload: Product and user image uploads via Cloudinary
- Responsive Design: Fully responsive UI optimized for all devices
- Framework: Next.js 15
- UI Library: React 19
- Styling: Tailwind CSS
- Database ODM: Mongoose
- Authentication: JWT (Jose), Bcrypt
- APIs:
- Google Maps API
- Cloudinary
- Leaflet/React-Leaflet for maps
- Utilities:
- React Hot Toast for notifications
- Framer Motion for animations
- Zod for validation
- Date-fns for date manipulation
- Framework: FastAPI (Python)
- Database: MongoDB
- Authentication: JWT
- Email: SMTP (Nodemailer integration)
- CORS: Enabled for frontend communication
ecommerce/
βββ backend/
β βββ main.py # FastAPI application entry point
β βββ config.py # Configuration settings
β βββ database.py # Database connection
β βββ models.py # Data models
β βββ auth/ # Authentication module
β β βββ routes.py # Auth endpoints
β β βββ address.py # Address management
β β βββ cart.py # Cart operations
β β βββ utils.py # Helper functions
β βββ __pycache__/
β
βββ website/ # Next.js Frontend Application
β βββ app/
β β βββ page.js # Home page
β β βββ layout.js # Root layout
β β βββ globals.css # Global styles
β β βββ api/ # API routes
β β β βββ auth/ # Authentication endpoints
β β β βββ products/ # Product endpoints
β β β βββ cart/ # Cart endpoints
β β β βββ orders/ # Order endpoints
β β β βββ checkout/ # Checkout endpoints
β β β βββ ...
β β βββ components/ # Reusable React components
β β βββ lib/ # Utility functions and helpers
β β βββ models/ # Mongoose schemas
β β βββ services/ # API service functions
β β βββ [pages]/ # Dynamic pages
β βββ public/ # Static assets
β βββ scripts/
β β βββ seed-products.js # Database seeding script
β β βββ test-mongodb-connection.js
β βββ package.json # Frontend dependencies
β βββ next.config.mjs # Next.js configuration
β βββ README-MONGODB.md # MongoDB setup guide
β
βββ package.json # Root dependencies
βββ README.md # This file
- Node.js (v18 or higher)
- Python 3.9+
- MongoDB (local or Atlas)
- npm or yarn package manager
# Install root dependencies
npm install
# Install frontend dependencies
cd website
npm install
# Install backend dependencies (if using pip)
cd ../backend
pip install -r requirements.txt # Create if needed
cd ../..Create a .env.local file in the website directory:
# MongoDB
MONGO_URI=mongodb://localhost:27017/ecommerce
# Frontend URL
NEXT_PUBLIC_API_URL=http://localhost:8000
# Google Maps (optional)
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your_api_key
# Cloudinary (optional)
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=your_cloud_nameCreate a .env file in the backend directory:
# Email Configuration
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_app_password
# JWT Configuration
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
JWT_ISSUER=your-app-name
JWT_AUDIENCE=your-app-audience
# Frontend URL
FRONTEND_URL=http://localhost:3000
# Debug Mode
DEBUG=False# Seed the database with sample products
cd website
npm run seedTerminal 1 - Start Backend (FastAPI)
cd backend
uvicorn main:app --reload
# API runs on http://localhost:8000Terminal 2 - Start Frontend (Next.js)
cd website
npm run dev
# Frontend runs on http://localhost:3000# Build frontend
cd website
npm run build
npm start
# Backend - Configure for production
cd backend
uvicorn main:app --host 0.0.0.0 --port 8000POST /api/auth/signup- User registrationPOST /api/auth/signin- User loginPOST /api/auth/logout- User logoutPOST /api/auth/send-otp- Send OTP for verificationPOST /api/auth/verify- Verify OTP
GET /api/products- Get all productsGET /api/products/[id]- Get product detailsGET /api/products/featured- Get featured productsGET /api/products/deals- Get deal productsGET /api/products/filters- Get available filtersPOST /api/search- Search products
GET /api/cart- Get cart itemsPOST /api/cart/[action]- Add/update cart itemsDELETE /api/cart/[id]- Remove from cart
GET /api/orders- Get user ordersGET /api/orders/[id]- Get order detailsPOST /api/orders- Create new orderGET /api/orders/previous-products- Get previous order products
GET /api/user/profile- Get user profileGET /api/user/address- Get user addressesPOST /api/user/address- Add new addressPUT /api/user/address- Update address
POST /api/checkout- Process checkoutGET /api/geocode- Geocoding servicePOST /api/upload- Upload files
- Email, password, name
- Phone, addresses
- Order history
- Name, description, price
- Category, stock
- Images, ratings
- Deal information
- User reference
- Product items with quantities
- User reference
- Products ordered
- Delivery address
- Order status
- Total amount
- Street, city, state
- Zip code, country
- Default address flag
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run seed # Seed database with productsuvicorn main:app --reload # Development with hot reload
uvicorn main:app --host 0.0.0.0 # Production- JWT-based authentication with secure token storage
- OTP verification for account security
- Password hashing with bcrypt
- CORS-enabled for frontend communication
- MongoDB integration with Mongoose
- Product filtering and search
- Deal and featured product pages
- Image uploads via Cloudinary
- Real-time cart management
- Address management for delivery
- Order creation and tracking
- Order history with previous purchases
- Google Maps for location services
- Leaflet for interactive maps
- Geolocation support
- Ensure MongoDB is running locally or check Atlas credentials
- Verify
MONGO_URIin.env.local - Run test script:
node scripts/test-mongodb-connection.js
- Verify backend CORS configuration allows
http://localhost:3000 - Check
FRONTEND_URLin backend.env
- Ensure
SECRET_KEYmatches between frontend and backend - Check JWT token expiration settings
- Verify SMTP credentials for email features
- Verify Cloudinary credentials in environment
- Check file size limits in configuration
This project is private and for educational/development purposes.
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit pull request
For issues or questions, please refer to the documentation or create an issue in the repository.
- Your Name - Initial work and development
- Next.js documentation and community
- FastAPI documentation
- MongoDB Atlas for database hosting
- Google Maps API
- Cloudinary for image hosting
Built with β€οΈ for learning and development. Version: 0.1.0 | Last Updated: January 2026







