Templates Migration: - Migrate admin templates to modules (tenancy, billing, monitoring, marketplace, etc.) - Migrate vendor templates to modules (tenancy, billing, orders, messaging, etc.) - Migrate storefront templates to modules (catalog, customers, orders, cart, checkout, cms) - Migrate public templates to modules (billing, marketplace, cms) - Keep shared templates in app/templates/ (base.html, errors/, partials/, macros/) - Migrate letzshop partials to marketplace module Static Files Migration: - Migrate admin JS to modules: tenancy (23 files), core (5 files), monitoring (1 file) - Migrate vendor JS to modules: tenancy (4 files), core (2 files) - Migrate shared JS: vendor-selector.js to core, media-picker.js to cms - Migrate storefront JS: storefront-layout.js to core - Keep framework JS in static/ (api-client, utils, money, icons, log-config, lib/) - Update all template references to use module_static paths Naming Consistency: - Rename static/platform/ to static/public/ - Rename app/templates/platform/ to app/templates/public/ - Update all extends and static references Documentation: - Update module-system.md with shared templates documentation - Update frontend-structure.md with new module JS organization Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6.2 KiB
Session Note: Module Config & Migrations Infrastructure
Date: 2026-01-28 Focus: Self-contained module configuration and migrations auto-discovery
Summary
Completed the infrastructure for fully self-contained modules with config and migrations auto-discovery. All modules now have placeholder files ready for the final migration phase.
What Was Done
1. Module Config Auto-Discovery
Created app/modules/config.py that auto-discovers module configurations:
from app.modules.config import get_module_config
marketplace_config = get_module_config("marketplace")
Each module now has a config.py placeholder:
# app/modules/marketplace/config.py
class MarketplaceConfig(BaseSettings):
model_config = {"env_prefix": "MARKETPLACE_"}
config = MarketplaceConfig()
2. Module Migrations Directories
Created migrations/versions/ directories for all 11 self-contained modules:
- analytics, billing, cms, customers, dev_tools
- inventory, marketplace, messaging, monitoring, orders, payments
Each with required __init__.py files for Alembic discovery.
3. New Architecture Rules
Added rules MOD-013 to MOD-015:
| Rule | Description |
|---|---|
| MOD-013 | config.py should export config or config_class |
| MOD-014 | Migrations must follow naming convention {module}_{seq}_{desc}.py |
| MOD-015 | Migrations directory must have __init__.py files |
4. Module Migration Commits
Committed all pending module migration work:
| Commit | Description |
|---|---|
2466dfd |
feat: add module config and migrations auto-discovery infrastructure |
bd2c99a |
feat: complete analytics module self-containment |
f79e67d |
feat: complete billing module self-containment |
b74d134 |
feat: complete marketplace module self-containment |
705d336 |
feat: add self-contained structure to remaining modules |
d987274 |
feat: complete dev_tools module self-containment |
37cf74c |
refactor: update registry and main.py for module auto-discovery |
3ffa337 |
refactor: convert legacy models/schemas to re-exports |
bf871dc |
refactor: convert legacy services/tasks to re-exports |
fbcf079 |
chore: update API routers, validation, and docs |
5. Documentation Updates
docs/architecture/module-system.md- Added Module Configuration and Module Migrations sectionsdocs/development/creating-modules.md- Added config.py pattern, updated migrations docs
Current Module Status
| Module | definition.py | config.py | migrations/ | routes/api/ | routes/pages/ | locales/ | Status |
|---|---|---|---|---|---|---|---|
| analytics | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | Complete |
| billing | ✅ | ✅ | ✅ | ✅ | ⚠️ | ✅ | Needs pages |
| cms | ✅ | ✅ | ✅ | ✅ | ✅ | - | Complete |
| customers | ✅ | ✅ | ✅ | ⚠️ | ⚠️ | - | Needs routes |
| dev_tools | ✅ | ✅ | ✅ | ✅ | - | - | Complete |
| inventory | ✅ | ✅ | ✅ | ⚠️ | ⚠️ | - | Needs routes |
| marketplace | ✅ | ✅ | ✅ | ✅ | ⚠️ | ✅ | Needs pages |
| messaging | ✅ | ✅ | ✅ | ⚠️ | ⚠️ | - | Needs routes |
| monitoring | ✅ | ✅ | ✅ | ⚠️ | ⚠️ | - | Needs routes |
| orders | ✅ | ✅ | ✅ | ⚠️ | ⚠️ | - | Needs routes |
| payments | ✅ | ✅ | ✅ | ⚠️ | ⚠️ | - | Needs routes |
| core | ✅ | - | - | - | - | - | Minimal |
| tenancy | ✅ | - | - | - | - | - | Minimal |
Decisions Made
- Config is environment-based: Each module uses Pydantic Settings with
{MODULE}_prefix - Migrations stay central for now: Existing migrations remain in
alembic/versions/, module directories are for future changes - Migration reorganization deferred: Will move existing migrations to modules before production
- Legacy files become re-exports: Original files in
models/database/,models/schema/,app/services/re-export from modules
Tomorrow's Tasks
Phase 1: Module Alignment Audit
Run architecture validator and fix all modules to comply with rules:
python scripts/validate_architecture.py
Check each module for:
- MOD-001: Required directories exist
- MOD-002: Services contain actual code (not re-exports)
- MOD-003: Schemas contain actual code (not re-exports)
- MOD-004: Routes import from module, not legacy
- MOD-005: Templates and static exist for UI modules
- MOD-008: exceptions.py exists
- MOD-010: Routes export
routervariable - MOD-011: Tasks have
__init__.py
Phase 2: Complete Module Routes Migration
Move remaining routes to self-contained structure:
- customers - Move routes from
app/api/v1/*/customers.py - inventory - Move routes from
app/api/v1/*/inventory.py - messaging - Move routes from
app/api/v1/*/messages.py - monitoring - Move routes from
app/api/v1/admin/monitoring.py - orders - Move routes from
app/api/v1/*/orders.py - payments - Move routes from
app/api/v1/*/payments.py
Phase 3: Migration Reorganization (Pre-Production)
Move existing migrations to module-specific directories:
- Identify which tables belong to which module
- Create baseline migrations in module directories
- Test migration chain works correctly
- Remove/reorganize central migrations
Phase 4: Validation & Testing
- Run full architecture validation
- Test all routes are accessible
- Test module enable/disable functionality
- Verify Alembic discovers all migrations
Files Changed
New Files
app/modules/config.py- Config auto-discoveryapp/modules/*/config.py- Module config placeholders (11 files)app/modules/*/migrations/__init__.py- Migration package markers (11 modules)app/modules/*/migrations/versions/__init__.py- Version package markers (11 modules).architecture-rules/module.yaml- Module validation rules
Modified Files
docs/architecture/module-system.md- Added config/migrations sectionsdocs/development/creating-modules.md- Added config pattern, updated migrations