08 / Backend

E-Commerce API

Project study

Products, carts and orders as a REST API, with roles, validation and a properly normalised schema.

E-Commerce API / Backend / 2024

Role
Solo — API and database
Status
REST API
Year
2024
Stack
Python / Django / Django REST Framework / MySQL / Postman

02 / Overview

The backend of a shop, built to be predictable.

REST APIs for product, cart and order management with input validation and clean JSON responses. Authentication and role-based access control use Django's built-in auth system, on top of a normalised MySQL schema with ORM logic for stock updates and order totals.

  1. Request
  2. Validate
  3. Authorise
  4. Persist

E-Commerce API / how the parts connect

03 / The problem

Money and stock leave no room for "usually correct".

An e-commerce backend has to keep stock, carts and orders consistent, reject bad input, and make sure customers cannot do what only staff should. Those rules belong in the API and the schema, not in each screen.

  1. 01

    Stock and totals that must always add up

  2. 02

    Different permissions for customers and staff

  3. 03

    Clear errors when a request is invalid

04 / How it works

Validation, roles and a normalised schema behind every endpoint.

  1. 01

    Request

    A client calls a product, cart or order endpoint.

  2. 02

    Validate

    Input is checked; bad requests get a clear JSON error.

  3. 03

    Authorise

    Django auth and roles decide what the caller may do.

  4. 04

    Persist

    The ORM updates stock and totals in a normalised MySQL schema.

05 / Key decisions

Where the important calls were made.

Decision 01

Where should permissions be enforced?

  1. →

    The choice

    Role-based access in the API, using Django auth.

  2. →

    What it gave

    A customer cannot reach staff actions, whatever client they use.

Decision 02

How should the data be stored?

  1. →

    The choice

    A normalised MySQL schema with ORM logic.

  2. →

    What it gave

    Stock updates and order totals stay consistent.

06 / The flow

From the first step to the result.

What it looks like from the side of the person using it — the path through E-Commerce API in 4 steps.

  1. 01Browse products
  2. 02Add to cart
  3. 03Place an order
  4. 04Stock and totals update

E-Commerce API / user flow

07 / Outcome

A clean, role-aware API for a shop.

Products, carts, orders
3 resources
Access control
Role-based
MySQL schema
Normalised
01 / Next project Lumida A self-hosted engine that reads your database, finds what is quietly broken, and explains why.