docs: add feature gating system documentation
- Add comprehensive feature-gating-system.md documenting: - Database models (Feature, VendorFeatureOverride) - 30 features across 8 categories with tier requirements - FeatureService and UsageService APIs - Backend enforcement (decorator, dependency patterns) - Frontend integration (Alpine stores, Jinja macros) - Admin and vendor API endpoints - Update subscription-workflow-plan.md with completion status - Add feature-gating-system.md to mkdocs.yml navigation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -294,61 +294,114 @@ class VendorAddOn(Base):
|
||||
|
||||
## 5. Implementation Phases
|
||||
|
||||
### Phase 1: Database & Core (Day 1-2)
|
||||
- [ ] Add `tier_id` FK to VendorSubscription
|
||||
- [ ] Create migration with data backfill
|
||||
- [ ] Update subscription service to use tier relationship
|
||||
- [ ] Update admin subscription endpoints
|
||||
**Last Updated:** December 31, 2025
|
||||
|
||||
### Phase 2: Admin Vendor Page (Day 2-3)
|
||||
- [ ] Add subscription card to vendor detail page
|
||||
- [ ] Show usage meters (orders, products, team)
|
||||
### Phase 1: Database & Core (COMPLETED)
|
||||
- [x] Add `tier_id` FK to VendorSubscription
|
||||
- [x] Create migration with data backfill
|
||||
- [x] Update subscription service to use tier relationship
|
||||
- [x] Update admin subscription endpoints
|
||||
- [x] **NEW:** Add Feature model with 30 features across 8 categories
|
||||
- [x] **NEW:** Create FeatureService with caching for tier-based feature checking
|
||||
- [x] **NEW:** Add UsageService for limit tracking and upgrade recommendations
|
||||
|
||||
### Phase 2: Admin Vendor Page (PARTIALLY COMPLETE)
|
||||
- [x] Add subscription card to vendor detail page
|
||||
- [x] Show usage meters (orders, products, team)
|
||||
- [ ] Add "Edit Subscription" modal
|
||||
- [ ] Implement tier change API (admin)
|
||||
- [x] **NEW:** Add Admin Features page (`/admin/features`)
|
||||
- [x] **NEW:** Admin features API (list, update, toggle)
|
||||
|
||||
### Phase 3: Vendor Billing Page (Day 3-4)
|
||||
- [ ] Create `/vendor/{code}/billing` page
|
||||
- [ ] Show current plan and usage
|
||||
- [ ] Add tier comparison/change UI
|
||||
- [ ] Implement tier change API (vendor)
|
||||
- [ ] Add Stripe checkout integration for upgrades
|
||||
### Phase 3: Vendor Billing Page (COMPLETED)
|
||||
- [x] Create `/vendor/{code}/billing` page
|
||||
- [x] Show current plan and usage
|
||||
- [x] Add tier comparison/change UI
|
||||
- [x] Implement tier change API (vendor)
|
||||
- [x] Add Stripe checkout integration for upgrades
|
||||
- [x] **NEW:** Add feature gate macros for templates
|
||||
- [x] **NEW:** Add Alpine.js feature store
|
||||
- [x] **NEW:** Add Alpine.js upgrade prompts store
|
||||
- [x] **FIX:** Resolved 89 JS architecture violations (JS-005 through JS-009)
|
||||
|
||||
### Phase 4: Add-ons (Day 4-5)
|
||||
- [ ] Seed add-on products in database
|
||||
- [ ] Add "Available Add-ons" section to billing page
|
||||
- [ ] Implement add-on purchase flow
|
||||
- [ ] Create VendorAddOn management
|
||||
- [ ] Add contextual upsell prompts
|
||||
### Phase 4: Add-ons (COMPLETED)
|
||||
- [x] Seed add-on products in database
|
||||
- [x] Add "Available Add-ons" section to billing page
|
||||
- [x] Implement add-on purchase flow
|
||||
- [x] Create VendorAddOn management (via billing page)
|
||||
- [x] Add contextual upsell prompts
|
||||
- [x] **FIX:** Fix Stripe webhook to create VendorAddOn records
|
||||
|
||||
### Phase 5: Polish & Testing (Day 5-6)
|
||||
### Phase 5: Polish & Testing (IN PROGRESS)
|
||||
- [ ] Email notifications for tier changes
|
||||
- [ ] Webhook handling for Stripe events
|
||||
- [ ] Usage limit enforcement updates
|
||||
- [ ] End-to-end testing
|
||||
- [ ] Documentation
|
||||
- [x] Webhook handling for Stripe events
|
||||
- [x] Usage limit enforcement updates
|
||||
- [ ] End-to-end testing (manual testing required)
|
||||
- [x] Documentation (feature-gating-system.md created)
|
||||
|
||||
### Phase 6: Remaining Work (NEW)
|
||||
- [ ] Admin tier change modal (upgrade/downgrade vendors)
|
||||
- [ ] Admin subscription override UI (custom limits for enterprise)
|
||||
- [ ] Trial extension from admin panel
|
||||
- [ ] Email notifications for tier changes
|
||||
- [ ] Email notifications for approaching limits
|
||||
- [ ] Grace period handling for failed payments
|
||||
- [ ] Integration tests for full billing workflow
|
||||
- [ ] Stripe test mode checkout verification
|
||||
|
||||
---
|
||||
|
||||
## 6. Files to Create/Modify
|
||||
## 6. Files Created/Modified
|
||||
|
||||
### New Files
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `app/templates/vendor/billing.html` | Vendor billing page |
|
||||
| `static/vendor/js/billing.js` | Billing page JS |
|
||||
| `app/api/v1/vendor/billing.py` | Vendor billing endpoints |
|
||||
| `app/services/addon_service.py` | Add-on management |
|
||||
**Last Updated:** December 31, 2025
|
||||
|
||||
### New Files (Created)
|
||||
| File | Purpose | Status |
|
||||
|------|---------|--------|
|
||||
| `app/templates/vendor/billing.html` | Vendor billing page | DONE |
|
||||
| `static/vendor/js/billing.js` | Billing page JS | DONE |
|
||||
| `app/api/v1/vendor/billing.py` | Vendor billing endpoints | DONE |
|
||||
| `models/database/feature.py` | Feature & VendorFeatureOverride models | DONE |
|
||||
| `app/services/feature_service.py` | Feature access control service | DONE |
|
||||
| `app/services/usage_service.py` | Usage tracking & limits service | DONE |
|
||||
| `app/core/feature_gate.py` | @require_feature decorator & dependency | DONE |
|
||||
| `app/api/v1/vendor/features.py` | Vendor features API | DONE |
|
||||
| `app/api/v1/vendor/usage.py` | Vendor usage API | DONE |
|
||||
| `app/api/v1/admin/features.py` | Admin features API | DONE |
|
||||
| `app/templates/admin/features.html` | Admin features management page | DONE |
|
||||
| `app/templates/shared/macros/feature_gate.html` | Jinja2 feature gate macros | DONE |
|
||||
| `static/shared/js/feature-store.js` | Alpine.js feature store | DONE |
|
||||
| `static/shared/js/upgrade-prompts.js` | Alpine.js upgrade prompts | DONE |
|
||||
| `alembic/versions/n2c3d4e5f6a7_add_features_table.py` | Features migration | DONE |
|
||||
| `docs/implementation/feature-gating-system.md` | Feature gating documentation | DONE |
|
||||
|
||||
### Modified Files
|
||||
| File | Changes |
|
||||
|------|---------|
|
||||
| `models/database/subscription.py` | Add tier_id FK |
|
||||
| `app/templates/admin/vendor-detail.html` | Add subscription card |
|
||||
| `static/admin/js/vendor-detail.js` | Load subscription data |
|
||||
| `app/api/v1/admin/vendors.py` | Include subscription in response |
|
||||
| `app/api/v1/admin/subscriptions.py` | Add tier change endpoint |
|
||||
| `app/services/subscription_service.py` | Tier change logic |
|
||||
| `app/templates/vendor/partials/sidebar.html` | Add Billing link |
|
||||
| File | Changes | Status |
|
||||
|------|---------|--------|
|
||||
| `models/database/subscription.py` | Add tier_id FK | DONE |
|
||||
| `models/database/__init__.py` | Export Feature models | DONE |
|
||||
| `app/templates/admin/vendor-detail.html` | Add subscription card | DONE |
|
||||
| `static/admin/js/vendor-detail.js` | Load subscription data | DONE |
|
||||
| `app/api/v1/admin/vendors.py` | Include subscription in response | DONE |
|
||||
| `app/api/v1/admin/__init__.py` | Register features router | DONE |
|
||||
| `app/api/v1/vendor/__init__.py` | Register features/usage routers | DONE |
|
||||
| `app/services/subscription_service.py` | Tier change logic | DONE |
|
||||
| `app/templates/vendor/partials/sidebar.html` | Add Billing link | DONE |
|
||||
| `app/templates/vendor/base.html` | Load feature/upgrade stores | DONE |
|
||||
| `app/templates/vendor/dashboard.html` | Add tier badge & usage bars | DONE |
|
||||
| `app/handlers/stripe_webhook.py` | Create VendorAddOn on purchase | DONE |
|
||||
| `app/routes/admin_pages.py` | Add features page route | DONE |
|
||||
| `static/shared/js/api-client.js` | Add postFormData() & getBlob() | DONE |
|
||||
|
||||
### Architecture Fixes (48 files)
|
||||
| Rule | Files Fixed | Description |
|
||||
|------|-------------|-------------|
|
||||
| JS-003 | billing.js | Rename billingData→vendorBilling |
|
||||
| JS-005 | 15 files | Add init guards |
|
||||
| JS-006 | 39 files | Add try/catch to async init |
|
||||
| JS-008 | 5 files | Use apiClient not fetch |
|
||||
| JS-009 | 30 files | Use Utils.showToast |
|
||||
| TPL-009 | validate_architecture.py | Check vendor templates too |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user