Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ›’ Django REST Framework e-commerce backend with JWT authentication, advanced admin panel, sequential order management, and optimized database performance. Production-ready with Docker support.

License

Notifications You must be signed in to change notification settings

Abdulazizovv/ecommerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

E-Commerce Platform

Professional Django REST Framework e-commerce backend with comprehensive admin management system and JWT authentication.

πŸš€ Features

Core Functionality

  • Product Management: Complete CRUD operations with categories, pricing, and image galleries
  • Order System: Sequential order ID generation (YYYYMMDD-XXXXXX format)
  • User Management: Custom user model with JWT authentication
  • Category System: Product categorization
  • Shopping Cart: Full cart management functionality

Authentication & Security

  • JWT Authentication: Access tokens (60 minutes) and refresh tokens (7 days)
  • Custom User Model: Email-based authentication
  • Permission System: Role-based access control
  • Secure API Endpoints: Protected routes with proper authorization

Admin Panel Features

  • Professional Admin Interface: Enhanced Django admin with custom actions
  • Advanced Filtering: Multiple filter options for all models
  • Bulk Operations: Mass update capabilities for products and orders
  • Statistics Dashboard: Comprehensive analytics and reporting
  • Image Preview: In-admin image preview functionality

Performance Optimization

  • Database Indexing: Strategic indexes for optimal query performance
  • Query Optimization: Efficient database queries with select_related and prefetch_related
  • Pagination: Optimized pagination for large datasets
  • Caching Ready: Prepared for Redis integration

πŸ›  Tech Stack

  • Backend: Django 4.x + Django REST Framework
  • Database: PostgreSQL with optimized indexing
  • Authentication: Django Simple JWT
  • API Documentation: Swagger/OpenAPI integration
  • Containerization: Docker & Docker Compose
  • Web Server: Nginx (production ready)

πŸ“ Project Structure

ecommerce/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/                 # API configuration
β”‚   β”œβ”€β”€ cart/               # Shopping cart functionality
β”‚   β”œβ”€β”€ category/           # Product categories
β”‚   β”œβ”€β”€ order/              # Order management
β”‚   β”œβ”€β”€ product/            # Product catalog
β”‚   └── users/              # User management
β”œβ”€β”€ core/                   # Project settings
β”œβ”€β”€ media/                  # User uploaded files
β”œβ”€β”€ static/                 # Static files
β”œβ”€β”€ nginx/                  # Nginx configuration
β”œβ”€β”€ docker-compose.yml      # Docker services
β”œβ”€β”€ Dockerfile             # Docker image
└── requirements.txt       # Python dependencies

πŸš€ Quick Start

Prerequisites

  • Python 3.12+
  • PostgreSQL 13+
  • Docker & Docker Compose (optional)

Installation

  1. Clone the repository
git clone https://github.com/Abdulazizovv/ecommerce.git
cd ecommerce
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # Linux/Mac
# or
venv\Scripts\activate     # Windows
  1. Install dependencies
pip install -r requirements.txt
  1. Environment configuration
cp .env.example .env
# Edit .env with your database credentials
  1. Database setup
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
  1. Run development server
python manage.py runserver

Docker Deployment

  1. Build and run with Docker Compose
docker-compose up --build
  1. Create superuser (in Docker)
docker-compose exec web python manage.py createsuperuser

πŸ“š API Documentation

Authentication Endpoints

POST /api/auth/login/          # User login
POST /api/auth/register/       # User registration
POST /api/auth/refresh/        # Refresh token
POST /api/auth/logout/         # User logout

Product Endpoints

GET    /api/products/          # List products
POST   /api/products/          # Create product
GET    /api/products/{id}/     # Product details
PUT    /api/products/{id}/     # Update product
DELETE /api/products/{id}/     # Delete product

Order Endpoints

GET    /api/orders/            # List user orders
POST   /api/orders/            # Create order
GET    /api/orders/{id}/       # Order details
PUT    /api/orders/{id}/       # Update order

Category Endpoints

GET    /api/categories/        # List categories
POST   /api/categories/        # Create category
GET    /api/categories/{id}/   # Category details

Cart Endpoints

GET    /api/cart/              # Get cart items
POST   /api/cart/add/          # Add to cart
PUT    /api/cart/update/       # Update cart item
DELETE /api/cart/remove/       # Remove from cart

πŸ”§ Admin Panel

Access the admin panel at /admin/ with superuser credentials.

Admin Features

  • Product Management: Bulk actions, advanced filtering, image preview
  • Order Management: Status updates, customer information, order analytics
  • User Management: User statistics, bulk operations, activity tracking
  • Category Management: Hierarchical structure, SEO optimization
  • Statistics Dashboard: Sales analytics, user metrics, performance data

πŸ—„ Database Schema

Key Models

  • User: Custom user model with email authentication
  • Product: Product catalog with pricing, categories, and images
  • Category: Product categorization system
  • Order: Order management with sequential ID generation
  • OrderItem: Individual items within orders
  • Cart: Shopping cart functionality

Database Indexes

Optimized indexes for:

  • Product searches and filtering
  • Order queries by date and status
  • User lookups and authentication
  • Category-based product filtering

πŸ”’ Security Features

  • JWT Authentication: Secure token-based authentication
  • CORS Configuration: Proper cross-origin resource sharing
  • Input Validation: Comprehensive data validation
  • SQL Injection Protection: Parameterized queries
  • XSS Protection: Output sanitization

πŸ“Š Performance

  • Database Optimization: Strategic indexing for common queries
  • Query Efficiency: Optimized ORM usage
  • Pagination: Efficient data loading
  • Caching Ready: Prepared for Redis integration

πŸ§ͺ Testing

Run tests with:

python manage.py test

πŸ“ Environment Variables

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/dbname

# JWT Settings
JWT_SECRET_KEY=your-secret-key
JWT_ACCESS_TOKEN_LIFETIME=60  # minutes
JWT_REFRESH_TOKEN_LIFETIME=7  # days

# Django Settings
DEBUG=False
SECRET_KEY=your-django-secret-key
ALLOWED_HOSTS=localhost,127.0.0.1

# Media Files
MEDIA_URL=/media/
STATIC_URL=/static/

πŸš€ Deployment

Production Checklist

  • Set DEBUG=False
  • Configure proper ALLOWED_HOSTS
  • Set up PostgreSQL database
  • Configure static file serving
  • Set up media file storage
  • Configure email backend
  • Set up monitoring and logging

Docker Production

docker-compose -f docker-compose.prod.yml up -d

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Abdulazizov

πŸ™ Acknowledgments

  • Django and DRF communities
  • Contributors and testers
  • Open source libraries used in this project

Built with ❀️ using Django REST Framework

About

πŸ›’ Django REST Framework e-commerce backend with JWT authentication, advanced admin panel, sequential order management, and optimized database performance. Production-ready with Docker support.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published