Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E-commerce Website API

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.

Features

  • 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

Tech Stack

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

Project Structure

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

Data Models

  • 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

Getting Started

Prerequisites

Installation

# 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 runserver

The API will be available at http://127.0.0.1:8000/.

Main Endpoints

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>

Notes

  • The project ships with development settings (DEBUG = True, a hardcoded SECRET_KEY, and DB credentials in settings.py). Move these to environment variables and disable debug before any real deployment.

About

E-commerce API System with Django Rest Framework (DRF) This project is a comprehensive e-commerce API system designed and implemented using Django Rest Framework (DRF).

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages