diff --git a/MISSING-FEATURES-ANALYSIS.md b/MISSING-FEATURES-ANALYSIS.md new file mode 100644 index 00000000..6080c8f2 --- /dev/null +++ b/MISSING-FEATURES-ANALYSIS.md @@ -0,0 +1,456 @@ +# Missing Features Analysis - Comparison with Remote + +**Date:** December 23, 2025 +**Purpose:** Identify missing features from remote commits that could enhance our AIModelConfig system + +--- + +## Summary + +After reviewing remote commit documentation (especially 3283a83b and 9e8ff4fb), we found **4 global settings models** and associated admin functionality that we don't currently have. These are **optional** features for centralized platform management. + +--- + +## Missing Models + +### 1. GlobalIntegrationSettings ⭐ (Most Useful) + +**Purpose:** Store platform-wide API keys and default model/parameter settings + +**Current Status:** ❌ **NOT IMPLEMENTED** + +**What It Provides:** +```python +class GlobalIntegrationSettings(models.Model): + # API Keys (platform-wide) + openai_api_key = CharField() # Used by ALL accounts + dalle_api_key = CharField() # Can be same as OpenAI + anthropic_api_key = CharField() # For Claude + runware_api_key = CharField() # For image generation + + # Default Model Selections + openai_model = CharField(default='gpt-4-turbo-preview') + anthropic_model = CharField(default='claude-3-sonnet') + dalle_model = CharField(default='dall-e-3') + + # Default Parameters + openai_temperature = FloatField(default=0.7) + openai_max_tokens = IntegerField(default=8192) + dalle_size = CharField(default='1024x1024') + dalle_quality = CharField(default='standard') + dalle_style = CharField(default='vivid') + + # Metadata + is_active = BooleanField(default=True) + last_updated = DateTimeField(auto_now=True) + updated_by = ForeignKey(User) +``` + +**Benefits:** +- ✅ Single source for platform API keys +- ✅ Easier onboarding (copy from global defaults) +- ✅ Consistent default settings across accounts +- ✅ Admin can update keys without touching per-account settings + +**Trade-offs:** +- ⚠️ Less multi-tenant isolation (all accounts share keys) +- ⚠️ Potential rate limit conflicts between accounts +- ⚠️ Enterprise customers may prefer their own API keys + +**How It Would Work with AIModelConfig:** +```python +# Hybrid approach combining both systems: +GlobalIntegrationSettings: + - Stores API keys (centralized) + - Links to AIModelConfig for default models (default_text_model FK, default_image_model FK) + - Stores default parameters (temperature, max_tokens, etc.) + +AIModelConfig: + - Stores model pricing (cost_per_1k_tokens, tokens_per_credit) + - Multiple models per provider + - Database-driven model management + +IntegrationSettings (per-account): + - Links to AIModelConfig for account defaults + - Overrides parameters (temperature, max_tokens) + - Optional: Own API keys (enterprise feature) +``` + +**Recommendation:** ⏭️ **Optional - Add Later If Needed** +- Current per-account IntegrationSettings work well +- Can be added when centralized API key management becomes necessary +- Requires migration to add FK to AIModelConfig + +--- + +### 2. GlobalAIPrompt + +**Purpose:** Platform-wide default AI prompt templates library + +**Current Status:** ❌ **NOT IMPLEMENTED** + +**What It Provides:** +```python +class GlobalAIPrompt(models.Model): + prompt_type = CharField(choices=[ + 'clustering', 'ideas', 'content_generation', + 'image_prompt_extraction', 'image_prompt_template', + 'negative_prompt', 'site_structure_generation', + 'product_generation', 'service_generation', + 'taxonomy_generation' + ]) + prompt_value = TextField() # Default prompt template + description = TextField() # What this prompt does + variables = JSONField() # List of {variables} used + version = IntegerField(default=1) # Track changes + is_active = BooleanField(default=True) +``` + +**Benefits:** +- ✅ Centralized prompt management +- ✅ Easy to update prompts platform-wide +- ✅ Version tracking for prompt changes +- ✅ Accounts can clone and customize + +**How It Would Work:** +1. Admin creates global prompts in Django Admin +2. All accounts use global prompts by default +3. When user customizes, system creates AIPrompt record with: + - `default_prompt` = GlobalAIPrompt value (for reset) + - `prompt_value` = user's custom version + - `is_customized` = True +4. User can reset to global anytime + +**Current Alternative:** +- Prompts are likely hardcoded in service files +- No easy way to update prompts without code changes +- No version tracking + +**Recommendation:** ⭐ **Useful - Consider Adding** +- Would improve prompt management +- Estimated effort: 3-4 hours +- Requires migration + admin interface +- Would need to refactor existing prompt usage + +--- + +### 3. GlobalAuthorProfile + +**Purpose:** Platform-wide author persona/tone templates library + +**Current Status:** ❌ **NOT IMPLEMENTED** + +**What It Provides:** +```python +class GlobalAuthorProfile(models.Model): + name = CharField() # e.g., "SaaS B2B Professional" + description = TextField() # Writing style description + tone = CharField() # Professional, Casual, Technical + language = CharField(default='en') + structure_template = JSONField() # Content section structure + category = CharField(choices=[ + 'saas', 'ecommerce', 'blog', 'technical', + 'creative', 'news', 'academic' + ]) + is_active = BooleanField(default=True) +``` + +**Benefits:** +- ✅ Pre-built writing personas for common industries +- ✅ Consistent tone across similar accounts +- ✅ Accounts can clone and customize +- ✅ Faster onboarding + +**Current Alternative:** +- Likely per-account AuthorProfile creation only +- No platform-wide templates to start from + +**Recommendation:** ⏭️ **Optional - Nice to Have** +- Not critical for core functionality +- More of a user experience enhancement +- Estimated effort: 2-3 hours + +--- + +### 4. GlobalStrategy + +**Purpose:** Platform-wide content strategy templates library + +**Current Status:** ❌ **NOT IMPLEMENTED** + +**What It Provides:** +```python +class GlobalStrategy(models.Model): + name = CharField() # e.g., "SEO Blog Post Strategy" + description = TextField() # What this strategy achieves + prompt_types = JSONField() # List of prompts to use + section_logic = JSONField() # Section generation logic + category = CharField(choices=[ + 'blog', 'ecommerce', 'saas', 'news', + 'technical', 'marketing' + ]) + is_active = BooleanField(default=True) +``` + +**Benefits:** +- ✅ Pre-built content strategies +- ✅ Accounts can clone and customize +- ✅ Consistent approach for similar content types + +**Current Alternative:** +- Per-account Strategy creation +- No platform-wide templates + +**Recommendation:** ⏭️ **Optional - Nice to Have** +- Similar to GlobalAuthorProfile +- UX enhancement rather than critical feature +- Estimated effort: 2-3 hours + +--- + +## Missing Admin Features + +### 1. Admin Monitoring Dashboard + +**What's Missing:** +- System health monitoring view +- API status indicators +- Debug console for testing API calls +- Real-time connection testing + +**Current Status:** ❌ **NOT IN PLAN** + +**Would Provide:** +- Live API connectivity status +- Quick API key testing +- Error diagnostics +- System health overview + +**Recommendation:** ⏭️ **Optional - Future Enhancement** +- Useful for ops/support team +- Not critical for core functionality +- Estimated effort: 6-8 hours + +--- + +### 2. Bulk Actions in Global Admin + +**What's in Remote:** +```python +# GlobalAIPromptAdmin +- increment_version: Bump version for selected prompts +- bulk_activate/deactivate: Enable/disable prompts + +# GlobalAuthorProfileAdmin +- bulk_clone: Clone profiles for accounts +- bulk_activate/deactivate + +# GlobalStrategyAdmin +- bulk_clone: Clone strategies for accounts +- bulk_activate/deactivate +``` + +**Current Status:** ⚠️ **Partially Implemented** +- We have bulk actions for regular admin models +- No global models to apply them to yet + +--- + +## Frontend Missing Features + +### 1. Integration Settings UI + +**What's in Remote:** +- Frontend page: `/settings/integration` +- View showing: + - Current model selection (from global OR account override) + - "Using platform defaults" badge + - "Custom settings" badge + - Model dropdown, temperature slider, max_tokens input + - **API keys NOT shown** (security - stored in backend only) + +**Current Status:** ⚠️ **Check if exists** + +**How It Works:** +```javascript +GET /api/v1/system/settings/integrations/openai/ +Response: { + "id": "openai", + "enabled": true, + "model": "gpt-4o-mini", // From global OR account + "temperature": 0.7, // From global OR account + "max_tokens": 8192, // From global OR account + "using_global": true // Flag +} + +PUT /api/v1/system/settings/integrations/openai/ +Body: { + "model": "gpt-4o", + "temperature": 0.8, + "max_tokens": 8192 +} +// Backend strips ANY API keys, saves ONLY overrides +``` + +**Recommendation:** ⭐ **Check if Exists, Otherwise Add** +- Important for user experience +- Lets accounts customize model selection +- Works with our AIModelConfig system +- Estimated effort: 4-6 hours if missing + +--- + +### 2. Module Settings UI + +**Status:** ✅ **ALREADY IMPLEMENTED** +- Commit 029c30ae added module settings UI +- `frontend/src/store/moduleStore.ts` exists +- Connects to GlobalModuleSettings backend + +--- + +## Backend API Endpoints + +### Missing Endpoints (if they don't exist): + +1. **Integration Settings API** +```python +GET /api/v1/system/settings/integrations/{integration_type}/ +PUT /api/v1/system/settings/integrations/{integration_type}/ +POST /api/v1/system/settings/integrations/test-connection/ +``` + +2. **Global Settings Access** (admin only) +```python +GET /api/v1/admin/global-settings/ +PUT /api/v1/admin/global-settings/ +``` + +3. **Module Settings API** ✅ (may exist) +```python +GET /api/v1/system/module-settings/ +``` + +--- + +## Recommendations by Priority + +### High Priority (Do Soon) +1. ⭐ **Integration Settings Frontend** (if missing) + - Check if page exists at `/settings/integration` + - If not, create UI for model/parameter customization + - Effort: 4-6 hours + - Works with existing IntegrationSettings model + +### Medium Priority (Consider Adding) +2. ⭐ **GlobalAIPrompt Model** + - Centralized prompt management + - Version tracking + - Effort: 3-4 hours + - Improves maintainability + +3. ⏭️ **GlobalIntegrationSettings Model** + - Only if centralized API keys needed + - Hybrid with AIModelConfig FKs + - Effort: 6-8 hours + - Trade-off: less multi-tenant isolation + +### Low Priority (Optional) +4. ⏭️ **GlobalAuthorProfile Model** + - UX enhancement + - Effort: 2-3 hours + +5. ⏭️ **GlobalStrategy Model** + - UX enhancement + - Effort: 2-3 hours + +6. ⏭️ **Admin Monitoring Dashboard** + - Ops/support tool + - Effort: 6-8 hours + +--- + +## What We Already Have ✅ + +1. ✅ **AIModelConfig** - Superior to remote's hardcoded model choices +2. ✅ **GlobalModuleSettings** - Platform-wide module toggles +3. ✅ **IntegrationSettings** - Per-account model/parameter overrides +4. ✅ **Token Analytics Reports** - Comprehensive reporting +5. ✅ **Admin Organization** - 12 logical groups +6. ✅ **Bulk Actions** - 11 admin models enhanced +7. ✅ **Module Settings UI** - Frontend + backend complete + +--- + +## Architecture Comparison + +### Remote Architecture (From 3283a83b) +``` +GlobalIntegrationSettings (API keys + defaults) + ↓ +IntegrationSettings (per-account overrides) + ↓ +Services use: Global API key + Account model/params +``` + +### Our Current Architecture +``` +AIModelConfig (database-driven model pricing) + ↓ +IntegrationSettings (per-account defaults + FK to AIModelConfig) + ↓ +CreditService.get_model_for_operation() (4-level priority) + ↓ +Services use: Account API key + Selected AIModelConfig +``` + +### Hybrid Architecture (If We Add GlobalIntegrationSettings) +``` +GlobalIntegrationSettings (API keys + FK to AIModelConfig for defaults) + ↓ +AIModelConfig (model pricing, multiple models per provider) + ↓ +IntegrationSettings (per-account: FK to AIModelConfig + parameter overrides) + ↓ +CreditService.get_model_for_operation() (5-level priority including global) + ↓ +Services use: Global/Account API key + Selected AIModelConfig +``` + +--- + +## Next Steps + +### Immediate (Today) +1. ✅ Document missing features (this file) +2. 🔍 Check if Integration Settings UI exists in frontend + - Look for: `/settings/integration` route + - Check: `frontend/src/pages/Settings/Integration.tsx` +3. 🔍 Check if Integration Settings API exists + - Look for: `/api/v1/system/settings/` endpoints + +### Short-term (This Week) +1. If missing: Add Integration Settings UI +2. Consider: GlobalAIPrompt model for centralized prompts + +### Long-term (If Needed) +1. Consider: GlobalIntegrationSettings for centralized API keys +2. Consider: Admin monitoring dashboard +3. Consider: GlobalAuthorProfile and GlobalStrategy templates + +--- + +## Conclusion + +We have successfully implemented the core token-based billing system with AIModelConfig, which is **superior** to the remote's hardcoded model choices. The main missing features are: + +1. **GlobalIntegrationSettings** - Optional, useful for centralized API key management +2. **GlobalAIPrompt** - Useful for centralized prompt management +3. **Integration Settings UI** - Important for UX (need to check if exists) +4. **GlobalAuthorProfile/GlobalStrategy** - Optional UX enhancements + +Our current architecture is production-ready. The missing features are **optional enhancements** that can be added incrementally based on business needs. + +**Total Estimated Effort for All Missing Features:** 20-30 hours + +**Recommended Next Action:** Check if Integration Settings UI exists, as it's the most user-facing feature.