refactor: migrate templates and static files to self-contained modules

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>
This commit is contained in:
2026-02-01 14:34:16 +01:00
parent 843703258f
commit 4e28d91a78
542 changed files with 11603 additions and 9037 deletions

View File

@@ -509,11 +509,11 @@ Routes define API and page endpoints. They are auto-discovered from module direc
| Type | Location | Discovery | Router Name |
|------|----------|-----------|-------------|
| Vendor API | `routes/api/vendor.py` | `app/modules/routes.py` | `vendor_router` |
| Admin API | `routes/api/admin.py` | `app/modules/routes.py` | `admin_router` |
| Shop API | `routes/api/shop.py` | `app/modules/routes.py` | `shop_router` |
| Vendor Pages | `routes/pages/vendor.py` | `app/modules/routes.py` | `vendor_router` |
| Vendor API | `routes/api/vendor.py` | `app/modules/routes.py` | `vendor_router` |
| Storefront API | `routes/api/storefront.py` | `app/modules/routes.py` | `router` |
| Admin Pages | `routes/pages/admin.py` | `app/modules/routes.py` | `admin_router` |
| Vendor Pages | `routes/pages/vendor.py` | `app/modules/routes.py` | `vendor_router` |
**Structure:**
```
@@ -521,9 +521,10 @@ app/modules/{module}/routes/
├── __init__.py
├── api/
│ ├── __init__.py
│ ├── vendor.py # Must export vendor_router
│ ├── admin.py # Must export admin_router
── vendor_{feature}.py # Sub-routers aggregated in vendor.py
── vendor.py # Must export vendor_router
│ ├── storefront.py # Must export router (public storefront)
│ └── admin_{feature}.py # Sub-routers aggregated in admin.py
└── pages/
├── __init__.py
└── vendor.py # Must export vendor_router
@@ -754,22 +755,30 @@ class OrderAlreadyFulfilledError(OrderException):
### Templates
Jinja2 templates are auto-discovered from module `templates/` directories.
Jinja2 templates are auto-discovered from module `templates/` directories. The template loader searches `app/templates/` first (for shared templates), then each module's `templates/` directory.
| Location | URL Pattern | Discovery |
|----------|-------------|-----------|
| `templates/{module}/vendor/*.html` | `/vendor/{vendor}/...` | Jinja2 loader |
| `templates/{module}/admin/*.html` | `/admin/...` | Jinja2 loader |
| `templates/{module}/storefront/*.html` | `/storefront/...` | Jinja2 loader |
| `templates/{module}/public/*.html` | `/...` (platform pages) | Jinja2 loader |
**Structure:**
**Module Template Structure:**
```
app/modules/{module}/templates/
└── {module}/
├── admin/
│ ├── list.html
│ └── partials/ # Module-specific partials
│ └── my-partial.html
├── vendor/
│ ├── index.html
│ └── detail.html
── admin/
└── list.html
── storefront/ # Customer-facing shop pages
└── products.html
└── public/ # Platform marketing pages
└── pricing.html
```
**Template Reference:**
@@ -782,6 +791,27 @@ return templates.TemplateResponse(
)
```
**Shared Templates (in `app/templates/`):**
Some templates remain in `app/templates/` because they are used across all modules:
| Directory | Contents | Purpose |
|-----------|----------|---------|
| `admin/base.html` | Admin layout | Parent template all admin pages extend |
| `vendor/base.html` | Vendor layout | Parent template all vendor pages extend |
| `storefront/base.html` | Shop layout | Parent template all storefront pages extend |
| `platform/base.html` | Public layout | Parent template all public pages extend |
| `admin/errors/` | Error pages | HTTP error templates (404, 500, etc.) |
| `vendor/errors/` | Error pages | HTTP error templates for vendor |
| `storefront/errors/` | Error pages | HTTP error templates for storefront |
| `admin/partials/` | Shared partials | Header, sidebar used across admin |
| `vendor/partials/` | Shared partials | Header, sidebar used across vendor |
| `shared/macros/` | Jinja2 macros | Reusable UI components (buttons, forms, tables) |
| `shared/includes/` | Includes | Common HTML snippets |
| `invoices/` | PDF templates | Invoice PDF generation |
These shared templates provide the "framework" that module templates build upon. Module templates extend base layouts and import shared macros.
---
### Static Files