docs: add consolidated dev URL reference and migrate /shop to /storefront
Some checks failed
Some checks failed
- Add Development URL Quick Reference section to url-routing overview with all login URLs, entry points, and full examples - Replace /shop/ path segments with /storefront/ across 50 docs files - Update file references: shop_pages.py → storefront_pages.py, templates/shop/ → templates/storefront/, api/v1/shop/ → api/v1/storefront/ - Preserve domain references (orion.shop) and /store/ staff dashboard paths - Archive docs left unchanged (historical) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,7 @@ graph TB
|
||||
|
||||
```http
|
||||
# Shop page request (subdomain mode)
|
||||
GET https://orion.platform.com/shop/products
|
||||
GET https://orion.platform.com/storefront/products
|
||||
Host: orion.platform.com
|
||||
|
||||
# API request
|
||||
@@ -69,7 +69,7 @@ Host: platform.com
|
||||
start_time = time.time()
|
||||
|
||||
# Log entry
|
||||
logger.info(f"Request: GET /shop/products from 192.168.1.100")
|
||||
logger.info(f"Request: GET /storefront/products from 192.168.1.100")
|
||||
```
|
||||
|
||||
**Output**: Nothing added to `request.state` yet
|
||||
@@ -87,7 +87,7 @@ logger.info(f"Request: GET /shop/products from 192.168.1.100")
|
||||
```python
|
||||
# Input
|
||||
host = "orion.platform.com"
|
||||
path = "/shop/products"
|
||||
path = "/storefront/products"
|
||||
|
||||
# Detection logic
|
||||
if host != settings.platform_domain:
|
||||
@@ -102,14 +102,14 @@ if host != settings.platform_domain:
|
||||
# Set request state
|
||||
request.state.store = store
|
||||
request.state.store_id = store.id
|
||||
request.state.clean_path = "/shop/products" # Already clean
|
||||
request.state.clean_path = "/storefront/products" # Already clean
|
||||
```
|
||||
|
||||
**Request State After**:
|
||||
```python
|
||||
request.state.store = <Store: Orion>
|
||||
request.state.store_id = 1
|
||||
request.state.clean_path = "/shop/products"
|
||||
request.state.clean_path = "/storefront/products"
|
||||
```
|
||||
|
||||
### 4. Router Matching (FastAPI Native)
|
||||
@@ -117,18 +117,18 @@ request.state.clean_path = "/shop/products"
|
||||
**What happens**:
|
||||
- FastAPI matches the request path against registered routes
|
||||
- For path-based development mode, routes are registered with two prefixes:
|
||||
- `/shop/*` for subdomain/custom domain
|
||||
- `/stores/{store_code}/shop/*` for path-based development
|
||||
- `/storefront/*` for subdomain/custom domain
|
||||
- `/stores/{store_code}/storefront/*` for path-based development
|
||||
|
||||
**Example** (Path-Based Mode):
|
||||
|
||||
```python
|
||||
# In main.py - Double router mounting
|
||||
app.include_router(shop_pages.router, prefix="/shop")
|
||||
app.include_router(shop_pages.router, prefix="/stores/{store_code}/shop")
|
||||
app.include_router(storefront_pages.router, prefix="/storefront")
|
||||
app.include_router(storefront_pages.router, prefix="/stores/{store_code}/storefront")
|
||||
|
||||
# Request: /stores/ORION/shop/products
|
||||
# Matches: Second router (/stores/{store_code}/shop)
|
||||
# Request: /stores/ORION/storefront/products
|
||||
# Matches: Second router (/stores/{store_code}/storefront)
|
||||
# Route: @router.get("/products")
|
||||
# store_code available as path parameter = "ORION"
|
||||
```
|
||||
@@ -148,7 +148,7 @@ app.include_router(shop_pages.router, prefix="/stores/{store_code}/shop")
|
||||
|
||||
```python
|
||||
host = request.headers.get("host", "")
|
||||
path = request.state.clean_path # "/shop/products"
|
||||
path = request.state.clean_path # "/storefront/products"
|
||||
has_store = hasattr(request.state, 'store') and request.state.store
|
||||
|
||||
# FrontendDetector handles all detection logic centrally
|
||||
@@ -210,11 +210,11 @@ request.state.theme = {
|
||||
**Route Matching**:
|
||||
|
||||
```python
|
||||
# Request path (after rewrite): "/shop/products"
|
||||
# Request path (after rewrite): "/storefront/products"
|
||||
|
||||
# Matches this route
|
||||
@app.get("/shop/products")
|
||||
async def get_shop_products(request: Request):
|
||||
@app.get("/storefront/products")
|
||||
async def get_storefront_products(request: Request):
|
||||
# Handler code
|
||||
pass
|
||||
```
|
||||
@@ -254,7 +254,7 @@ async def shop_products_page(
|
||||
|
||||
### 9. Template Rendering (Jinja2)
|
||||
|
||||
**Template** (`templates/shop/products.html`):
|
||||
**Template** (`templates/storefront/products.html`):
|
||||
|
||||
```jinja2
|
||||
<!DOCTYPE html>
|
||||
@@ -322,7 +322,7 @@ async def shop_products_page(
|
||||
duration = time.time() - start_time # 0.143 seconds
|
||||
|
||||
logger.info(
|
||||
f"Response: 200 for GET /shop/products (0.143s)"
|
||||
f"Response: 200 for GET /storefront/products (0.143s)"
|
||||
)
|
||||
|
||||
# Add header
|
||||
@@ -397,7 +397,7 @@ sequenceDiagram
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant Client
|
||||
participant Client
|
||||
participant Logging
|
||||
participant Store
|
||||
participant Path
|
||||
@@ -412,7 +412,7 @@ sequenceDiagram
|
||||
Logging->>Store: Pass request
|
||||
Store->>DB: Query store by subdomain
|
||||
DB-->>Store: Store object
|
||||
Note over Store: Set store, store_id, clean_path
|
||||
Note over Store: Set store, store_id, clean_path
|
||||
Store->>Path: Pass request
|
||||
Note over Path: Path already clean
|
||||
Path->>Context: Pass request
|
||||
@@ -420,7 +420,7 @@ sequenceDiagram
|
||||
Note over Context: frontend_type = STOREFRONT
|
||||
Context->>Theme: Pass request
|
||||
Theme->>DB: Query theme
|
||||
DB-->>Theme: Theme config
|
||||
DB-->>Theme: Theme config
|
||||
Note over Theme: Set theme in request.state
|
||||
Theme->>Router: Route request
|
||||
Router->>Handler: Call handler
|
||||
@@ -431,7 +431,7 @@ sequenceDiagram
|
||||
```
|
||||
|
||||
## Request State Timeline
|
||||
|
||||
|
||||
Showing how `request.state` is built up through the middleware stack:
|
||||
|
||||
```
|
||||
@@ -445,14 +445,14 @@ After StoreContextMiddleware:
|
||||
}
|
||||
|
||||
After FrontendTypeMiddleware:
|
||||
{
|
||||
{
|
||||
store: <Store: Orion>,
|
||||
store_id: 1,
|
||||
clean_path: "/storefront/products",
|
||||
frontend_type: FrontendType.STOREFRONT
|
||||
}
|
||||
|
||||
After ThemeContextMiddleware:
|
||||
After ThemeContextMiddleware:
|
||||
{
|
||||
store: <Store: Orion>,
|
||||
store_id: 1,
|
||||
@@ -460,7 +460,7 @@ After ThemeContextMiddleware:
|
||||
frontend_type: FrontendType.STOREFRONT,
|
||||
theme: {
|
||||
primary_color: "#3B82F6",
|
||||
secondary_color: "#10B981",
|
||||
secondary_color: "#10B981",
|
||||
logo_url: "/static/stores/orion/logo.png",
|
||||
custom_css: "..."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user