type
concept
created
Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
updated
Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
sources
raw/notes/systemPatterns, raw/notes/techContext, raw/notes/codeGuidelines
tags
django backend app-layout architecture drf

Django App Layout

abstract
The backend is organized as Django apps under `backend/apps/`, each owning a slice of the domain, with models, serializers (explicit fields only), views, and optional services.py for business logic.

Overview

The wiki/entities/b2bpaper backend follows Django's app-per-domain pattern, where each Django app owns a coherent slice of the business domain. Apps live under backend/apps/ and follow a consistent internal structure. The backend runs Django 5.x with Django REST Framework 5.x on PostgreSQL.

App Structure Convention

Every Django app follows this layout:

apps/<app_name>/
    __init__.py
    models.py           # Django models (always PostgreSQL)
    serializers.py      # DRF serializers (explicit fields, NEVER __all__)
    views.py            # ViewSets or GenericAPIView
    urls.py             # URL routing for this app
    admin.py            # Django admin configuration
    permissions.py      # Custom DRF permissions (when needed)
    filters.py          # django-filter FilterSets (when needed)
    services.py         # Pure-function business logic (when needed)
    tests/
        test_models.py
        test_api/       # API integration tests
        test_services/  # Service unit tests (when services.py exists)

Domain Apps

Based on the wiki/concepts/six-core-entities and wiki/concepts/eight-core-actions, the key domain areas are:

App Domain Entities Owned Key Actions
Products Products (master catalog) Reference data CRUD
Surplus Surplus Availability Excel ingestion, CRUD
Mills Mills, Mills Surplus Visibility Onboarding, visibility config
Buyers Buyers, Buyer Specifics Onboarding, spec management
Containers Container Proposals, Freight Rates Container assembly, fill optimization
Matching Match results, scores Spec-based matching algorithm
Newsletters Newsletter templates, send logs Newsletter generation and delivery
Exclusivity Exclusivity windows 48-hour window management

Key Backend Conventions

Serializers

Views

Database

API Design

Authentication

Async Processing

Documentation

Sources

Related