Overview
This E-commerce API is built with Django and Django REST Framework, following a modular app-based architecture that separates concerns and promotes code reusability.Django App Structure
The API is organized into multiple Django applications, each handling a specific domain:Catalogue
Product management including categories, variants, attributes, media, and reviews
Orders
Order processing and order item management
Customers
Customer accounts, authentication, and address management
Cart
Shopping cart functionality and item management
Discount
Promotional offers, vouchers, and discount conditions
Payments
Payment processing with Braintree integration
Stores
Multi-vendor store management
Wishlist
Customer wishlists and saved items
App Location
All apps are located in~/workspace/source/ directory:
API Versioning
The API uses URL path versioning with the current version being v1.Base URL Structure
Example Endpoints
All endpoints shown in this documentation are relative to the
/api/v1/ base path.URL Configuration
Versioning is configured inconfig/urls.py:63:
Key Architectural Patterns
Abstract Base Models
The API uses abstract base models to share common functionality across apps. Located incatalogue/abstract.py, these models provide:
Timestamp Model
BaseModel
- Inherits timestamp tracking
- Soft delete support via
is_activeflag - Dual managers:
objects(all records) andactive_objects(active only)
TimeBased Model
- Extends BaseModel with time-based validity
- Automatic validation ensuring
valid_to>valid_from
Manager Classes
Custom managers provide filtered querysets for common use cases:ActiveObjectsManager
ActiveOfferManager
Authentication
The API supports multiple authentication methods configured inconfig/settings.py:167-174:
- JWT (Recommended)
- Basic Auth
JSON Web Token authentication with access and refresh tokens.Token Lifetime:
- Access Token: 1 hour
- Refresh Token: 3 days
Permission System
Default permission requires authentication:Database Configuration
Supports both PostgreSQL (production) and SQLite (development):Custom User Model
Uses email-based authentication instead of username:Design Principles
Separation of Concerns
Separation of Concerns
Each Django app handles a specific domain with clear boundaries. For example,
catalogue manages products, while orders handles order processing.Reusable Components
Reusable Components
Abstract base models and managers are shared across apps, reducing code duplication and ensuring consistent behavior.
Soft Deletes
Soft Deletes
Records are marked inactive rather than deleted, preserving data integrity and audit trails.
Database Indexing
Database Indexing
Strategic indexes on frequently queried fields improve performance:
- Product:
category,is_available - Order:
customer,status,created - Offer:
valid_from,valid_to,store
Multi-tenancy Support
Multi-tenancy Support
Store foreign keys enable multi-vendor marketplace functionality.
Next Steps
Data Models
Explore the core data models and their relationships
Filtering & Pagination
Learn how to filter, search, and paginate API results