From a622a3ffe30c7bcdc2e4d367c69dad4ec496ca5e Mon Sep 17 00:00:00 2001 From: alorig <220087330+alorig@users.noreply.github.com> Date: Sun, 9 Nov 2025 23:16:15 +0500 Subject: [PATCH] 1 --- docs/AI-ELEMENTS-TABLE.md | 128 -------- docs/{ => AI-NEW-DESIGN}/07-AI-FRAMEWORK.md | 0 .../STAGE1-REORGANIZATION-COMPLETE.md | 0 .../STAGE2-EXECUTION-LOGGING-COMPLETE.md | 0 .../STAGE3-LOGGING-COMPLETE.md | 0 .../STAGE4-PROMPT-REGISTRY-COMPLETE.md | 0 docs/ActiveDocs/AI-ELEMENTS-EXTRACTED.md | 300 ------------------ docs/ActiveDocs/COLOR-TOKENS-COMPARISON.md | 121 ------- docs/{ => Architecture}/01-ARCHITECTURE.md | 0 .../{ => Architecture}/MASTER-ARCHITECTURE.md | 0 docs/verify-venv-dependencies.sh | 149 --------- 11 files changed, 698 deletions(-) delete mode 100644 docs/AI-ELEMENTS-TABLE.md rename docs/{ => AI-NEW-DESIGN}/07-AI-FRAMEWORK.md (100%) rename docs/{ActiveDocs => AI-NEW-DESIGN}/STAGE1-REORGANIZATION-COMPLETE.md (100%) rename docs/{ActiveDocs => AI-NEW-DESIGN}/STAGE2-EXECUTION-LOGGING-COMPLETE.md (100%) rename docs/{ActiveDocs => AI-NEW-DESIGN}/STAGE3-LOGGING-COMPLETE.md (100%) rename docs/{ActiveDocs => AI-NEW-DESIGN}/STAGE4-PROMPT-REGISTRY-COMPLETE.md (100%) delete mode 100644 docs/ActiveDocs/AI-ELEMENTS-EXTRACTED.md delete mode 100644 docs/ActiveDocs/COLOR-TOKENS-COMPARISON.md rename docs/{ => Architecture}/01-ARCHITECTURE.md (100%) rename docs/{ => Architecture}/MASTER-ARCHITECTURE.md (100%) delete mode 100644 docs/verify-venv-dependencies.sh diff --git a/docs/AI-ELEMENTS-TABLE.md b/docs/AI-ELEMENTS-TABLE.md deleted file mode 100644 index 2e3d37a6..00000000 --- a/docs/AI-ELEMENTS-TABLE.md +++ /dev/null @@ -1,128 +0,0 @@ -# AI-Related Elements Across Codebase - -Complete table of all AI-related logic, configs, prompts, validations, retries, logging, response parsing, etc. - -| Type | Name / Key | File | Function / Class | Line No | Notes | -|------|------------|------|------------------|---------|-------| -| **๐Ÿง  AI Core Functions** | -| AI Core | `_auto_cluster_keywords_core` | `backend/igny8_core/modules/planner/tasks.py` | `_auto_cluster_keywords_core()` | 26 | Core clustering logic (legacy, used by old tasks) | -| AI Core | `_generate_single_idea_core` | `backend/igny8_core/modules/planner/tasks.py` | `_generate_single_idea_core()` | 1047 | Core idea generation logic (legacy) | -| AI Core | `auto_generate_content_task` | `backend/igny8_core/modules/writer/tasks.py` | `auto_generate_content_task()` | 27 | Celery task for content generation (legacy) | -| AI Core | `AutoClusterFunction` | `backend/igny8_core/ai/functions/auto_cluster.py` | `AutoClusterFunction` class | 14 | New framework function for clustering | -| AI Core | `cluster_keywords` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor.cluster_keywords()` | 1080 | Legacy clustering method | -| AI Core | `generate_ideas` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor.generate_ideas()` | 1280 | Legacy idea generation method | -| AI Core | `generate_content` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor.generate_content()` | 446 | Legacy content generation method | -| AI Core | `generate_image` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor.generate_image()` | 656 | Image generation (OpenAI DALL-E / Runware) | -| AI Core | `generate_image` | `backend/igny8_core/ai/processor.py` | `AIProcessor.generate_image()` | 61 | Framework wrapper for image generation | -| AI Core | `run_ai_task` | `backend/igny8_core/ai/tasks.py` | `run_ai_task()` | 13 | Unified Celery entrypoint for all AI functions | -| AI Core | `AIEngine.execute` | `backend/igny8_core/ai/engine.py` | `AIEngine.execute()` | 26 | Central orchestrator for all AI functions | -| **๐Ÿ” Retry / Model Fallback Logic** | -| Retry | `_call_openai` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor._call_openai()` | 125 | Main OpenAI API call method with error handling | -| Retry | `_get_api_key` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor._get_api_key()` | 73 | Gets API key from IntegrationSettings or Django settings (fallback) | -| Retry | `_get_model` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor._get_model()` | 98 | Gets model from IntegrationSettings or Django settings (fallback) | -| Retry | `max_retries=3` | `backend/igny8_core/ai/tasks.py` | `@shared_task(bind=True, max_retries=3)` | 12 | Celery task retry configuration | -| Retry | `max_retries=3` | `backend/igny8_core/modules/writer/tasks.py` | `@shared_task(bind=True, max_retries=3)` | 26 | Content generation task retry configuration | -| Retry | Error handling | `backend/igny8_core/utils/ai_processor.py` | `_call_openai()` | 191-305 | HTTP error handling, JSON parsing errors, timeout handling | -| Retry | Fallback to Django settings | `backend/igny8_core/utils/ai_processor.py` | `_get_api_key()` | 91-95 | Falls back to `OPENAI_API_KEY` or `RUNWARE_API_KEY` from settings | -| Retry | Fallback to default model | `backend/igny8_core/utils/ai_processor.py` | `_get_model()` | 120-123 | Falls back to `DEFAULT_AI_MODEL` from settings (default: 'gpt-4.1') | -| **๐Ÿงฑ Prompt Sources** | -| Prompt | `clustering` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt('clustering')` | 10-30 | Hardcoded default clustering prompt template | -| Prompt | `ideas` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt('ideas')` | 32-55 | Hardcoded default ideas generation prompt template | -| Prompt | `content_generation` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt('content_generation')` | 57-75 | Hardcoded default content generation prompt template | -| Prompt | `image_prompt_extraction` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt('image_prompt_extraction')` | 77-98 | Hardcoded default image prompt extraction template | -| Prompt | `image_prompt_template` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt('image_prompt_template')` | 100 | Hardcoded default image prompt template | -| Prompt | `negative_prompt` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt('negative_prompt')` | 102 | Hardcoded default negative prompt | -| Prompt | `get_prompt_value` | `backend/igny8_core/modules/system/utils.py` | `get_prompt_value()` | 108 | Retrieves prompt from DB (AIPrompt model) or returns default | -| Prompt | `AIPrompt` model | `backend/igny8_core/modules/system/models.py` | `AIPrompt` class | 13 | Database model storing account-specific prompts | -| Prompt | `prompt_type` | `backend/igny8_core/modules/system/models.py` | `AIPrompt.prompt_type` | 25 | Choices: clustering, ideas, content_generation, image_prompt_extraction, image_prompt_template, negative_prompt | -| Prompt | `build_prompt` | `backend/igny8_core/ai/functions/auto_cluster.py` | `AutoClusterFunction.build_prompt()` | 117 | Builds clustering prompt using `get_prompt_value()` | -| Prompt | `[IGNY8_KEYWORDS]` | `backend/igny8_core/ai/functions/auto_cluster.py` | `build_prompt()` | 131 | Placeholder replaced with keyword list | -| Prompt | `[IGNY8_CLUSTERS]` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt('ideas')` | 34 | Placeholder for ideas prompt | -| Prompt | `[IGNY8_IDEA]` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt('content_generation')` | 60 | Placeholder for content generation prompt | -| **โš ๏ธ Validation / Limits** | -| Validation | `validate` | `backend/igny8_core/ai/base.py` | `BaseAIFunction.validate()` | 34 | Base validation: checks for 'ids' array, max_items limit | -| Validation | `validate` | `backend/igny8_core/ai/functions/auto_cluster.py` | `AutoClusterFunction.validate()` | 37 | Custom validation: checks keywords exist, plan limits | -| Validation | `get_max_items` | `backend/igny8_core/ai/functions/auto_cluster.py` | `AutoClusterFunction.get_max_items()` | 34 | Returns 20 (max keywords per cluster operation) | -| Validation | `check_credits` | `backend/igny8_core/modules/billing/services.py` | `CreditService.check_credits()` | 16 | Checks if account has enough credits | -| Validation | Daily cluster limit | `backend/igny8_core/ai/functions/auto_cluster.py` | `validate()` | 59-71 | Checks `plan.daily_cluster_limit` against clusters created today | -| Validation | Max clusters limit | `backend/igny8_core/ai/functions/auto_cluster.py` | `validate()` | 73-79 | Checks `plan.max_clusters` against total clusters | -| Validation | `VALID_OPENAI_IMAGE_MODELS` | `backend/igny8_core/utils/ai_processor.py` | Constant | 34 | Set: {'dall-e-3', 'dall-e-2'} | -| Validation | `VALID_SIZES_BY_MODEL` | `backend/igny8_core/utils/ai_processor.py` | Constant | 41 | Dict mapping models to valid sizes | -| Validation | Model validation | `backend/igny8_core/utils/ai_processor.py` | `generate_image()` | 704-708 | Validates model is in VALID_OPENAI_IMAGE_MODELS | -| Validation | Size validation | `backend/igny8_core/utils/ai_processor.py` | `generate_image()` | 719-724 | Validates size is valid for selected model | -| Validation | Model rate validation | `backend/igny8_core/utils/ai_processor.py` | `_get_model()` | 112 | Validates model is in MODEL_RATES before using | -| **๐Ÿชต AI Debug Steps** | -| Debug Step | `addRequestStep` | `backend/igny8_core/ai/tracker.py` | `StepTracker.add_request_step()` | 21 | Adds request phase step (INIT, PREP, SAVE, DONE) | -| Debug Step | `addResponseStep` | `backend/igny8_core/ai/tracker.py` | `StepTracker.add_response_step()` | 45 | Adds response phase step (AI_CALL, PARSE) | -| Debug Step | `request_steps` | `backend/igny8_core/ai/tracker.py` | `StepTracker.request_steps` | 17 | List of request steps | -| Debug Step | `response_steps` | `backend/igny8_core/ai/tracker.py` | `StepTracker.response_steps` | 18 | List of response steps | -| Debug Step | `request_steps` | `backend/igny8_core/modules/planner/tasks.py` | `_auto_cluster_keywords_core()` | 37 | Legacy request steps tracking | -| Debug Step | `response_steps` | `backend/igny8_core/modules/planner/tasks.py` | `_auto_cluster_keywords_core()` | 38 | Legacy response steps tracking | -| Debug Step | `meta['request_steps']` | `backend/igny8_core/modules/system/integration_views.py` | `task_progress()` | 936-937 | Extracts request_steps from Celery task meta | -| Debug Step | `meta['response_steps']` | `backend/igny8_core/modules/system/integration_views.py` | `task_progress()` | 938-939 | Extracts response_steps from Celery task meta | -| Debug Step | `request_steps` | `backend/igny8_core/ai/models.py` | `AITaskLog.request_steps` | 31 | JSONField storing request steps in database | -| Debug Step | `response_steps` | `backend/igny8_core/ai/models.py` | `AITaskLog.response_steps` | 32 | JSONField storing response steps in database | -| Debug Step | `get_meta()` | `backend/igny8_core/ai/tracker.py` | `StepTracker.get_meta()` | 69 | Returns dict with request_steps and response_steps | -| Debug Step | Step injection | `backend/igny8_core/ai/engine.py` | `execute()` | 47, 60, 68, 125, 138, 174 | Adds steps at each phase (INIT, PREP, AI_CALL, PARSE, SAVE, DONE) | -| Debug Step | Step counter | `backend/igny8_core/ai/tracker.py` | `StepTracker.step_counter` | 19 | Auto-increments for sequential step numbers | -| **๐Ÿงพ Model Config / Selection** | -| Model Config | `default_model` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor.__init__()` | 67 | Set from `_get_model()` or defaults to 'gpt-4.1' | -| Model Config | `_get_model` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor._get_model()` | 98 | Gets model from IntegrationSettings.config['model'] or Django settings | -| Model Config | `MODEL_RATES` | `backend/igny8_core/utils/ai_processor.py` | Constant | 19 | Dict: {'gpt-4.1': {...}, 'gpt-4o-mini': {...}, 'gpt-4o': {...}} | -| Model Config | `IMAGE_MODEL_RATES` | `backend/igny8_core/utils/ai_processor.py` | Constant | 26 | Dict: {'dall-e-3': 0.040, 'dall-e-2': 0.020, ...} | -| Model Config | `DEFAULT_AI_MODEL` | `backend/igny8_core/utils/ai_processor.py` | Django setting | 121 | Default: 'gpt-4.1' if not set | -| Model Config | `get_model` | `backend/igny8_core/ai/base.py` | `BaseAIFunction.get_model()` | 70 | Override to specify model (defaults to account's default) | -| Model Config | `model` parameter | `backend/igny8_core/ai/processor.py` | `call()` | 22 | Model can be passed to AIProcessor.call() | -| Model Config | `json_models` | `backend/igny8_core/ai/processor.py` | `call()` | 40 | List: ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo-preview'] (supports JSON mode) | -| Model Config | `IntegrationSettings.config['model']` | `backend/igny8_core/modules/system/models.py` | `IntegrationSettings.config` | 56 | JSONField storing model name per account | -| Model Config | Model selection | `backend/igny8_core/ai/engine.py` | `execute()` | 65 | Gets model via `fn.get_model(self.account)` | -| **๐Ÿ“ฆ Request/Response Structuring** | -| Request/Response | `response_format` | `backend/igny8_core/utils/ai_processor.py` | `_call_openai()` | 131 | Optional dict for JSON mode: {'type': 'json_object'} | -| Request/Response | `response_format` | `backend/igny8_core/ai/processor.py` | `call()` | 25 | Optional dict for JSON mode | -| Request/Response | JSON mode auto-enable | `backend/igny8_core/ai/processor.py` | `call()` | 41-42 | Auto-enables JSON mode for json_models if not specified | -| Request/Response | `_extract_json_from_response` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor._extract_json_from_response()` | 334 | Extracts JSON from response (handles markdown code blocks, multiline) | -| Request/Response | `extract_json` | `backend/igny8_core/ai/processor.py` | `AIProcessor.extract_json()` | 57 | Wrapper for `_extract_json_from_response()` | -| Request/Response | `parse_response` | `backend/igny8_core/ai/functions/auto_cluster.py` | `AutoClusterFunction.parse_response()` | 158 | Parses AI response into cluster data structure | -| Request/Response | `parse_response` | `backend/igny8_core/ai/base.py` | `BaseAIFunction.parse_response()` | 75 | Abstract method for parsing AI response | -| Request/Response | Request body format | `backend/igny8_core/utils/ai_processor.py` | `_call_openai()` | 171-183 | Format: {'model': str, 'messages': [...], 'temperature': float, 'max_tokens': int, 'response_format': dict} | -| Request/Response | Response format | `backend/igny8_core/utils/ai_processor.py` | `_call_openai()` | 215-329 | Returns: {'content': str, 'input_tokens': int, 'output_tokens': int, 'total_tokens': int, 'model': str, 'cost': float, 'error': str, 'api_id': str} | -| Request/Response | JSON parsing fallback | `backend/igny8_core/ai/functions/auto_cluster.py` | `parse_response()` | 173-176 | Falls back to `extract_json()` if direct JSON parse fails | -| **๐Ÿ“ Paths / Constants** | -| Path/Constant | `OPENAI_API_KEY` | `backend/igny8_core/utils/ai_processor.py` | Django setting | 93 | Fallback API key from Django settings | -| Path/Constant | `RUNWARE_API_KEY` | `backend/igny8_core/utils/ai_processor.py` | Django setting | 95 | Fallback API key from Django settings | -| Path/Constant | OpenAI API URL | `backend/igny8_core/utils/ai_processor.py` | `_call_openai()` | 163 | Hardcoded: 'https://api.openai.com/v1/chat/completions' | -| Path/Constant | OpenAI Images URL | `backend/igny8_core/utils/ai_processor.py` | `generate_image()` | 735 | Hardcoded: 'https://api.openai.com/v1/images/generations' | -| Path/Constant | Runware API URL | `backend/igny8_core/utils/ai_processor.py` | `generate_image()` | 844 | Hardcoded: 'https://api.runware.ai/v1' | -| Path/Constant | `IntegrationSettings.config['apiKey']` | `backend/igny8_core/modules/system/models.py` | `IntegrationSettings.config` | 56 | JSONField storing API key per account | -| Path/Constant | Prompt type choices | `backend/igny8_core/modules/system/models.py` | `AIPrompt.PROMPT_TYPE_CHOICES` | 16 | ['clustering', 'ideas', 'content_generation', 'image_prompt_extraction', 'image_prompt_template', 'negative_prompt'] | -| Path/Constant | Integration type choices | `backend/igny8_core/modules/system/models.py` | `IntegrationSettings.INTEGRATION_TYPE_CHOICES` | 48 | ['openai', 'runware', 'gsc', 'image_generation'] | -| Path/Constant | `get_function_instance` | `backend/igny8_core/ai/registry.py` | `get_function_instance()` | - | Gets AI function instance from registry | -| Path/Constant | `auto_cluster` | `backend/igny8_core/ai/registry.py` | `register_lazy_function()` | 69 | Registered function name for clustering | -| **๐Ÿ’ฐ Cost Tracking** | -| Cost | `CostTracker` | `backend/igny8_core/ai/tracker.py` | `CostTracker` class | 193 | Tracks API costs and token usage | -| Cost | `record` | `backend/igny8_core/ai/tracker.py` | `CostTracker.record()` | 201 | Records cost, tokens, model for an operation | -| Cost | Cost calculation | `backend/igny8_core/utils/ai_processor.py` | `_call_openai()` | 277-295 | Calculates cost from MODEL_RATES based on input/output tokens | -| Cost | Image cost calculation | `backend/igny8_core/utils/ai_processor.py` | `generate_image()` | 790 | Calculates cost from IMAGE_MODEL_RATES * n images | -| Cost | Credit logging | `backend/igny8_core/ai/engine.py` | `execute()` | 142-171 | Logs credit usage to CreditUsageLog after successful save | -| Cost | `_calculate_credits_for_clustering` | `backend/igny8_core/ai/engine.py` | `_calculate_credits_for_clustering()` | 257 | Calculates credits used (from plan config or fallback formula) | -| **๐Ÿ“Š Progress Tracking** | -| Progress | `ProgressTracker` | `backend/igny8_core/ai/tracker.py` | `ProgressTracker` class | 77 | Tracks progress updates for AI tasks | -| Progress | `update` | `backend/igny8_core/ai/tracker.py` | `ProgressTracker.update()` | 89 | Updates Celery task state with progress | -| Progress | Phase percentages | `backend/igny8_core/ai/engine.py` | `execute()` | 30-36 | INIT (0-10%), PREP (10-25%), AI_CALL (25-70%), PARSE (70-85%), SAVE (85-98%), DONE (98-100%) | -| Progress | `update_ai_progress` | `backend/igny8_core/ai/tracker.py` | `ProgressTracker.update_ai_progress()` | 184 | Callback for AI processor progress updates | -| **๐Ÿ—„๏ธ Database Logging** | -| Database | `AITaskLog` | `backend/igny8_core/ai/models.py` | `AITaskLog` model | 8 | Unified logging table for all AI tasks | -| Database | `_log_to_database` | `backend/igny8_core/ai/engine.py` | `AIEngine._log_to_database()` | 220 | Logs task execution to AITaskLog table | -| Database | Task logging | `backend/igny8_core/ai/engine.py` | `execute()` | 178 | Called after successful execution to log to database | -| **๐Ÿ”„ Celery Integration** | -| Celery | `run_ai_task` | `backend/igny8_core/ai/tasks.py` | `run_ai_task()` | 13 | Unified Celery task entrypoint | -| Celery | Task state updates | `backend/igny8_core/ai/tracker.py` | `ProgressTracker.update()` | 124-131 | Updates Celery task state via `task.update_state()` | -| Celery | Meta injection | `backend/igny8_core/modules/system/integration_views.py` | `task_progress()` | 936-991 | Extracts request_steps/response_steps from task meta and returns to frontend | -| Celery | Error state | `backend/igny8_core/ai/tasks.py` | `run_ai_task()` | 68-84 | Updates task state to FAILURE on error | -| **๐Ÿ”ง Utility Functions** | -| Utility | `get_default_prompt` | `backend/igny8_core/modules/system/utils.py` | `get_default_prompt()` | 7 | Returns hardcoded default prompt by type | -| Utility | `get_prompt_value` | `backend/igny8_core/modules/system/utils.py` | `get_prompt_value()` | 108 | Gets prompt from DB or returns default | -| Utility | `check_moderation` | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor.check_moderation()` | 594 | Checks content against OpenAI moderation API | -| Utility | `prepare` | `backend/igny8_core/ai/functions/auto_cluster.py` | `AutoClusterFunction.prepare()` | 85 | Loads keywords with relationships | -| Utility | `save_output` | `backend/igny8_core/ai/functions/auto_cluster.py` | `AutoClusterFunction.save_output()` | 205 | Saves clusters to database with transaction | - diff --git a/docs/07-AI-FRAMEWORK.md b/docs/AI-NEW-DESIGN/07-AI-FRAMEWORK.md similarity index 100% rename from docs/07-AI-FRAMEWORK.md rename to docs/AI-NEW-DESIGN/07-AI-FRAMEWORK.md diff --git a/docs/ActiveDocs/STAGE1-REORGANIZATION-COMPLETE.md b/docs/AI-NEW-DESIGN/STAGE1-REORGANIZATION-COMPLETE.md similarity index 100% rename from docs/ActiveDocs/STAGE1-REORGANIZATION-COMPLETE.md rename to docs/AI-NEW-DESIGN/STAGE1-REORGANIZATION-COMPLETE.md diff --git a/docs/ActiveDocs/STAGE2-EXECUTION-LOGGING-COMPLETE.md b/docs/AI-NEW-DESIGN/STAGE2-EXECUTION-LOGGING-COMPLETE.md similarity index 100% rename from docs/ActiveDocs/STAGE2-EXECUTION-LOGGING-COMPLETE.md rename to docs/AI-NEW-DESIGN/STAGE2-EXECUTION-LOGGING-COMPLETE.md diff --git a/docs/ActiveDocs/STAGE3-LOGGING-COMPLETE.md b/docs/AI-NEW-DESIGN/STAGE3-LOGGING-COMPLETE.md similarity index 100% rename from docs/ActiveDocs/STAGE3-LOGGING-COMPLETE.md rename to docs/AI-NEW-DESIGN/STAGE3-LOGGING-COMPLETE.md diff --git a/docs/ActiveDocs/STAGE4-PROMPT-REGISTRY-COMPLETE.md b/docs/AI-NEW-DESIGN/STAGE4-PROMPT-REGISTRY-COMPLETE.md similarity index 100% rename from docs/ActiveDocs/STAGE4-PROMPT-REGISTRY-COMPLETE.md rename to docs/AI-NEW-DESIGN/STAGE4-PROMPT-REGISTRY-COMPLETE.md diff --git a/docs/ActiveDocs/AI-ELEMENTS-EXTRACTED.md b/docs/ActiveDocs/AI-ELEMENTS-EXTRACTED.md deleted file mode 100644 index a711e286..00000000 --- a/docs/ActiveDocs/AI-ELEMENTS-EXTRACTED.md +++ /dev/null @@ -1,300 +0,0 @@ -# IGNY8 AI Elements Reference Table - -Generated by extract_ai_elements.py analysis - ---- - -## ๐Ÿง  AI Core Functions - -| Function Name | Category | Type | File | Line | Uses AIProcessor | Celery | Progress | Steps | Prompt Source | Model Source | -|---------------|----------|------|------|------|------------------|--------|----------|-------|---------------|--------------| -| `_auto_cluster_keywords_core` | cluster | core_function | `backend/igny8_core/modules/planner/tasks.py` | 26 | โœ… | โŒ | โœ… | โœ… | Database (get_prompt_value) | AIProcessor.default_model | -| `_generate_single_idea_core` | ideas | core_function | `backend/igny8_core/modules/planner/tasks.py` | 1047 | โœ… | โŒ | โœ… | โœ… | Database (get_prompt_value) | AIProcessor.default_model | -| `auto_generate_content_task` | content | celery_task | `backend/igny8_core/modules/writer/tasks.py` | 27 | โœ… | โœ… | โœ… | โŒ | Database (get_prompt_value) | AIProcessor.default_model | -| `auto_generate_images_task` | image | celery_task | `backend/igny8_core/modules/writer/tasks.py` | 741 | โœ… | โœ… | โœ… | โŒ | Database (get_prompt_value) | AIProcessor.default_model | -| `AutoClusterFunction` | cluster | class | `backend/igny8_core/ai/functions/auto_cluster.py` | 14 | โœ… | โŒ | โœ… | โœ… | Database (get_prompt_value) | Function.get_model() | -| `cluster_keywords` | cluster | method | `backend/igny8_core/utils/ai_processor.py` | 1080 | โœ… | โŒ | โœ… | โœ… | Inline/Hardcoded | AIProcessor.default_model | -| `generate_ideas` | ideas | method | `backend/igny8_core/utils/ai_processor.py` | 1280 | โœ… | โŒ | โœ… | โœ… | Inline/Hardcoded | AIProcessor.default_model | -| `generate_content` | content | method | `backend/igny8_core/utils/ai_processor.py` | 446 | โœ… | โŒ | โŒ | โŒ | Inline/Hardcoded | AIProcessor.default_model | -| `generate_image` | image | method | `backend/igny8_core/utils/ai_processor.py` | 656 | โœ… | โŒ | โŒ | โŒ | Inline/Hardcoded | Parameter or default | -| `run_ai_task` | unified | celery_task | `backend/igny8_core/ai/tasks.py` | 13 | โŒ | โœ… | โœ… | โœ… | Via function | Via function | -| `execute` | unified | method | `backend/igny8_core/ai/engine.py` | 26 | โœ… | โŒ | โœ… | โœ… | Via function | Via function | - ---- - -## ๐Ÿงฑ Prompt Sources - -| Prompt Type | Source | File | Retrieval Method | -|-------------|--------|------|------------------| -| `clustering` | Hardcoded in get_default_prompt() | `backend/igny8_core/modules/system/utils.py` | `get_prompt_value()` -> AIPrompt model or default | -| `ideas` | Hardcoded in get_default_prompt() | `backend/igny8_core/modules/system/utils.py` | `get_prompt_value()` -> AIPrompt model or default | -| `content_generation` | Hardcoded in get_default_prompt() | `backend/igny8_core/modules/system/utils.py` | `get_prompt_value()` -> AIPrompt model or default | -| `image_prompt_extraction` | Hardcoded in get_default_prompt() | `backend/igny8_core/modules/system/utils.py` | `get_prompt_value()` -> AIPrompt model or default | -| `image_prompt_template` | Hardcoded in get_default_prompt() | `backend/igny8_core/modules/system/utils.py` | `get_prompt_value()` -> AIPrompt model or default | -| `negative_prompt` | Hardcoded in get_default_prompt() | `backend/igny8_core/modules/system/utils.py` | `get_prompt_value()` -> AIPrompt model or default | - -**Prompt Storage:** -- **Database Model**: `AIPrompt` in `backend/igny8_core/modules/system/models.py` -- **Table**: `igny8_ai_prompts` -- **Fields**: `prompt_type`, `prompt_value`, `default_prompt`, `account` (FK) -- **Unique Constraint**: `(account, prompt_type)` - -**Prompt Retrieval Flow:** -1. `get_prompt_value(account, prompt_type)` in `modules/system/utils.py:108` -2. Tries: `AIPrompt.objects.get(account=account, prompt_type=prompt_type, is_active=True)` -3. Falls back to: `get_default_prompt(prompt_type)` if not found - ---- - -## ๐Ÿงพ Model Configuration - -| Model Name | Source | File | Selection Method | -|------------|--------|------|------------------| -| `gpt-4.1` | MODEL_RATES constant | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor._get_model()` -> IntegrationSettings or Django settings | -| `gpt-4o-mini` | MODEL_RATES constant | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor._get_model()` -> IntegrationSettings or Django settings | -| `gpt-4o` | MODEL_RATES constant | `backend/igny8_core/utils/ai_processor.py` | `AIProcessor._get_model()` -> IntegrationSettings or Django settings | -| `dall-e-3` | IMAGE_MODEL_RATES constant | `backend/igny8_core/utils/ai_processor.py` | Parameter or default in `generate_image()` | -| `dall-e-2` | IMAGE_MODEL_RATES constant | `backend/igny8_core/utils/ai_processor.py` | Parameter or default in `generate_image()` | - -**Model Selection Flow:** -1. `AIProcessor.__init__(account)` in `utils/ai_processor.py:54` -2. Calls `_get_model('openai', account)` in `utils/ai_processor.py:98` -3. Tries: `IntegrationSettings.objects.filter(integration_type='openai', account=account, is_active=True).first().config.get('model')` -4. Validates model is in `MODEL_RATES` dict -5. Falls back to: `settings.DEFAULT_AI_MODEL` (default: 'gpt-4.1') - -**Model Storage:** -- **Database Model**: `IntegrationSettings` in `backend/igny8_core/modules/system/models.py` -- **Table**: `igny8_integration_settings` -- **Fields**: `integration_type`, `config` (JSONField), `account` (FK) -- **Config Structure**: `{"apiKey": "...", "model": "gpt-4.1", "enabled": true}` - ---- - -## โš ๏ธ Validation & Limits - -| Function | Validation Checks | Limit Checks | -|----------|-------------------|--------------| -| `_auto_cluster_keywords_core` | Has validate() call, Keywords exist check | Credit check, Plan limits (daily_cluster_limit, max_clusters) | -| `AutoClusterFunction.validate()` | Base validation (ids array, max_items), Keywords exist | Plan limits (daily_cluster_limit, max_clusters) | -| `auto_generate_content_task` | Task existence, Account validation | Credit check (via CreditService) | -| `auto_generate_images_task` | Task existence, Account validation | Credit check (via CreditService) | -| `generate_image` | Model validation (VALID_OPENAI_IMAGE_MODELS), Size validation (VALID_SIZES_BY_MODEL) | None | -| `AIProcessor._get_model()` | Model in MODEL_RATES validation | None | - -**Validation Details:** - -1. **Plan Limits** (in `AutoClusterFunction.validate()`): - - `plan.daily_cluster_limit` - Max clusters per day - - `plan.max_clusters` - Total max clusters - - Checked in `backend/igny8_core/ai/functions/auto_cluster.py:59-79` - -2. **Credit Checks**: - - `CreditService.check_credits(account, required_credits)` in `modules/billing/services.py:16` - - Used before AI operations - -3. **Model Validation**: - - OpenAI images: Only `dall-e-3` and `dall-e-2` valid (line 704-708 in `ai_processor.py`) - - Size validation per model (line 719-724 in `ai_processor.py`) - -4. **Input Validation**: - - Base validation in `BaseAIFunction.validate()` checks for 'ids' array and max_items limit - - `AutoClusterFunction.get_max_items()` returns 20 (max keywords per cluster) - ---- - -## ๐Ÿ” Retry & Error Handling - -| Component | Retry Logic | Error Handling | Fallback | -|-----------|-------------|----------------|----------| -| `run_ai_task` | `max_retries=3` (Celery decorator) | Exception caught, task state updated to FAILURE | None | -| `auto_generate_content_task` | `max_retries=3` (Celery decorator) | Try/except blocks, error logging | None | -| `_call_openai` | None (single attempt) | HTTP error handling, JSON parse errors, timeout (60s) | Returns error dict | -| `_get_api_key` | None | Exception caught, logs warning | Falls back to Django settings (`OPENAI_API_KEY`, `RUNWARE_API_KEY`) | -| `_get_model` | None | Exception caught, logs warning | Falls back to Django settings (`DEFAULT_AI_MODEL`) | - ---- - -## ๐Ÿชต AI Debug Steps - -| Function | Request Steps | Response Steps | Step Tracking Method | -|----------|---------------|----------------|---------------------| -| `_auto_cluster_keywords_core` | โœ… (manual list) | โœ… (manual list) | Manual `request_steps.append()` and `response_steps.append()` | -| `AutoClusterFunction` | โœ… (via StepTracker) | โœ… (via StepTracker) | `StepTracker.add_request_step()` and `add_response_step()` | -| `run_ai_task` | โœ… (via engine) | โœ… (via engine) | Extracted from `engine.execute()` result | -| `AIEngine.execute` | โœ… (via StepTracker) | โœ… (via StepTracker) | `StepTracker` instance tracks all steps | -| `auto_generate_content_task` | โŒ | โŒ | No step tracking (legacy) | -| `auto_generate_images_task` | โŒ | โŒ | No step tracking (legacy) | - -**Step Tracking Implementation:** - -1. **New Framework** (AIEngine): - - Uses `StepTracker` class in `backend/igny8_core/ai/tracker.py` - - Steps added at each phase: INIT, PREP, AI_CALL, PARSE, SAVE, DONE - - Steps stored in `request_steps` and `response_steps` lists - - Returned in result dict and logged to `AITaskLog` model - -2. **Legacy Functions**: - - Manual step tracking with lists - - Steps added to `meta` dict for Celery task progress - - Extracted in `integration_views.py:task_progress()` for frontend - -3. **Step Structure**: - ```python - { - 'stepNumber': int, - 'stepName': str, # INIT, PREP, AI_CALL, PARSE, SAVE, DONE - 'functionName': str, - 'status': 'success' | 'error' | 'pending', - 'message': str, - 'error': str (optional), - 'duration': int (milliseconds, optional) - } - ``` - ---- - -## ๐Ÿ“ฆ Request/Response Structuring - -| Function | Request Format | Response Format | JSON Mode | Parsing Method | -|----------|----------------|-----------------|-----------|----------------| -| `_call_openai` | OpenAI API format: `{'model': str, 'messages': [...], 'temperature': float, 'max_tokens': int, 'response_format': dict}` | `{'content': str, 'input_tokens': int, 'output_tokens': int, 'total_tokens': int, 'model': str, 'cost': float, 'error': str, 'api_id': str}` | โœ… (if `response_format={'type': 'json_object'}`) | `_extract_json_from_response()` | -| `cluster_keywords` | Prompt string with keywords | JSON with 'clusters' array | โœ… (auto-enabled for json_models) | `_extract_json_from_response()` then extract 'clusters' | -| `generate_ideas` | Prompt string with clusters | JSON with 'ideas' array | โœ… (auto-enabled for json_models) | `_extract_json_from_response()` then extract 'ideas' | -| `generate_image` (OpenAI) | `{'prompt': str, 'model': str, 'n': int, 'size': str}` | `{'url': str, 'revised_prompt': str, 'cost': float}` | N/A | Direct JSON response | -| `generate_image` (Runware) | Array format with `imageInference` tasks | `{'url': str, 'cost': float}` | N/A | Extract from nested response structure | - -**JSON Mode Auto-Enable:** -- Models: `['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo-preview']` -- Auto-enabled in `AIProcessor.call()` if `response_format` not specified -- Location: `backend/igny8_core/ai/processor.py:40-42` - -**JSON Extraction:** -- Primary: Direct `json.loads()` on response -- Fallback: `_extract_json_from_response()` handles: - - Markdown code blocks (```json ... ```) - - Multiline JSON - - Partial JSON extraction -- Location: `backend/igny8_core/utils/ai_processor.py:334-440` - ---- - -## ๐Ÿ“ Paths & Constants - -| Constant | Value | File | Usage | -|----------|-------|------|-------| -| `OPENAI_API_KEY` | Django setting | `backend/igny8_core/utils/ai_processor.py:93` | Fallback API key | -| `RUNWARE_API_KEY` | Django setting | `backend/igny8_core/utils/ai_processor.py:95` | Fallback API key | -| `DEFAULT_AI_MODEL` | Django setting (default: 'gpt-4.1') | `backend/igny8_core/utils/ai_processor.py:121` | Fallback model | -| OpenAI API URL | `'https://api.openai.com/v1/chat/completions'` | `backend/igny8_core/utils/ai_processor.py:163` | Text generation endpoint | -| OpenAI Images URL | `'https://api.openai.com/v1/images/generations'` | `backend/igny8_core/utils/ai_processor.py:735` | Image generation endpoint | -| Runware API URL | `'https://api.runware.ai/v1'` | `backend/igny8_core/utils/ai_processor.py:844` | Runware image generation | -| `MODEL_RATES` | Dict with pricing per 1M tokens | `backend/igny8_core/utils/ai_processor.py:19` | Cost calculation | -| `IMAGE_MODEL_RATES` | Dict with pricing per image | `backend/igny8_core/utils/ai_processor.py:26` | Image cost calculation | -| `VALID_OPENAI_IMAGE_MODELS` | `{'dall-e-3', 'dall-e-2'}` | `backend/igny8_core/utils/ai_processor.py:34` | Model validation | -| `VALID_SIZES_BY_MODEL` | Dict mapping models to valid sizes | `backend/igny8_core/utils/ai_processor.py:41` | Size validation | - ---- - -## ๐Ÿ’ฐ Cost Tracking - -| Component | Cost Calculation | Token Tracking | Storage | -|-----------|------------------|----------------|---------| -| `_call_openai` | Calculated from `MODEL_RATES` based on input/output tokens | โœ… (input_tokens, output_tokens, total_tokens) | Returned in result dict | -| `generate_image` (OpenAI) | `IMAGE_MODEL_RATES[model] * n` | N/A | Returned in result dict | -| `generate_image` (Runware) | `0.036 * n` (hardcoded) | N/A | Returned in result dict | -| `CostTracker` | Aggregates costs from multiple operations | โœ… (total_tokens) | In-memory during execution | -| `AITaskLog` | Stored in `cost` field (DecimalField) | โœ… (stored in `tokens` field) | Database table `igny8_ai_task_logs` | -| `CreditUsageLog` | Stored in `cost_usd` field | โœ… (tokens_input, tokens_output) | Database table (billing module) | - -**Cost Calculation Formula:** -```python -# Text generation -input_cost = (input_tokens / 1_000_000) * MODEL_RATES[model]['input'] -output_cost = (output_tokens / 1_000_000) * MODEL_RATES[model]['output'] -total_cost = input_cost + output_cost - -# Image generation -cost = IMAGE_MODEL_RATES[model] * n_images -``` - ---- - -## ๐Ÿ“Š Progress Tracking - -| Function | Progress Method | Phase Tracking | Percentage Mapping | -|----------|-----------------|----------------|-------------------| -| `_auto_cluster_keywords_core` | `progress_callback()` function | Manual phase strings | Manual percentage | -| `auto_generate_content_task` | `self.update_state()` (Celery) | Manual phase strings | Manual percentage | -| `AIEngine.execute` | `ProgressTracker.update()` | Automatic (INIT, PREP, AI_CALL, PARSE, SAVE, DONE) | Automatic: INIT (0-10%), PREP (10-25%), AI_CALL (25-70%), PARSE (70-85%), SAVE (85-98%), DONE (98-100%) | -| `run_ai_task` | Via `AIEngine` | Via `AIEngine` | Via `AIEngine` | - -**Progress Tracker:** -- Class: `ProgressTracker` in `backend/igny8_core/ai/tracker.py:77` -- Updates Celery task state via `task.update_state()` -- Tracks: phase, percentage, message, current, total, meta - ---- - -## ๐Ÿ—„๏ธ Database Logging - -| Component | Log Table | Fields Logged | When Logged | -|-----------|-----------|---------------|-------------| -| `AIEngine.execute` | `AITaskLog` | task_id, function_name, phase, message, status, duration, cost, tokens, request_steps, response_steps, error, payload, result | After execution (success or error) | -| Credit usage | `CreditUsageLog` | account, operation_type, credits_used, cost_usd, model_used, tokens_input, tokens_output | After successful save operation | - -**AITaskLog Model:** -- Table: `igny8_ai_task_logs` -- Location: `backend/igny8_core/ai/models.py:8` -- Fields: All execution details including steps, costs, tokens, errors - ---- - -## ๐Ÿ”„ Celery Integration - -| Task | Entrypoint | Task ID | State Updates | Error Handling | -|------|------------|---------|---------------|----------------| -| `run_ai_task` | `backend/igny8_core/ai/tasks.py:13` | `self.request.id` | Via `ProgressTracker` | Updates state to FAILURE, raises exception | -| `auto_generate_content_task` | `backend/igny8_core/modules/writer/tasks.py:27` | `self.request.id` | Manual `self.update_state()` | Try/except, logs error | -| `auto_generate_images_task` | `backend/igny8_core/modules/writer/tasks.py:741` | `self.request.id` | Manual `self.update_state()` | Try/except, logs error | - -**Task Progress Endpoint:** -- Route: `/api/v1/system/settings/task_progress/{task_id}/` -- Handler: `IntegrationSettingsViewSet.task_progress()` in `modules/system/integration_views.py:936` -- Extracts: `request_steps` and `response_steps` from task meta -- Returns: Progress data to frontend for debug panel - ---- - -## Summary - -**Key Findings:** - -1. **Two AI Systems Coexist:** - - **Legacy**: Direct functions in `modules/planner/tasks.py` and `modules/writer/tasks.py` - - **New Framework**: `AIEngine` + `BaseAIFunction` classes in `ai/` directory - -2. **Unified Entrypoint:** - - `run_ai_task()` in `ai/tasks.py` is the unified Celery entrypoint - - Uses `AIEngine` to execute any registered AI function - -3. **Prompt Management:** - - All prompts stored in `AIPrompt` model (database) - - Fallback to hardcoded defaults in `get_default_prompt()` - - Retrieved via `get_prompt_value(account, prompt_type)` - -4. **Model Selection:** - - Per-account via `IntegrationSettings.config['model']` - - Falls back to Django `DEFAULT_AI_MODEL` setting - - Validated against `MODEL_RATES` dict - -5. **Step Tracking:** - - New framework uses `StepTracker` class - - Legacy functions use manual lists - - Both stored in Celery task meta and `AITaskLog` model - -6. **Cost Tracking:** - - Calculated from `MODEL_RATES` and `IMAGE_MODEL_RATES` - - Logged to `AITaskLog` and `CreditUsageLog` - - Tracked via `CostTracker` during execution - diff --git a/docs/ActiveDocs/COLOR-TOKENS-COMPARISON.md b/docs/ActiveDocs/COLOR-TOKENS-COMPARISON.md deleted file mode 100644 index d79378db..00000000 --- a/docs/ActiveDocs/COLOR-TOKENS-COMPARISON.md +++ /dev/null @@ -1,121 +0,0 @@ -# Color Tokens Comparison - -Side-by-side comparison of provided tokens vs. global color palette - -| Color Token | Provided Value | Our Global Palette | Match Status | Notes | -|-------------|----------------|-------------------|--------------|-------| -| **RED** | -| `--color-red-50` | `oklch(.971 .013 17.38)` | `oklch(0.971 0.013 17.38)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:10` | -| `--color-red-100` | `oklch(.936 .032 17.717)` | `oklch(0.936 0.032 17.717)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:11` | -| `--color-red-500` | `oklch(.637 .237 25.331)` | `oklch(0.637 0.237 25.331)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:15` | -| `--color-red-600` | `oklch(.577 .245 27.325)` | `oklch(0.577 0.245 27.325)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:16` | -| `--color-red-700` | `oklch(.505 .213 27.518)` | `oklch(0.505 0.213 27.518)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:17` | -| **ORANGE** | -| `--color-orange-50` | `#fff6ed` | `oklch(0.98 0.016 73.684)` โŒ | **DIFFERENT** | Provided: hex, Ours: oklch (in `tailwindcss/theme.css:22`) | -| `--color-orange-100` | `#ffead5` | `oklch(0.954 0.038 75.164)` โŒ | **DIFFERENT** | Provided: hex, Ours: oklch (in `tailwindcss/theme.css:23`) | -| `--color-orange-400` | `#fd853a` | `oklch(0.75 0.183 55.934)` โŒ | **DIFFERENT** | Provided: hex, Ours: oklch (in `tailwindcss/theme.css:26`) | -| `--color-orange-500` | `#fb6514` | `oklch(0.705 0.213 47.604)` โŒ | **DIFFERENT** | Provided: hex, Ours: oklch (in `tailwindcss/theme.css:27`) | -| `--color-orange-600` | `#ec4a0a` | `oklch(0.646 0.222 41.116)` โŒ | **DIFFERENT** | Provided: hex, Ours: oklch (in `tailwindcss/theme.css:28`) | -| `--color-orange-700` | `#c4320a` | `oklch(0.553 0.195 38.402)` โŒ | **DIFFERENT** | Provided: hex, Ours: oklch (in `tailwindcss/theme.css:29`) | -| **YELLOW** | -| `--color-yellow-100` | `oklch(.973 .071 103.193)` | `oklch(0.973 0.071 103.193)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:47` | -| `--color-yellow-600` | `oklch(.681 .162 75.834)` | `oklch(0.681 0.162 75.834)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:52` | -| **GREEN** | -| `--color-green-50` | `oklch(.982 .018 155.826)` | `oklch(0.982 0.018 155.826)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:70` | -| `--color-green-100` | `oklch(.962 .044 156.743)` | `oklch(0.962 0.044 156.743)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:71` | -| `--color-green-500` | `oklch(.723 .219 149.579)` | `oklch(0.723 0.219 149.579)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:75` | -| `--color-green-600` | `oklch(.627 .194 149.214)` | `oklch(0.627 0.194 149.214)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:76` | -| `--color-green-700` | `oklch(.527 .154 150.069)` | `oklch(0.527 0.154 150.069)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:77` | -| **CYAN** | -| `--color-cyan-100` | `oklch(.956 .045 203.388)` | `oklch(0.956 0.045 203.388)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:107` | -| `--color-cyan-600` | `oklch(.609 .126 221.723)` | `oklch(0.609 0.126 221.723)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:112` | -| **BLUE** | -| `--color-blue-50` | `oklch(.97 .014 254.604)` | `oklch(0.97 0.014 254.604)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:130` | -| `--color-blue-100` | `oklch(.932 .032 255.585)` | `oklch(0.932 0.032 255.585)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:131` | -| `--color-blue-500` | `oklch(.623 .214 259.815)` | `oklch(0.623 0.214 259.815)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:135` | -| `--color-blue-700` | `oklch(.488 .243 264.376)` | `oklch(0.488 0.243 264.376)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:137` | -| **PURPLE** | -| `--color-purple-50` | `oklch(.977 .014 308.299)` | `oklch(0.977 0.014 308.299)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:166` | -| `--color-purple-100` | `oklch(.946 .033 307.174)` | `oklch(0.946 0.033 307.174)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:167` | -| `--color-purple-400` | `oklch(.714 .203 305.504)` | `oklch(0.714 0.203 305.504)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:170` | -| `--color-purple-500` | `oklch(.627 .265 303.9)` | `oklch(0.627 0.265 303.9)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:171` | -| `--color-purple-600` | `oklch(.558 .288 302.321)` | `oklch(0.558 0.288 302.321)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:172` | -| `--color-purple-700` | `oklch(.496 .265 301.924)` | `oklch(0.496 0.265 301.924)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:173` | -| **PINK** | -| `--color-pink-100` | `oklch(.948 .028 342.258)` | `oklch(0.948 0.028 342.258)` โœ… | **EXACT MATCH** | In `tailwindcss/theme.css:191` | -| `--color-pink-600` | `oklch(.592 .249 .584)` | `oklch(0.592 0.249 0.584)` โš ๏ธ | **FORMAT DIFFERENCE** | Provided: `.584` (missing hue), Ours: full oklch (in `tailwindcss/theme.css:196`) | -| **GRAY** | -| `--color-gray-50` | `#f9fafb` | `#f9fafb` โœ… | **EXACT MATCH** | In `index.css:87` | -| `--color-gray-100` | `#f2f4f7` | `#f2f4f7` โœ… | **EXACT MATCH** | In `index.css:88` | -| `--color-gray-200` | `#e4e7ec` | `#e4e7ec` โœ… | **EXACT MATCH** | In `index.css:89` | -| `--color-gray-300` | `#d0d5dd` | `#d0d5dd` โœ… | **EXACT MATCH** | In `index.css:90` | -| `--color-gray-400` | `#98a2b3` | `#98a2b3` โœ… | **EXACT MATCH** | In `index.css:91` | -| `--color-gray-500` | `#667085` | `#667085` โœ… | **EXACT MATCH** | In `index.css:92` | -| `--color-gray-600` | `#475467` | `#475467` โœ… | **EXACT MATCH** | In `index.css:93` | -| `--color-gray-700` | `#344054` | `#344054` โœ… | **EXACT MATCH** | In `index.css:94` | -| `--color-gray-800` | `#1d2939` | `#1d2939` โœ… | **EXACT MATCH** | In `index.css:95` | -| `--color-gray-900` | `#101828` | `#101828` โœ… | **EXACT MATCH** | In `index.css:96` | -| `--color-gray-950` | `#0c111d` | `#0c111d` โœ… | **EXACT MATCH** | In `index.css:97` | -| **BLACK & WHITE** | -| `--color-black` | `#101828` | `#101828` โœ… | **EXACT MATCH** | In `index.css:58` | -| `--color-white` | `#fff` | `#ffffff` โœ… | **EQUIVALENT** | In `index.css:57` (same color, different format) | - ---- - -## Summary - -### โœ… **Matches (28 tokens)** -- **Red**: All 5 tokens match exactly (oklch format) -- **Yellow**: Both tokens match exactly (oklch format) -- **Green**: All 5 tokens match exactly (oklch format) -- **Cyan**: Both tokens match exactly (oklch format) -- **Blue**: All 4 tokens match exactly (oklch format) -- **Purple**: All 6 tokens match exactly (oklch format) -- **Gray**: All 11 tokens match exactly (hex format) -- **Black/White**: Both match (hex format) - -### โŒ **Differences (6 tokens)** -- **Orange**: All 6 tokens differ - - Provided: Hex format (`#fff6ed`, `#ffead5`, etc.) - - Ours: oklch format in Tailwind theme - - **Note**: These are likely the same colors, just different formats. The hex values you provided match our custom orange palette in `index.css:100-111` (which uses hex), but Tailwind's theme uses oklch. - -### โš ๏ธ **Format Issue (1 token)** -- **Pink-600**: `oklch(.592 .249 .584)` - Missing hue value (should be 3 values: lightness, chroma, hue) - ---- - -## Location of Colors in Codebase - -### Tailwind Default Colors (oklch format) -- **File**: `frontend/node_modules/tailwindcss/theme.css` -- Contains: red, orange, yellow, green, cyan, blue, purple, pink (all in oklch) - -### Custom IGNY8 Colors (hex format) -- **File**: `frontend/src/index.css` (lines 55-154) -- Contains: - - Gray scale (hex) - - Orange scale (hex) - **Matches your provided orange values!** - - Brand colors (hex) - - Success/Error/Warning colors (hex) - -### IGNY8 Brand Colors -- **File**: `frontend/src/styles/igny8-colors.css` -- Contains: Custom brand colors with `--igny8-` prefix - ---- - -## Recommendation - -**Your provided orange tokens match our custom orange palette in `index.css`!** - -The orange colors you provided are already in our codebase: -- `--color-orange-50: #fff6ed` โœ… (line 101) -- `--color-orange-100: #ffead5` โœ… (line 102) -- `--color-orange-400: #fd853a` โœ… (line 105) -- `--color-orange-500: #fb6514` โœ… (line 106) -- `--color-orange-600: #ec4a0a` โœ… (line 107) -- `--color-orange-700: #c4320a` โœ… (line 108) - -All other colors (red, yellow, green, cyan, blue, purple, gray, black, white) also match either in Tailwind's theme or our custom palette. - diff --git a/docs/01-ARCHITECTURE.md b/docs/Architecture/01-ARCHITECTURE.md similarity index 100% rename from docs/01-ARCHITECTURE.md rename to docs/Architecture/01-ARCHITECTURE.md diff --git a/docs/MASTER-ARCHITECTURE.md b/docs/Architecture/MASTER-ARCHITECTURE.md similarity index 100% rename from docs/MASTER-ARCHITECTURE.md rename to docs/Architecture/MASTER-ARCHITECTURE.md diff --git a/docs/verify-venv-dependencies.sh b/docs/verify-venv-dependencies.sh deleted file mode 100644 index 69e2e9fb..00000000 --- a/docs/verify-venv-dependencies.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/bash -# Verification Script: Check if venv folders are in use -# Run this script to verify nothing active depends on .venv or venv folders - -echo "==========================================" -echo "IGNY8 Venv Dependency Verification Script" -echo "==========================================" -echo "" - -# Colors for output -GREEN='\033[0;32m' -RED='\033[0;31m' -YELLOW='\033[1;33m' -NC='\033[0m' # No Color - -VENV_PATH="/data/app/igny8/backend/venv" -DOTVENV_PATH="/data/app/igny8/backend/.venv" - -echo "Step 1: Check if any processes are using venv folders" -echo "------------------------------------------------------" -echo "Checking for processes with venv in command line..." -ps aux | grep -E "(venv|\.venv)" | grep -v grep || echo -e "${GREEN}โœ“ No processes found using venv${NC}" -echo "" - -echo "Step 2: Check if Python processes are running from venv" -echo "------------------------------------------------------" -echo "Checking Python processes..." -ps aux | grep python | grep -v grep | while read line; do - if echo "$line" | grep -qE "(venv|\.venv)"; then - echo -e "${RED}โœ— Found Python process using venv:${NC}" - echo " $line" - fi -done -echo -e "${GREEN}โœ“ No Python processes using venv found${NC}" -echo "" - -echo "Step 3: Check if Docker containers reference venv" -echo "------------------------------------------------------" -echo "Checking Docker container mounts..." -docker inspect $(docker ps -q) --format '{{.Name}}: {{range .Mounts}}{{.Source}} {{end}}' 2>/dev/null | grep -E "(venv|\.venv)" || echo -e "${GREEN}โœ“ No Docker containers mount venv folders${NC}" -echo "" - -echo "Step 4: Check if any files are open/locked in venv folders" -echo "------------------------------------------------------" -echo "Checking for open file handles..." -if command -v lsof >/dev/null 2>&1; then - lsof +D "$VENV_PATH" 2>/dev/null | head -20 || echo -e "${GREEN}โœ“ No open files in venv/${NC}" - lsof +D "$DOTVENV_PATH" 2>/dev/null | head -20 || echo -e "${GREEN}โœ“ No open files in .venv/${NC}" -else - echo -e "${YELLOW}โš  lsof not available, skipping file handle check${NC}" -fi -echo "" - -echo "Step 5: Check if any scripts reference venv paths" -echo "------------------------------------------------------" -echo "Checking for venv references in shell scripts..." -find /data/app/igny8 -name "*.sh" -type f 2>/dev/null | xargs grep -lE "(venv|\.venv)" 2>/dev/null | while read file; do - echo -e "${YELLOW}โš  Found reference in: $file${NC}" - grep -nE "(venv|\.venv)" "$file" | head -3 -done || echo -e "${GREEN}โœ“ No shell scripts reference venv${NC}" -echo "" - -echo "Step 6: Check Docker container Python paths" -echo "------------------------------------------------------" -echo "Checking Python executable paths in containers..." -for container in igny8_backend igny8_celery_worker igny8_celery_beat; do - if docker ps --format '{{.Names}}' | grep -q "^${container}$"; then - echo "Container: $container" - docker exec "$container" which python3 2>/dev/null || echo " (container not accessible)" - docker exec "$container" python3 -c "import sys; print('Python path:', sys.executable)" 2>/dev/null | grep -v "Python path:" || echo " (container not accessible)" - docker exec "$container" sh -c 'echo $VIRTUAL_ENV' 2>/dev/null | grep -v "^$" && echo -e "${RED}โœ— VIRTUAL_ENV is set${NC}" || echo -e "${GREEN} โœ“ No VIRTUAL_ENV set${NC}" - fi -done -echo "" - -echo "Step 7: Check if venv folders are in Dockerfile" -echo "------------------------------------------------------" -echo "Checking Dockerfile for venv references..." -if [ -f "/data/app/igny8/backend/Dockerfile" ]; then - grep -nE "(venv|\.venv)" /data/app/igny8/backend/Dockerfile 2>/dev/null && echo -e "${YELLOW}โš  Found venv reference in Dockerfile${NC}" || echo -e "${GREEN}โœ“ No venv references in Dockerfile${NC}" -else - echo -e "${YELLOW}โš  Dockerfile not found${NC}" -fi -echo "" - -echo "Step 8: Check docker-compose files for venv references" -echo "------------------------------------------------------" -echo "Checking docker-compose files..." -find /data/app -name "docker-compose*.yml" -type f 2>/dev/null | while read file; do - if grep -qE "(venv|\.venv)" "$file" 2>/dev/null; then - echo -e "${YELLOW}โš  Found reference in: $file${NC}" - grep -nE "(venv|\.venv)" "$file" - fi -done || echo -e "${GREEN}โœ“ No venv references in docker-compose files${NC}" -echo "" - -echo "Step 9: Verify containers are running correctly" -echo "------------------------------------------------------" -echo "Checking container health..." -docker ps --format "table {{.Names}}\t{{.Status}}" | grep -E "(igny8_backend|igny8_frontend|igny8_celery)" | while read line; do - if echo "$line" | grep -q "healthy\|Up"; then - echo -e "${GREEN}โœ“ $line${NC}" - else - echo -e "${RED}โœ— $line${NC}" - fi -done -echo "" - -echo "Step 10: Test backend API endpoint (verify it works without venv)" -echo "------------------------------------------------------" -echo "Testing backend health endpoint..." -response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8011/api/v1/system/status/ 2>/dev/null) -if [ "$response" = "200" ]; then - echo -e "${GREEN}โœ“ Backend API is responding (HTTP $response)${NC}" -else - echo -e "${RED}โœ— Backend API not responding (HTTP $response)${NC}" -fi -echo "" - -echo "Step 11: Check if venv folders exist and their sizes" -echo "------------------------------------------------------" -if [ -d "$VENV_PATH" ]; then - size=$(du -sh "$VENV_PATH" 2>/dev/null | cut -f1) - echo -e "${YELLOW}โš  venv/ exists: $size${NC}" -else - echo -e "${GREEN}โœ“ venv/ does not exist${NC}" -fi - -if [ -d "$DOTVENV_PATH" ]; then - size=$(du -sh "$DOTVENV_PATH" 2>/dev/null | cut -f1) - echo -e "${YELLOW}โš  .venv/ exists: $size${NC}" -else - echo -e "${GREEN}โœ“ .venv/ does not exist${NC}" -fi -echo "" - -echo "==========================================" -echo "Verification Complete" -echo "==========================================" -echo "" -echo "Summary:" -echo "- If all checks show โœ“, venv folders are safe to delete" -echo "- If any check shows โœ—, investigate before deleting" -echo "- If any check shows โš , review but likely safe" -echo "" -echo "To delete venv folders (if safe):" -echo " rm -rf $VENV_PATH" -echo " rm -rf $DOTVENV_PATH" -