A RESTful backend API for an online store, built with Django and Django REST Framework. It exposes endpoints for managing products, carts, orders, customers, and comments, with JWT-based authentication.
This started as one of my early backend projects while learning Django REST Framework, so it's meant as a learning / practice project rather than a production-ready service.
- Products & Categories — full CRUD, search, ordering, and filtering (admin-only writes)
- Shopping Cart — create carts (UUID-based), add/update/remove items
- Orders — place orders from a cart; users see only their own orders, admins see all
- Customers — profile management with a
me/endpoint; custom permission for sending private emails - Comments — product reviews with an approval workflow (waiting / approved / not approved)
- Authentication — registration, login, and JWT tokens via Djoser + SimpleJWT
- Discounts — many-to-many discounts on products
- Fake data — a management command to seed the database for testing
| Purpose | Library |
|---|---|
| Framework | Django 4.2, Django REST Framework |
| Database | MySQL (mysqlclient) |
| Authentication | Djoser, djangorestframework-simplejwt |
| Filtering | django-filter |
| Nested routes | drf-nested-routers |
| Test data | factory-boy, faker |
| Debugging | django-debug-toolbar |
config/ Project settings, root URLconf, WSGI/ASGI
core/ Custom user model (CustomUser) and auth serializers
store/ Core store logic: models, views, serializers, filters, signals
manage.py Django entry point
- Category — product categories (with an optional "top product")
- Product — name, slug, description, unit price, inventory, discounts
- Discount — discount value + description (M2M with Product)
- Customer — linked to a user, with phone number and birth date
- Address — one-to-one address per customer
- Order / OrderItem — orders with status (Paid / Unpaid / Canceled) and line items
- Cart / CartItem — UUID-keyed carts and their items
- Comment — product comments with an approval status
- Python 3.9
- MySQL
- Pipenv
# Install dependencies
pipenv install
pipenv shell
# Configure the database
# Edit DATABASES in config/settings.py to match your MySQL setup
# (name, host, user, password)
# Apply migrations
python manage.py migrate
# (Optional) seed the database with fake data
python manage.py setup_fake_data
# Create an admin user
python manage.py createsuperuser
# Run the development server
python manage.py runserverThe API will be available at http://127.0.0.1:8000/.
| Endpoint | Description |
|---|---|
/store/products/ |
List / manage products |
/store/products/{id}/comments/ |
Product comments (nested) |
/store/categories/ |
List / manage categories |
/store/carts/ |
Create and view carts |
/store/carts/{id}/items/ |
Manage items in a cart |
/store/orders/ |
Place and view orders |
/store/customers/me/ |
View / update own profile |
/auth/users/ |
Register a new user |
/auth/jwt/create/ |
Obtain a JWT token |
/admin/ |
Django admin panel |
Authenticated requests use the JWT auth header type, e.g.:
Authorization: JWT <your_access_token>
- The project ships with development settings (
DEBUG = True, a hardcodedSECRET_KEY, and DB credentials insettings.py). Move these to environment variables and disable debug before any real deployment.