Architecture Overview
Django SuperApp is a modular framework that extends Django to enable rapid project development through pre-built, standalone apps. The framework provides an automatic discovery and integration system that makes Django projects more organized and scalable.Core Architecture
Django SuperApp enhances the standard Django project structure by introducing an automated app discovery and integration mechanism. Instead of manually configuring each app in your project’s settings and URLs, SuperApp automatically detects and integrates apps placed in thesuperapp/apps/ directory.
How SuperApp Extends Django
The framework provides two core integration points:- Settings Integration - Automatically discovers and executes
extend_superapp_settings()functions from each app’ssettings.py - URL Integration - Automatically discovers and executes URL extension functions from each app’s
urls.py
App Discovery Mechanism
SuperApp uses Python’spkgutil.iter_modules() to automatically discover all apps within the superapp/apps/ directory. The discovery process:
- Iterates through all modules in the apps package
- Attempts to import
settings.pyandurls.pyfrom each app - Executes integration functions if they exist
- Gracefully continues if an app doesn’t have these files
Settings Discovery
Fromsrc/django_superapp/settings.py:9-21:
- Dynamically imports each app’s settings module
- Checks if
extend_superapp_settings()exists - Passes the main settings dictionary for modification
- Handles missing modules gracefully
URL Discovery
Fromsrc/django_superapp/urls.py:7-19:
Project Structure Conventions
Django SuperApp follows a standardized project structure:Key Conventions
App Location
App Location
All SuperApp apps must be placed in
superapp/apps/ directory for automatic discovery.App Settings
App Settings
Each app should have a
settings.py with an extend_superapp_settings(main_settings) function to configure the app.App URLs
App URLs
Each app should have a
urls.py with extend_superapp_urlpatterns(main_urlpatterns) function to register routes.App Dependencies
App Dependencies
Each app can have its own
requirements.txt for app-specific Python packages.Admin Files
Admin Files
Admin configurations must live in
superapp/apps/<app_name>/admin/<model_name_slug>.py for proper organization.Benefits of SuperApp Architecture
Modularity
Each app is completely self-contained with its own settings, URLs, and dependencies.
Reusability
Apps can be easily shared across projects or published as templates.
Automatic Integration
No manual configuration needed - just drop an app in the apps directory.
Scalability
Add or remove apps without modifying core project files.
Integration Flow
When your Django SuperApp project starts:The discovery mechanism is fault-tolerant - if an app doesn’t have
settings.py or urls.py, it’s simply skipped without errors.Next Steps
App System
Learn how to structure and create SuperApp apps
Settings Integration
Deep dive into app settings integration
URL Integration
Understand URL pattern integration