App Structure
Maybern follows a consistent directory structure across all Django apps. This structure promotes clear separation of concerns, maintainability, and testability.Directory Layout
Layer Overview
API Layer
Public endpoints that receive HTTP requests and return responses. Should be thin and delegate to services.
Public Layer
External interface for other apps. Contains services, constants, and dataclasses that can be imported by other apps.
Private Layer
Internal business logic. Contains selectors for data access and services for complex operations.
Models Layer
Django ORM models defining data structure and relationships. No business logic here.
Data Flow
Key Principles
Separation of Concerns
Separation of Concerns
Each layer has a specific responsibility:
- API: Request handling, validation, response formatting
- Public Services: External interface, orchestration
- Private Services: Business logic implementation
- Selectors: Data access patterns
- Models: Data structure and relationships
Dependency Direction
Dependency Direction
Dependencies should flow inward:
- API can import from Public
- Public can import from Private
- Private can import from Models
- Models should have no app-level dependencies
Test Organization
Test Organization
Tests live alongside the code they test:
api/tests/for API testsprivate/selectors/tests/for selector testsprivate/services/tests/for service testspublic/tests/for public service tests