refactor: Reorganize Django apps into domain-based structure
Restructured 13 Django apps from flat/mixed organization into 5 logical
domain packages following cookiecutter-django conventions:
- identity/: core (tenant/domain models, middleware, mixins), users
- scheduling/: schedule, contracts, analytics
- communication/: notifications, credits, mobile, messaging
- commerce/: payments, tickets
- platform/: admin, api
Key changes:
- Moved all apps to smoothschedule/smoothschedule/{domain}/{app}/
- Updated all import paths across the codebase
- Updated settings (base.py, multitenancy.py, test.py)
- Updated URL configuration in config/urls.py
- Updated middleware and permission paths
- Preserved app_label in AppConfig for migration compatibility
- Updated CLAUDE.md documentation with new structure
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,10 +13,16 @@ from .base import INSTALLED_APPS, MIDDLEWARE, DATABASES, LOGGING, env
|
||||
# Shared apps - Available to all tenants (stored in 'public' schema)
|
||||
SHARED_APPS = [
|
||||
'django_tenants', # Must be first
|
||||
'core', # Core models (Tenant, Domain, PermissionGrant)
|
||||
'platform_admin.apps.PlatformAdminConfig', # Platform management (TenantInvitation, etc.)
|
||||
|
||||
# Django built-ins (must be in shared
|
||||
# Identity Domain (shared)
|
||||
'smoothschedule.identity.core', # Core models (Tenant, Domain, PermissionGrant)
|
||||
'smoothschedule.identity.users', # Users app (shared across tenants)
|
||||
|
||||
# Platform Domain (shared)
|
||||
'smoothschedule.platform.admin', # Platform management (TenantInvitation, etc.)
|
||||
'smoothschedule.platform.api', # Public API v1 for third-party integrations
|
||||
|
||||
# Django built-ins (must be in shared)
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.sessions',
|
||||
@@ -25,15 +31,12 @@ SHARED_APPS = [
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.admin',
|
||||
|
||||
# Users app (shared across tenants)
|
||||
'smoothschedule.users',
|
||||
|
||||
# Third-party apps that should be shared
|
||||
'rest_framework',
|
||||
'rest_framework.authtoken',
|
||||
'corsheaders',
|
||||
'drf_spectacular',
|
||||
'channels', # WebSockets
|
||||
'channels', # WebSockets
|
||||
'allauth',
|
||||
'allauth.account',
|
||||
'allauth.mfa',
|
||||
@@ -45,23 +48,26 @@ SHARED_APPS = [
|
||||
'crispy_bootstrap5',
|
||||
'csp',
|
||||
'djstripe', # Stripe integration
|
||||
'tickets', # Ticket system - shared for platform support access
|
||||
'notifications', # Notification system - shared for platform to notify tenants
|
||||
'smoothschedule.public_api', # Public API v1 for third-party integrations
|
||||
'smoothschedule.comms_credits', # Communication credits (SMS/calling) - shared for billing
|
||||
'smoothschedule.field_mobile', # Field employee mobile app - shared for location tracking
|
||||
|
||||
# Commerce Domain (shared for platform support)
|
||||
'smoothschedule.commerce.tickets', # Ticket system - shared for platform support access
|
||||
|
||||
# Communication Domain (shared)
|
||||
'smoothschedule.communication.notifications', # Notification system - shared for platform
|
||||
'smoothschedule.communication.credits', # Communication credits (SMS/calling) - shared for billing
|
||||
'smoothschedule.communication.mobile', # Field employee mobile app - shared for location tracking
|
||||
]
|
||||
|
||||
# Tenant-specific apps - Each tenant gets isolated data in their own schema
|
||||
TENANT_APPS = [
|
||||
'django.contrib.contenttypes', # Needed for tenant schemas
|
||||
'schedule', # Resource scheduling with configurable concurrency
|
||||
'payments', # Stripe Connect payments bridge
|
||||
'contracts', # Contract/e-signature system
|
||||
# Add your tenant-scoped business logic apps here:
|
||||
# 'appointments',
|
||||
# 'customers',
|
||||
# 'analytics',
|
||||
|
||||
# Scheduling Domain (tenant-isolated)
|
||||
'smoothschedule.scheduling.schedule', # Resource scheduling with configurable concurrency
|
||||
'smoothschedule.scheduling.contracts', # Contract/e-signature system
|
||||
|
||||
# Commerce Domain (tenant-isolated)
|
||||
'smoothschedule.commerce.payments', # Stripe Connect payments bridge
|
||||
]
|
||||
|
||||
|
||||
@@ -96,7 +102,7 @@ MIDDLEWARE = [
|
||||
|
||||
# 1. Tenant resolution
|
||||
'django_tenants.middleware.main.TenantMainMiddleware',
|
||||
'core.middleware.TenantHeaderMiddleware', # Support tenant switching via header
|
||||
'smoothschedule.identity.core.middleware.TenantHeaderMiddleware', # Support tenant switching via header
|
||||
|
||||
# 2. Security middleware
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
@@ -108,7 +114,7 @@ MIDDLEWARE = [
|
||||
|
||||
# 4. Sandbox mode - switches to sandbox schema if requested
|
||||
# MUST come after TenantMainMiddleware and SessionMiddleware
|
||||
'core.middleware.SandboxModeMiddleware',
|
||||
'smoothschedule.identity.core.middleware.SandboxModeMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
@@ -120,7 +126,7 @@ MIDDLEWARE = [
|
||||
'hijack.middleware.HijackUserMiddleware',
|
||||
|
||||
# 6. MASQUERADE AUDIT - MUST come AFTER HijackUserMiddleware
|
||||
'core.middleware.MasqueradeAuditMiddleware',
|
||||
'smoothschedule.identity.core.middleware.MasqueradeAuditMiddleware',
|
||||
|
||||
# 7. Messages, Clickjacking, and Allauth
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
@@ -176,7 +182,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
# HIJACK (MASQUERADING) CONFIGURATION
|
||||
# =============================================================================
|
||||
|
||||
HIJACK_AUTHORIZATION_CHECK = 'core.permissions.can_hijack'
|
||||
HIJACK_AUTHORIZATION_CHECK = 'smoothschedule.identity.core.permissions.can_hijack'
|
||||
HIJACK_DISPLAY_ADMIN_BUTTON = True
|
||||
HIJACK_USE_BOOTSTRAP = True
|
||||
HIJACK_ALLOW_GET_REQUESTS = False # Security: require POST
|
||||
|
||||
Reference in New Issue
Block a user