Skip to content

valiantProgrammer/E-commerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ecommerce Platform

A full-stack ecommerce application built with modern web technologies, featuring a React/Next.js frontend, Python FastAPI backend, and MongoDB database.


⚠️ IMPORTANT CAUTION

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.


πŸš€ Features

  • 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

πŸ“Έ Screenshots

Application Overview

Screenshot 1

Screenshot 2

Screenshot 3

Screenshot 4

Screenshot 5

Screenshot 6

Screenshot 7

Screenshot 8

πŸ› οΈ Tech Stack

Frontend Technologies

Next.js React Tailwind CSS JavaScript

Backend Technologies

FastAPI Python

Database

MongoDB Mongoose

Authentication & Security

JWT Bcrypt

APIs & Services

Google Maps Cloudinary

Additional Libraries

Framer Motion Zod React Hot Toast


Detailed Tech Stack

Frontend

  • 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

Backend

  • Framework: FastAPI (Python)
  • Database: MongoDB
  • Authentication: JWT
  • Email: SMTP (Nodemailer integration)
  • CORS: Enabled for frontend communication

πŸ“ Project Structure

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

βš™οΈ Installation & Setup

Prerequisites

  • Node.js (v18 or higher)
  • Python 3.9+
  • MongoDB (local or Atlas)
  • npm or yarn package manager

1. Clone & Install Dependencies

# 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 ../..

2. Environment Configuration

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_name

Create 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

3. Database Setup

# Seed the database with sample products
cd website
npm run seed

πŸš€ Running the Application

Development Mode

Terminal 1 - Start Backend (FastAPI)

cd backend
uvicorn main:app --reload
# API runs on http://localhost:8000

Terminal 2 - Start Frontend (Next.js)

cd website
npm run dev
# Frontend runs on http://localhost:3000

Production Build

# Build frontend
cd website
npm run build
npm start

# Backend - Configure for production
cd backend
uvicorn main:app --host 0.0.0.0 --port 8000

πŸ“š API Documentation

Authentication Endpoints

  • POST /api/auth/signup - User registration
  • POST /api/auth/signin - User login
  • POST /api/auth/logout - User logout
  • POST /api/auth/send-otp - Send OTP for verification
  • POST /api/auth/verify - Verify OTP

Product Endpoints

  • GET /api/products - Get all products
  • GET /api/products/[id] - Get product details
  • GET /api/products/featured - Get featured products
  • GET /api/products/deals - Get deal products
  • GET /api/products/filters - Get available filters
  • POST /api/search - Search products

Cart Endpoints

  • GET /api/cart - Get cart items
  • POST /api/cart/[action] - Add/update cart items
  • DELETE /api/cart/[id] - Remove from cart

Order Endpoints

  • GET /api/orders - Get user orders
  • GET /api/orders/[id] - Get order details
  • POST /api/orders - Create new order
  • GET /api/orders/previous-products - Get previous order products

User Endpoints

  • GET /api/user/profile - Get user profile
  • GET /api/user/address - Get user addresses
  • POST /api/user/address - Add new address
  • PUT /api/user/address - Update address

Other Endpoints

  • POST /api/checkout - Process checkout
  • GET /api/geocode - Geocoding service
  • POST /api/upload - Upload files

πŸ—„οΈ Database Models

User

  • Email, password, name
  • Phone, addresses
  • Order history

Product

  • Name, description, price
  • Category, stock
  • Images, ratings
  • Deal information

Cart

  • User reference
  • Product items with quantities

Order

  • User reference
  • Products ordered
  • Delivery address
  • Order status
  • Total amount

Address

  • Street, city, state
  • Zip code, country
  • Default address flag

πŸ”§ Available Scripts

Frontend

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 products

Backend

uvicorn main:app --reload          # Development with hot reload
uvicorn main:app --host 0.0.0.0    # Production

πŸ“ Key Features Implementation

Authentication

  • JWT-based authentication with secure token storage
  • OTP verification for account security
  • Password hashing with bcrypt
  • CORS-enabled for frontend communication

Product Management

  • MongoDB integration with Mongoose
  • Product filtering and search
  • Deal and featured product pages
  • Image uploads via Cloudinary

Shopping Experience

  • Real-time cart management
  • Address management for delivery
  • Order creation and tracking
  • Order history with previous purchases

Maps Integration

  • Google Maps for location services
  • Leaflet for interactive maps
  • Geolocation support

πŸ› Troubleshooting

MongoDB Connection Issues

  • Ensure MongoDB is running locally or check Atlas credentials
  • Verify MONGO_URI in .env.local
  • Run test script: node scripts/test-mongodb-connection.js

CORS Errors

  • Verify backend CORS configuration allows http://localhost:3000
  • Check FRONTEND_URL in backend .env

Authentication Issues

  • Ensure SECRET_KEY matches between frontend and backend
  • Check JWT token expiration settings
  • Verify SMTP credentials for email features

Image Upload Issues

  • Verify Cloudinary credentials in environment
  • Check file size limits in configuration

πŸ“„ License

This project is private and for educational/development purposes.

🀝 Contributing

  1. Create a feature branch
  2. Make your changes
  3. Test thoroughly
  4. Submit pull request

πŸ“§ Support

For issues or questions, please refer to the documentation or create an issue in the repository.

πŸ‘₯ Authors

  • Your Name - Initial work and development

πŸ™ Acknowledgments

  • Next.js documentation and community
  • FastAPI documentation
  • MongoDB Atlas for database hosting
  • Google Maps API
  • Cloudinary for image hosting

Additional Resources


Built with ❀️ for learning and development. Version: 0.1.0 | Last Updated: January 2026

About

A full-stack e-commerce application with Python backend API and Next.js frontend. Features include secure user authentication with email OTP verification, comprehensive product catalog with search and filtering, shopping cart functionality, complete checkout system, order management, and responsive mobile design. Database-driven with MongoDB.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors