Professional Django REST Framework e-commerce backend with comprehensive admin management system and JWT authentication.
- 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
- 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
- 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
- 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
- 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)
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
- Python 3.12+
- PostgreSQL 13+
- Docker & Docker Compose (optional)
- Clone the repository
git clone https://github.com/Abdulazizovv/ecommerce.git
cd ecommerce- Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows- Install dependencies
pip install -r requirements.txt- Environment configuration
cp .env.example .env
# Edit .env with your database credentials- Database setup
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser- Run development server
python manage.py runserver- Build and run with Docker Compose
docker-compose up --build- Create superuser (in Docker)
docker-compose exec web python manage.py createsuperuserPOST /api/auth/login/ # User login
POST /api/auth/register/ # User registration
POST /api/auth/refresh/ # Refresh token
POST /api/auth/logout/ # User logout
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
GET /api/orders/ # List user orders
POST /api/orders/ # Create order
GET /api/orders/{id}/ # Order details
PUT /api/orders/{id}/ # Update order
GET /api/categories/ # List categories
POST /api/categories/ # Create category
GET /api/categories/{id}/ # Category details
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
Access the admin panel at /admin/ with superuser credentials.
- 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
- 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
Optimized indexes for:
- Product searches and filtering
- Order queries by date and status
- User lookups and authentication
- Category-based product filtering
- 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
- Database Optimization: Strategic indexing for common queries
- Query Efficiency: Optimized ORM usage
- Pagination: Efficient data loading
- Caching Ready: Prepared for Redis integration
Run tests with:
python manage.py test# 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/- 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-compose -f docker-compose.prod.yml up -d- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Abdulazizov
- GitHub: @Abdulazizovv
- Email: [email protected]
- Django and DRF communities
- Contributors and testers
- Open source libraries used in this project
Built with β€οΈ using Django REST Framework