Core Functionality
This project is the backend for a multi-vendor e-commerce marketplace, similar to a mini-Amazon. It handles all the business logic, including user authentication, product management, order processing, and payment integration. The system supports distinct roles for buyers, sellers, and administrators, with role-based access control enforced at the API level.
Key Features
- Role-Based Access Control: Implements custom DRF permission classes (IsBuyer, IsSeller, IsAdminUser) to ensure appropriate access for different user roles.
- Secure Payment Processing: Integrates with Razorpay for secure payment handling. Orders are created server-side, and payment signatures are cryptographically verified using HMAC-SHA256 to prevent fraud.
- Atomic Stock Management: Stock deductions are performed within database transactions to ensure data integrity. If any part of the process fails, the entire transaction is rolled back.
- Asynchronous Email Notifications: Utilizes Celery and Redis for background tasks, enabling instant API responses for order confirmations, low stock alerts, and daily sales reports.
- Inventory Alerts: Automatically notifies sellers via email when product stock falls below a configurable threshold.
- Scheduled Daily Reports: Generates and sends daily sales summaries to sellers via email using Celery Beat.
Technical Stack
- Framework: Django 5.1 with Django REST Framework 3.15
- Authentication: Token-based authentication
- Asynchronous Tasks: Celery 5.4 with Redis
- Database: PostgreSQL (production), SQLite (local development)
- Payment Gateway: Razorpay
- Production Server: Gunicorn
- Static Files: WhiteNoise
- Hosting: Render
- Programming Language: Python
API Overview
The backend exposes REST endpoints for managing users (registration, login, profile), products (CRUD, search, filtering), and orders (cart, checkout, payment verification, status updates). Internal notification tasks are also handled.
Setup and Deployment
The project includes detailed instructions for local setup using Python, Redis, and Django, as well as deployment guidelines for Render, including configuration of environment variables and necessary build scripts.