A modern, full-stack e-commerce website for clothing built with React (JSX) and Django.
- Product Management: Browse products by category, gender, and search functionality
- Shopping Cart: Add, update, and remove items from cart
- User Authentication: Register, login, and logout functionality
- Order Management: Place orders and track order status
- Responsive Design: Mobile-friendly interface
- Product Details: View detailed product information with images
- Featured Products: Display featured and on-sale products
- Django 4.2.7
- Django REST Framework
- SQLite (default database)
- Django CORS Headers
- React 18.2.0
- Vite (build tool)
- React Router DOM
- Axios for API calls
- CSS3 for styling
ecommerce/
├── backend/
│ ├── ecommerce_backend/ # Django project settings
│ ├── products/ # Products app
│ ├── orders/ # Orders and Cart app
│ ├── users/ # User authentication app
│ ├── manage.py
│ └── requirements.txt
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ ├── context/ # React context
│ │ └── App.jsx
│ ├── index.html # Vite entry HTML
│ ├── vite.config.js # Vite configuration
│ └── package.json
└── README.md
- Python 3.8 or higher
- Node.js 14 or higher
- npm or yarn
- Navigate to the backend directory:
cd backend- Create a virtual environment (recommended):
# Windows
python -m venv venv
venv\Scripts\activate
# Linux/Mac
python3 -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Configure environment variables. Create a
.envfile inbackend/(or update your environment) with at least:
POSTGRES_DB=<your_db>
POSTGRES_USER=<your_user>
POSTGRES_PASSWORD=<your_password>
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
CLOUDINARY_CLOUD_NAME=<cloudinary_name>
CLOUDINARY_API_KEY=<api_key>
CLOUDINARY_API_SECRET=<api_secret>
- Run migrations:
python manage.py makemigrations
python manage.py migrate- Create a superuser (optional, for admin access):
python manage.py createsuperuser- Run the development server:
python manage.py runserverThe backend will be available at http://localhost:8000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will be available at http://localhost:3000
GET /api/products/- List all productsGET /api/products/{id}/- Get product detailsGET /api/products/categories/- List all categoriesGET /api/products/featured/- Get featured productsGET /api/products/on_sale/- Get products on sale
GET /api/orders/cart/- Get user's cartPOST /api/orders/cart/add_item/- Add item to cartPOST /api/orders/cart/update_item/- Update cart itemPOST /api/orders/cart/remove_item/- Remove item from cartPOST /api/orders/cart/checkout/- Checkout cart
GET /api/orders/orders/- List user's ordersGET /api/orders/orders/{id}/- Get order detailsPOST /api/orders/orders/{id}/cancel/- Cancel order
POST /api/users/register/- Register new userPOST /api/users/login/- Login userPOST /api/users/logout/- Logout userGET /api/users/me/- Get current user
Access the Django admin panel at http://localhost:8000/admin/ using the superuser credentials created during setup.
- Category: Product categories
- Product: Products with images, prices, sizes, etc.
- Cart: User shopping cart
- CartItem: Items in cart
- Order: User orders
- OrderItem: Items in orders
You can add sample data through the Django admin panel or by creating a management command. To add data via admin:
- Go to
http://localhost:8000/admin/ - Login with superuser credentials
- Add Categories first
- Then add Products with images
- The backend uses PostgreSQL via environment variables. Update
.envfor your setup. - CORS is configured to allow requests from
http://localhost:3000 - Product images are stored on Cloudinary via
django-cloudinary-storage; setCLOUDINARY_*variables before uploading products. - Local media directory is still available for development fallbacks, but uploaded files default to Cloudinary once credentials are provided.
For production deployment:
- Set
DEBUG = Falseinbackend/ecommerce_backend/settings.py - Update
ALLOWED_HOSTSwith your domain - Change
SECRET_KEYto a secure random value - Use a production database (PostgreSQL recommended)
- Set up proper static file serving
- Configure environment variables for sensitive data
- Build React app:
npm run build(Vite will create optimized production build) - Serve static files appropriately
This project is open source and available for educational purposes.
Feel free to submit issues and enhancement requests!