Architecture
The Django Project Template follows a clean architecture with clear separation of concerns and modular design.
Application Structure
django-project-template/
├── apps/ # All application modules
│ ├── common/ # Core models and utilities
│ ├── api/ # REST API endpoints
│ ├── public/ # Web interface components
│ ├── ai/ # AI integration features
│ └── integration/ # Third-party integrations
├── settings/ # Project configuration
├── templates/ # All HTML templates (centralized)
├── static/ # Static assets (centralized)
└── docs/ # Project documentation
Key Design Principles
Centralized Templates and Static Files
Templates and static files are stored in root-level directories rather than within apps, promoting consistency and reducing duplication.
Behavior Mixins
Models use behavior mixins (e.g., Timestampable, Authorable) to share common functionality without complex inheritance hierarchies.
HTMX-Centric Frontend
Frontend interactions are implemented primarily using HTMX, reducing the need for custom JavaScript while maintaining modern UX capabilities.
Comprehensive Testing
Every component has extensive test coverage using pytest, with specific patterns for testing models, views, and behaviors.
Clean API Design
APIs follow a consistent RESTful design using Django Rest Framework, with standardized serializers and authentication mechanisms.
Modular Integrations
Third-party integrations are encapsulated in dedicated modules with clear interfaces, making them easy to replace or update.
App Responsibilities
- common
Core data models, behaviors, and utilities used throughout the application.
- api
REST API endpoints, serializers, and authentication.
- public
Web interface components, including HTMX views and templates.
- ai
Artificial intelligence integrations and models.
- integration
Third-party service connections (AWS, Stripe, Twilio, etc.).