diff --git a/CLAUDE.md b/CLAUDE.md index 499f131..b99ad89 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,7 +8,7 @@ Quantum Tasks AI is a Django-based AI agent marketplace platform. Users can purc **Key Architecture:** - **Django Framework**: Main web application using Django 5.2.4 -- **Agent System**: Unified workflows app handling all AI agents via N8N webhooks +- **Agent System**: Database-driven agents app with marketplace and N8N webhook execution - **Authentication**: Custom user model with email verification - **Payments**: Stripe integration with wallet system - **Database**: SQLite for development, PostgreSQL for production (Railway) @@ -59,7 +59,7 @@ pytest # Run specific app tests python manage.py test authentication -python manage.py test workflows +python manage.py test agents python manage.py test wallet # Custom test scripts @@ -96,22 +96,22 @@ gunicorn netcop_hub.wsgi:application ### Apps Structure - **authentication/**: Custom user model, email verification, password reset - **core/**: Homepage, error handlers, utility functions -- **workflows/**: Unified agent system (marketplace, execution, models) +- **agents/**: Database-driven agent system (marketplace, execution, models, REST API) - **wallet/**: Stripe payments, wallet management, transactions -### Agent System (workflows app) +### Agent System (agents app) **Key Files:** -- `workflows/config/agents.py`: Agent definitions and configurations -- `workflows/models.py`: WorkflowRequest, WorkflowResponse, WorkflowAnalytics -- `workflows/views.py`: Marketplace and agent execution views -- `workflows/templates/workflows/`: Agent-specific templates +- `agents/models.py`: Agent, AgentCategory, AgentExecution models +- `agents/views.py`: REST API and web interface views +- `agents/templates/agents/`: Dynamic agent templates with form generation +- `agents/management/commands/`: Agent creation and management commands **Agent Flow:** -1. User selects agent from marketplace (`/agents/`) -2. Fills agent-specific form (`/agents/{slug}/`) -3. Form submission creates WorkflowRequest and calls N8N webhook +1. User browses marketplace (`/agents/`) +2. Selects agent and fills dynamic form (`/agents/{slug}/`) +3. Form submission creates AgentExecution and calls N8N webhook 4. N8N processes request and returns response via webhook -5. WorkflowResponse stores results for user retrieval +5. Results displayed with file upload support and real-time wallet updates ### Database Models **User Management:** @@ -119,10 +119,10 @@ gunicorn netcop_hub.wsgi:application - `authentication.PasswordResetToken`: Password reset tokens - `authentication.EmailVerificationToken`: Email verification tokens -**Workflows:** -- `workflows.WorkflowRequest`: Universal agent request model -- `workflows.WorkflowResponse`: Universal agent response model -- `workflows.WorkflowAnalytics`: Usage tracking and analytics +**Agents:** +- `agents.Agent`: Agent definitions with JSON form schemas and pricing +- `agents.AgentCategory`: Agent categories with icons and descriptions +- `agents.AgentExecution`: Execution history and results tracking **Payments:** - `wallet.Wallet`: User wallet with balance tracking @@ -137,49 +137,81 @@ gunicorn netcop_hub.wsgi:application - `DATABASE_URL`: PostgreSQL connection string (Railway) **N8N Webhook URLs:** -- `N8N_WEBHOOK_DATA_ANALYZER`: Data analysis agent webhook -- `N8N_WEBHOOK_FIVE_WHYS`: Five whys analysis webhook -- `N8N_WEBHOOK_JOB_POSTING`: Job posting generator webhook -- `N8N_WEBHOOK_FAQ_GENERATOR`: FAQ generator webhook -- `N8N_WEBHOOK_SOCIAL_ADS`: Social ads generator webhook +Agent-specific webhook URLs are stored in the database with each agent. Current working agents: +- Social Ads Generator: Creates compelling social media advertisements +- Job Posting Generator: Creates professional job postings +- PDF Summarizer: Analyzes and summarizes PDF documents with file upload ### URL Structure ``` / # Homepage (core app) /auth/ # Authentication (login, register, etc.) -/agents/ # Agent marketplace (workflows app) +/agents/ # Agent marketplace (agents app) /agents/{slug}/ # Individual agent pages /wallet/ # Wallet management /admin/ # Django admin ``` ### Key Components -**Agent Configuration (workflows/config/agents.py):** -- Centralizes all agent metadata (pricing, descriptions, webhooks) -- No database dependency for agent definitions -- Easy to add new agents by updating AGENT_CONFIGS +**Agent Configuration (Database-driven):** +- All agent metadata stored in database (pricing, descriptions, webhooks) +- JSON form schemas for dynamic form generation +- Easy to add new agents via management commands or admin interface **Templates:** - `templates/base.html`: Main layout with navigation - `templates/components/`: Reusable UI components -- `workflows/templates/workflows/`: Agent-specific forms and pages +- `agents/templates/agents/`: Dynamic agent forms and marketplace pages ## Adding New Agents -1. **Add agent config** in `workflows/config/agents.py`: +1. **Create management command** (recommended approach): ```python -'new-agent-slug': { - 'name': 'Agent Name', - 'description': 'Agent description', - 'price': 10.0, - 'icon': 'π€', - 'webhook_url': 'N8N_WEBHOOK_URL', -} +# agents/management/commands/create_new_agent.py +from django.core.management.base import BaseCommand +from agents.models import AgentCategory, Agent + +class Command(BaseCommand): + def handle(self, *args, **options): + category, _ = AgentCategory.objects.get_or_create( + slug='category-slug', + defaults={'name': 'Category Name', 'icon': 'π€'} + ) + + Agent.objects.get_or_create( + slug='agent-slug', + defaults={ + 'name': 'Agent Name', + 'short_description': 'Brief description', + 'description': 'Full description', + 'category': category, + 'price': 10.0, + 'form_schema': { + 'fields': [ + { + 'name': 'input_field', + 'type': 'text', + 'label': 'Input Field', + 'required': True + } + ] + }, + 'webhook_url': 'http://your-n8n-webhook-url' + } + ) ``` -2. **Create agent template** in `workflows/templates/workflows/{slug}.html` -3. **Add webhook URL** to environment variables -4. **Update N8N workflow** to handle new agent type +2. **Run the command**: `python manage.py create_new_agent` +3. **Update N8N workflow** to handle the new agent +4. **Agent will automatically appear** in marketplace with dynamic form generation + +**Supported Form Field Types:** +- `text`: Text input +- `textarea`: Multi-line text +- `select`: Dropdown with options +- `file`: File upload with drag-and-drop +- `url`: URL input with validation +- `checkbox`: Boolean checkbox ## Production Deployment @@ -220,9 +252,9 @@ gunicorn netcop_hub.wsgi:application **Testing agent webhooks locally:** 1. Use ngrok or similar to expose local server -2. Update webhook URLs in agent config +2. Update webhook URLs in agent database records 3. Test agent execution flow -4. Check WorkflowRequest/WorkflowResponse creation +4. Check AgentExecution records and results display --- -Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: 2025-07-31 22:55:38 +Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: 2025-07-31 23:12:15 diff --git a/agents/templates/agents/agent_detail.html b/agents/templates/agents/agent_detail.html index f920a43..6ec39e5 100644 --- a/agents/templates/agents/agent_detail.html +++ b/agents/templates/agents/agent_detail.html @@ -312,10 +312,10 @@ document.body.setAttribute('data-user-balance', '{{ user.wallet_balance }}');
Can't find what you're looking for?
{{ agent_subtitle }}
-- Discover powerful AI agents to automate your tasks, boost productivity, and streamline your workflow -
-{{ agent.price }} AED
-{{ agent.description }}
- - - {% endfor %} - {% endfor %} -{{ agent.price }} AED
-{{ agent.description }}
- - - {% endfor %} -