Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

Repository files navigation

ShopDRF — E-Commerce REST API

A production-grade e-commerce backend built with Django REST Framework, featuring JWT authentication, async task processing, caching, performance profiling, and load testing.

Tech Stack

  • Backend: Django 5.2, Django REST Framework
  • Auth: JWT via djangorestframework-simplejwt + Djoser
  • Database: MySQL (prod) / SQLite (dev)
  • Cache: Redis via django-redis
  • Task Queue: Celery + Redis broker
  • Search & Filtering: django-filter, DRF SearchFilter, OrderingFilter
  • Performance: Django Silk (profiling), Django Debug Toolbar
  • Load Testing: Locust
  • Testing: pytest + pytest-django + model-bakery
  • Static Files: WhiteNoise
  • CORS: django-cors-headers

Features

  • Product Catalog — CRUD with filtering by collection, price range, search, and ordering
  • Collections — Hierarchical product categorization with product count annotations
  • Cart System — Session-based carts with add/update/remove items
  • Orders — Order creation from cart, order management with admin controls
  • Customer Profiles — /me endpoint, customer history with custom permissions
  • Product Images — Multi-image support per product
  • Reviews — Nested reviews per product
  • Likes — Generic content type-based likes system
  • Tags — Generic tagging system via content types
  • JWT Auth — Register, login, token refresh via Djoser
  • Custom User Model — Extends AbstractUser via core app
  • Celery Beat — Scheduled background tasks
  • Pagination — Default pagination on all list endpoints
  • Permissions — Role-based: AllowAny for reads, IsAdminUser for writes

Project Structure

FirstDjangoProject/
├── core/           # Custom user model, serializers
├── store/          # Products, collections, carts, orders, reviews, images
├── tags/           # Generic tagging
├── likes/          # Generic likes
├── playground/     # Celery task experiments
├── locustfiles/    # Load test scripts
├── project1/
│   └── settings/
│       ├── common.py
│       ├── dev.py
│       └── prod.py
└── manage.py

Setup

# Clone
git clone https://github.com/gsvenkatsai/FirstDjangoProject.git
cd FirstDjangoProject

# Create and activate virtualenv
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Configure dev settings (create project1/settings/dev.py with SECRET_KEY, DB, Redis)

# Run migrations
python manage.py migrate

# Load fixtures (optional)
python manage.py loaddata fullstoredata.json

# Start server
python manage.py runserver

Running Celery

# Worker
celery -A project1 worker --loglevel=info

# Beat scheduler
celery -A project1 beat --loglevel=info

# Flower monitoring
celery -A project1 flower

Running Tests

pytest
# Watch mode
ptw

Load Testing

locust -f locustfiles/browse_products.py

API Endpoints

Resource Endpoint
Products /store/products/
Collections /store/collections/
Cart /store/carts/
Cart Items /store/carts/{id}/items/
Orders /store/orders/
Customers /store/customers/
My Profile /store/customers/me/
Product Reviews /store/products/{id}/reviews/
Product Images /store/products/{id}/images/
Auth /auth/users/, /auth/jwt/create/

Environment Variables (dev.py)

SECRET_KEY = '...'
DEBUG = True
DATABASES = { 'default': { 'ENGINE': '...mysql...', 'NAME': '...', ... } }
CELERY_BROKER_URL = 'redis://localhost:6379/1'

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages