docs: update documentation for /platforms/ URL routing strategy
- Add multi-platform URL routing section to url-routing/overview.md - Update multi-platform-cms.md with new request flow diagrams - Add PlatformContextMiddleware documentation to middleware.md - Update middleware execution order diagram - Add Phase 7 (Platform URL Routing Strategy) to implementation plan - Update platform URL summary tables across all docs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -113,13 +113,29 @@ ALTER TABLE content_pages ADD COLUMN is_platform_page BOOLEAN DEFAULT FALSE;
|
||||
|
||||
## Request Flow
|
||||
|
||||
### URL Routing Structure
|
||||
|
||||
The system uses different URL patterns for development vs production:
|
||||
|
||||
**Development (localhost):**
|
||||
- Main marketing site: `localhost:9999/` (no prefix) → `main` platform
|
||||
- Platform sites: `localhost:9999/platforms/{code}/` → specific platform
|
||||
|
||||
**Production (custom domains):**
|
||||
- Main marketing site: `wizamart.lu/` → `main` platform
|
||||
- Platform sites: `oms.lu/`, `loyalty.lu/` → specific platform
|
||||
|
||||
### Request Processing
|
||||
|
||||
```
|
||||
Request: GET /oms/vendors/shopname/about
|
||||
Request: GET /platforms/oms/vendors/shopname/about
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ PlatformContextMiddleware │
|
||||
│ - Detects platform from path prefix (/oms) or domain │
|
||||
│ - Detects platform from /platforms/{code}/ prefix or domain │
|
||||
│ - Rewrites path: /platforms/oms/vendors/shopname/about │
|
||||
│ → /vendors/shopname/about │
|
||||
│ - Sets request.state.platform = Platform(code='oms') │
|
||||
│ - Sets request.state.platform_clean_path = /vendors/shopname/about │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
@@ -127,7 +143,7 @@ Request: GET /oms/vendors/shopname/about
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ VendorContextMiddleware │
|
||||
│ - Uses platform_clean_path for vendor detection │
|
||||
│ - Uses rewritten path for vendor detection │
|
||||
│ - Sets request.state.vendor = Vendor(subdomain='shopname') │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
@@ -142,6 +158,30 @@ Request: GET /oms/vendors/shopname/about
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Main Marketing Site (No Platform Prefix)
|
||||
|
||||
For requests without the `/platforms/` prefix (e.g., `localhost:9999/about`):
|
||||
|
||||
```
|
||||
Request: GET /about
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ PlatformContextMiddleware │
|
||||
│ - No /platforms/ prefix detected │
|
||||
│ - Uses DEFAULT_PLATFORM_CODE = 'main' │
|
||||
│ - Sets request.state.platform = Platform(code='main') │
|
||||
│ - Path unchanged: /about │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ Route Handler (platform_pages.py) │
|
||||
│ - Gets platform_id from request.state.platform (main) │
|
||||
│ - Loads CMS content for main marketing site │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Admin Interface
|
||||
|
||||
### Platform Management (`/admin/platforms`)
|
||||
@@ -218,8 +258,8 @@ Request: GET /oms/vendors/shopname/about
|
||||
|
||||
1. Insert platform record:
|
||||
```sql
|
||||
INSERT INTO platforms (code, name, description, path_prefix)
|
||||
VALUES ('loyalty', 'Loyalty Program', 'Customer loyalty and rewards', '/loyalty');
|
||||
INSERT INTO platforms (code, name, description, domain, path_prefix)
|
||||
VALUES ('loyalty', 'Loyalty Program', 'Customer loyalty and rewards', 'loyalty.lu', 'loyalty');
|
||||
```
|
||||
|
||||
2. Create platform-specific content pages:
|
||||
@@ -228,8 +268,10 @@ Request: GET /oms/vendors/shopname/about
|
||||
VALUES (2, 'home', 'Loyalty Program', '<h1>Welcome</h1>', TRUE);
|
||||
```
|
||||
|
||||
3. Configure routing (if using path prefix):
|
||||
- Platform detected by `PlatformContextMiddleware`
|
||||
3. Configure routing:
|
||||
- **Development:** Access at `localhost:9999/platforms/loyalty/`
|
||||
- **Production:** Access at `loyalty.lu/`
|
||||
- Platform detected automatically by `PlatformContextMiddleware`
|
||||
- No additional route configuration needed
|
||||
|
||||
4. Assign vendors to platform:
|
||||
@@ -237,3 +279,11 @@ Request: GET /oms/vendors/shopname/about
|
||||
INSERT INTO vendor_platforms (vendor_id, platform_id)
|
||||
VALUES (1, 2);
|
||||
```
|
||||
|
||||
### Platform URL Summary
|
||||
|
||||
| Platform | Code | Dev URL | Prod URL |
|
||||
|----------|------|---------|----------|
|
||||
| Main Marketing | `main` | `localhost:9999/` | `wizamart.lu/` |
|
||||
| OMS | `oms` | `localhost:9999/platforms/oms/` | `oms.lu/` |
|
||||
| Loyalty | `loyalty` | `localhost:9999/platforms/loyalty/` | `loyalty.lu/` |
|
||||
|
||||
Reference in New Issue
Block a user