Fixed url pattern in the doc for path-based shops

This commit is contained in:
2025-11-18 23:18:13 +01:00
parent b3009e3795
commit f14686c131
8 changed files with 68 additions and 52 deletions

View File

@@ -8,6 +8,11 @@ The Wizamart platform supports **three deployment modes** for multi-tenancy, all
**Key Concept**: One application, multiple isolated vendor shops, each accessible via different URLs.
**Important Distinction:**
- **Vendor Dashboard** (all modes): `/vendor/{code}/*` (singular) - Management interface for vendors
- **Shop Storefront** (path-based only): `/vendors/{code}/shop/*` (plural) - Customer-facing shop
- This naming distinction helps separate administrative routes from public-facing shop routes
## The Three Routing Modes
### 1. Custom Domain Mode
@@ -75,9 +80,9 @@ id | code | name
**Example**:
```
platform.com/vendor/vendor1/shop → Vendor 1 Shop
platform.com/vendor/vendor2/shop → Vendor 2 Shop
platform.com/vendors/vendor3/shop → Vendor 3 Shop (alternative)
platform.com/vendors/vendor1/shop → Vendor 1 Shop
platform.com/vendors/vendor2/shop → Vendor 2 Shop
platform.com/vendors/vendor3/shop → Vendor 3 Shop
```
**How it works**:
@@ -86,12 +91,11 @@ platform.com/vendors/vendor3/shop → Vendor 3 Shop (alternative)
3. Path is rewritten for routing
4. All vendors on same domain
**Use Case**: Simplest deployment, single domain certificate
**Use Case**: Development and testing environments only
**Path Patterns**:
- `/vendor/{code}/shop/*` - Storefront pages
- `/vendor/{code}/api/*` - API endpoints (if needed)
- `/vendors/{code}/shop/*` - Alternative pattern
- `/vendors/{code}/shop/*` - Storefront pages (correct pattern)
- `/vendor/{code}/*` - Vendor dashboard pages (different context)
## Routing Mode Comparison
@@ -142,20 +146,22 @@ def detect_vendor(request):
For path-based routing, clean paths are extracted:
**Example 1**: Single vendor prefix
```
Original: /vendor/WIZAMART/shop/products
Extracted: vendor_code = "WIZAMART"
Clean: /shop/products
```
**Example 2**: Plural vendors prefix
**Path-Based Shop Routes** (Development):
```
Original: /vendors/WIZAMART/shop/products
Extracted: vendor_code = "WIZAMART"
Clean: /shop/products
```
**Vendor Dashboard Routes** (All environments):
```
Original: /vendor/WIZAMART/dashboard
Extracted: vendor_code = "WIZAMART"
Clean: /dashboard
```
**Note**: The shop storefront uses `/vendors/` (plural) while the vendor dashboard uses `/vendor/` (singular). This distinction helps separate customer-facing shop routes from vendor management routes.
**Why Clean Path?**
- FastAPI routes don't include vendor prefix
- Routes defined as: `@app.get("/shop/products")`
@@ -214,9 +220,9 @@ INSERT INTO vendor_domains (vendor_id, domain) VALUES
**URLs**:
```
myplatform.com/admin
myplatform.com/vendor/shop1/shop
myplatform.com/vendor/shop2/shop
myplatform.com/vendor/shop3/shop
myplatform.com/vendors/shop1/shop
myplatform.com/vendors/shop2/shop
myplatform.com/vendors/shop3/shop
```
**Infrastructure**:
@@ -266,8 +272,8 @@ shop3.myplatform.com → Vendor 3
shop4.myplatform.com → Vendor 4
# Path-based (free tier)
myplatform.com/vendor/shop5/shop → Vendor 5
myplatform.com/vendor/shop6/shop → Vendor 6
myplatform.com/vendors/shop5/shop → Vendor 5
myplatform.com/vendors/shop6/shop → Vendor 6
```
**Infrastructure**:
@@ -433,7 +439,7 @@ Host: wizamart.myplatform.com
**Request**:
```http
GET /vendor/WIZAMART/shop/products HTTP/1.1
GET /vendors/WIZAMART/shop/products HTTP/1.1
Host: myplatform.com
```