223 lines
6.9 KiB
Markdown
223 lines
6.9 KiB
Markdown
# IGNY8 Multi-Tenancy Documentation
|
|
|
|
**Last Updated:** December 9, 2024
|
|
|
|
## 📚 Documentation Structure
|
|
|
|
This directory contains comprehensive documentation for the IGNY8 multi-tenancy system. All scattered documentation has been consolidated into organized, maintainable files.
|
|
|
|
### Core Documentation Files
|
|
|
|
#### 1. **TENANCY-CHANGE-LOG.md** (334 lines)
|
|
Complete changelog of all changes made during the current session and last 2 git commits.
|
|
|
|
**Contents:**
|
|
- Recent Session Changes (Dec 9, 2024)
|
|
- JWT token generation fixes
|
|
- Payment modal amount display fixes
|
|
- Payment approval workflow automation
|
|
- Site creation permission fixes
|
|
- Git Commit History
|
|
- Commit 4d13a570: Payment methods restructuring
|
|
- Commit 72d0b6b0: Tenancy fixes and improvements
|
|
|
|
**Use this for:** Understanding what changed, when, and why.
|
|
|
|
---
|
|
|
|
#### 2. **TENANCY-IMPLEMENTATION-GUIDE.md** (1,584 lines)
|
|
Complete technical implementation documentation without code snippets.
|
|
|
|
**Contents:**
|
|
- Section 1: Architecture Overview
|
|
- Section 2: Core Data Models (9 models explained)
|
|
- Section 3: Authentication System
|
|
- Section 4: Payment Processing Workflows
|
|
- Section 5: Multi-Currency System
|
|
- Section 6: Site & Sector Management
|
|
- Section 7: Credit System
|
|
- Section 8: Admin Workflows
|
|
- Section 9: API Endpoints Summary
|
|
- Section 10: Security & Permissions
|
|
|
|
**Use this for:** Understanding how the system is implemented, business logic, function purposes, and technical architecture.
|
|
|
|
---
|
|
|
|
#### 3. **TENANCY-DATA-FLOW.md** (1,426 lines)
|
|
Visual data flow diagrams for all critical workflows.
|
|
|
|
**Contents:**
|
|
- Flow 1: Free Trial Signup
|
|
- Flow 2: Paid Signup
|
|
- Flow 3: Payment Confirmation
|
|
- Flow 4: Payment Approval (Admin)
|
|
- Flow 5: Site Creation
|
|
- Flow 6: Sector Selection
|
|
- Flow 7: Credit Allocation
|
|
- Flow 8: Currency Conversion
|
|
- Flow 9: Authentication (Login/Register/Refresh)
|
|
- Flow 10: Complete End-to-End User Journey
|
|
|
|
**Use this for:** Understanding workflow sequences, decision trees, state transitions, and user journeys.
|
|
|
|
---
|
|
|
|
## 🎯 Quick Navigation
|
|
|
|
### For New Developers
|
|
Start with:
|
|
1. **TENANCY-IMPLEMENTATION-GUIDE.md** - Section 1 (Architecture Overview)
|
|
2. **TENANCY-DATA-FLOW.md** - Flow 10 (Complete Journey)
|
|
3. **TENANCY-IMPLEMENTATION-GUIDE.md** - Section 2 (Core Models)
|
|
|
|
### For Bug Fixes
|
|
Check:
|
|
1. **TENANCY-CHANGE-LOG.md** - See recent changes
|
|
2. **TENANCY-IMPLEMENTATION-GUIDE.md** - Find relevant section
|
|
3. **TENANCY-DATA-FLOW.md** - Understand expected flow
|
|
|
|
### For Feature Development
|
|
Reference:
|
|
1. **TENANCY-DATA-FLOW.md** - Understand existing workflows
|
|
2. **TENANCY-IMPLEMENTATION-GUIDE.md** - Review related systems
|
|
3. **TENANCY-CHANGE-LOG.md** - Check for recent related changes
|
|
|
|
---
|
|
|
|
## 🔍 Key Concepts Quick Reference
|
|
|
|
### Account Status States
|
|
- `pending_payment` - Paid plan, awaiting payment approval
|
|
- `trial` - Free trial active
|
|
- `active` - Paid and approved
|
|
- `suspended` - Payment issues or policy violation
|
|
- `cancelled` - User requested cancellation
|
|
- `expired` - Subscription ended
|
|
|
|
### Subscription Status States
|
|
- `incomplete` - Created but payment pending
|
|
- `active` - Currently active
|
|
- `past_due` - Payment failed
|
|
- `cancelled` - User cancelled
|
|
- `expired` - Period ended without renewal
|
|
|
|
### Payment Status States
|
|
- `pending_approval` - Manual payment submitted, needs admin review
|
|
- `succeeded` - Payment approved and processed
|
|
- `failed` - Payment failed or rejected
|
|
- `refunded` - Payment refunded to user
|
|
|
|
### User Roles (Hierarchical)
|
|
1. `developer` - Full system access
|
|
2. `owner` - Account owner, full account access
|
|
3. `admin` - Administrative access
|
|
4. `editor` - Can create/edit content
|
|
5. `viewer` - Read-only access
|
|
6. `system_bot` - Automated processes
|
|
|
|
---
|
|
|
|
## 🛠️ Common Tasks
|
|
|
|
### How to Add a New Payment Method
|
|
See: **TENANCY-IMPLEMENTATION-GUIDE.md** → Section 4.1 (Payment Methods Configuration)
|
|
|
|
### How to Change Plan Pricing
|
|
See: **TENANCY-IMPLEMENTATION-GUIDE.md** → Section 2.2 (Plan Model)
|
|
|
|
### How to Add a New Currency
|
|
See: **TENANCY-IMPLEMENTATION-GUIDE.md** → Section 5.1 (Currency Configuration)
|
|
|
|
### How to Approve Manual Payments
|
|
See: **TENANCY-DATA-FLOW.md** → Flow 4 (Payment Approval)
|
|
|
|
### How Credits Work
|
|
See: **TENANCY-IMPLEMENTATION-GUIDE.md** → Section 7 (Credit System)
|
|
|
|
---
|
|
|
|
## 📊 System Metrics
|
|
|
|
### Database Models
|
|
- **9 Core Models** documented
|
|
- **15+ Supporting Models** in use
|
|
- **Account-based isolation** on all tenant data
|
|
|
|
### API Endpoints
|
|
- **15+ REST endpoints** documented
|
|
- **JWT authentication** on all protected routes
|
|
- **Multi-currency support** for 8 countries
|
|
|
|
### Payment Methods
|
|
- **15+ payment methods** configured
|
|
- **8 countries** supported
|
|
- **Manual approval workflow** implemented
|
|
|
|
---
|
|
|
|
## 🚀 Recent Improvements (Dec 9, 2024)
|
|
|
|
### 1. Authentication Fixed
|
|
**Problem:** Users logged out immediately after signup
|
|
**Solution:** Generate JWT tokens in RegisterView
|
|
**Impact:** Seamless signup-to-login experience
|
|
|
|
### 2. Payment Modal Fixed
|
|
**Problem:** Amount showing PKR 0.00
|
|
**Solution:** API returns both `total` and `total_amount` fields
|
|
**Impact:** Correct amounts displayed to users
|
|
|
|
### 3. Payment Approval Automated
|
|
**Problem:** Admin approval didn't activate accounts
|
|
**Solution:** Enhanced save_model() with full workflow
|
|
**Impact:** One-click approval activates everything
|
|
|
|
### 4. Site Creation Fixed
|
|
**Problem:** Permission errors and domain validation failures
|
|
**Solution:** Fixed permission class instantiation and domain validator
|
|
**Impact:** Users can create sites without errors
|
|
|
|
---
|
|
|
|
## 📝 Documentation Standards
|
|
|
|
### Established Patterns
|
|
- **No code snippets** - Focus on business logic and function names
|
|
- **Chunked sections** - 300-400 lines per section for readability
|
|
- **Tables for data** - Structured information in tables
|
|
- **Visual flows** - ASCII diagrams for workflows
|
|
- **Clear hierarchy** - Numbered sections with clear headings
|
|
|
|
### Maintenance Guidelines
|
|
- **Update TENANCY-CHANGE-LOG.md** after every significant change
|
|
- **Update flow diagrams** when workflows change
|
|
- **Update implementation guide** when new features added
|
|
- **Keep README.md** current with navigation links
|
|
|
|
---
|
|
|
|
## 🗂️ Archived Documentation
|
|
|
|
Old documentation files have been removed. Historical reference available in git history:
|
|
- `IMPLEMENTATION-PLAN-SIGNUP-TO-PAYMENT-WORKFLOW.md` (Replaced)
|
|
- `TENANCY-WORKFLOW-DOCUMENTATION.md` (Replaced)
|
|
- `CRITICAL-GAPS-SIGNUP-TO-SITE-WORKFLOW.md` (Addressed in new docs)
|
|
- `in-progress/` folder contents (Consolidated)
|
|
|
|
---
|
|
|
|
## 📧 Questions or Issues?
|
|
|
|
For questions about:
|
|
- **Architecture** → See TENANCY-IMPLEMENTATION-GUIDE.md Section 1
|
|
- **Workflows** → See TENANCY-DATA-FLOW.md
|
|
- **Recent Changes** → See TENANCY-CHANGE-LOG.md
|
|
- **API Usage** → See TENANCY-IMPLEMENTATION-GUIDE.md Section 9
|
|
|
|
---
|
|
|
|
**Total Documentation:** 3,344 lines across 4 files
|
|
**Coverage:** Complete multi-tenancy system from signup to content generation
|
|
**Maintenance:** Active, updated with every significant change
|