Cleanup Tasks Completed: • Remove populate_agents management command (obsolete with file-based agents) • Clean up unused Agent serializers and API endpoints • Remove redundant database model imports and queries • Update documentation to reflect file-based architecture Technical Changes: • Deleted agents/management/commands/populate_agents.py • Removed AgentSerializer and AgentCategorySerializer (unused) • Removed agent_list and agent_detail API endpoints (replaced by file service) • Cleaned up unused imports (models.db) • Updated CLAUDE.md documentation for file-based system Benefits: • Cleaner codebase with 100+ lines removed • No obsolete database commands • Streamlined API surface (only execution-related endpoints remain) • Updated documentation reflects current architecture • All functionality verified working All 8 agents and marketplace functionality confirmed operational after cleanup. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
10 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Quantum Tasks AI is a Django-based AI agent marketplace platform. Users can access AI agent services through a web interface, with execution handled via two distinct systems: N8N webhook integrations and direct form access integrations.
Key Architecture:
- Django Framework: Main web application using Django 5.2.4
- Agent System: Database-driven agents app with dual integration systems:
- Webhook Agents: N8N integrations for complex processing
- Direct Access Agents: Form-based integrations (JotForm, etc.)
- Authentication: Custom user model with email verification
- Payments: Stripe integration with wallet system (supports free agents)
- Database: SQLite for development, PostgreSQL for production (Railway)
- Static Files: WhiteNoise for production static file serving
Development Commands
Environment Setup
# Use virtual environment
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt # Production
pip install -r requirements-dev.txt # Development
# Start development server
./run_dev.sh # Recommended - includes migration checks
# OR
python manage.py runserver # Direct Django server
Database Operations
# Make migrations
python manage.py makemigrations
# Apply migrations
python manage.py migrate
# Create superuser
python manage.py createsuperuser
# Database shell
python manage.py dbshell
# Check database configuration
python manage.py check_db
Agent Management (File-Based System)
# Agents are managed via JSON files - no commands needed!
# Simply add/edit JSON files in agents/configs/agents/
# View agent statistics
python -c "
from agents.services import AgentFileService
stats = AgentFileService.get_agent_stats()
print('Agent Stats:', stats)
"
Testing
# Run Django tests
python manage.py test
# Run pytest (if configured)
pytest
# Run specific app tests
python manage.py test authentication
python manage.py test agents
python manage.py test wallet
# Custom test scripts
python tests/simple_test.py
python tests/check_agents.py
Code Quality (Development Dependencies)
# Format code
black .
# Sort imports
isort .
# Lint code
flake8
# Type checking (if available)
mypy .
Production Commands
# Collect static files
python manage.py collectstatic --noinput
# Production server (via Gunicorn)
gunicorn netcop_hub.wsgi:application
Core Architecture
Apps Structure
- authentication/: Custom user model, email verification, password reset
- core/: Homepage, error handlers, utility functions
- agents/: File-based agent system (marketplace, execution history, REST API for executions)
- wallet/: Stripe payments, wallet management, transactions
Agent System (agents app)
Key Files:
agents/services.py: AgentFileService - file-based agent managementagents/configs/agents/: JSON agent configuration filesagents/configs/categories/: JSON category configuration filesagents/models.py: AgentExecution, ChatSession models (execution history)agents/views.py: Dual integration systems and web interface viewsagents/templates/agents/: Dynamic agent templates and marketplacetemplates/career_navigator.html: Direct access form template
Dual Integration Systems:
System 1: Webhook Agents (N8N Integration)
- User browses marketplace (
/agents/) - Clicks "Try Now" → Agent detail page (
/agents/{slug}/) - Fills dynamic form → Form submission calls
/agents/api/execute/ - N8N webhook processes request and returns response
- Results displayed with file upload support
System 2: Direct Access Agents (Form Integration)
- User browses marketplace (
/agents/) - Clicks special "Try Now" button → Direct access (
/agents/{slug}/access/) - Payment processed → Redirect to form page (
/agents/{slug}/) - Form displays embedded interface (JotForm, etc.)
- User interacts directly with external form system
Database Models
User Management:
authentication.User: Custom user model with email verificationauthentication.PasswordResetToken: Password reset tokensauthentication.EmailVerificationToken: Email verification tokens
Agents:
agents.Agent: Agent definitions with JSON form schemas and pricingagents.AgentCategory: Agent categories with icons and descriptionsagents.AgentExecution: Execution history and results tracking
Payments:
wallet.Wallet: User wallet with balance trackingwallet.WalletTransaction: Transaction history and Stripe integration
Settings Configuration
Environment Variables (Required for Production):
SECRET_KEY: Django secret keyALLOWED_HOSTS: Comma-separated list of allowed hostsEMAIL_HOST_USER,EMAIL_HOST_PASSWORD: SMTP credentialsSTRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET: Stripe API keysDATABASE_URL: PostgreSQL connection string (Railway)
Current System: The platform supports 8 total agents across 6 categories:
- 4 Webhook Agents (N8N integration): Social Ads Generator, Job Posting Generator, PDF Summarizer, 5 Whys Analyzer
- 4 Direct Access Agents (External forms): CyberSec Career Navigator, AI Brand Strategist, Lean Six Sigma Expert, SWOT Analysis Expert
For detailed agent information and creation instructions, see docs/AGENT_CREATION.md.
URL Structure
/ # Homepage (core app)
/digital-branding/ # Digital branding services page
/auth/ # Authentication (login, register, etc.)
/agents/ # Agent marketplace (agents app)
/agents/{slug}/ # Individual agent pages (webhook agents)
/agents/{slug}/access/ # Direct access agent payment processing
/wallet/ # Wallet management
/admin/ # Django admin
Key Components
Agent Configuration (File-driven):
- All agent metadata stored in JSON files (pricing, descriptions, webhooks)
- JSON form schemas for dynamic form generation
- Instant agent creation by adding JSON files (no commands needed)
- Automatic database sync for foreign key compatibility
Templates:
templates/base.html: Main layout with navigationtemplates/components/: Reusable UI componentsagents/templates/agents/: Dynamic agent forms and marketplace pages
Adding New Agents
For comprehensive agent creation instructions, see docs/AGENT_CREATION.md.
Quick Summary:
- Create JSON config in
agents/configs/agents/your-agent-name.json - Git push (or restart server locally)
- Agent appears in marketplace automatically - no commands needed!
The platform supports 2 agent types:
- Webhook Agents - N8N integration with dynamic forms
- Direct Access Agents - External forms (JotForm, etc.) with embedded interfaces
Production Deployment
Railway Configuration:
- Automatic deployment from git repository
- PostgreSQL database provided by Railway
- Environment variables configured in Railway dashboard
- Static files served via WhiteNoise
Security Features:
- CSRF protection enabled
- Rate limiting on sensitive endpoints
- Secure headers in production
- HTTPS redirect and HSTS headers
- Session and cookie security
Development Notes
- Database: Uses SQLite by default for development reliability
- Cache: Redis preferred, falls back to local memory cache
- Email: Console backend in development, SMTP in production
- Debug Tools: Debug toolbar and Django extensions available in development
- Static Files: Collected to
staticfiles/directory for production - Media Files: User uploads stored in
media/directory
Common Development Tasks
Adding new environment variables:
- Add to
settings.pywithconfig()call - Add to required_env_vars list if production-required
- Document in this file
Database changes:
- Make model changes
- Run
python manage.py makemigrations - Review migration file
- Run
python manage.py migrate
Testing agent webhooks locally:
- Use ngrok or similar to expose local server
- Update webhook URLs in agent database records
- Test agent execution flow
- Check AgentExecution records and results display
System Status
Current Status: ✅ STABLE COMPREHENSIVE SYSTEM
- 8 agents confirmed working and tested (4 webhook + 4 direct access)
- 6 categories with clean, logical organization
- Dual integration architecture with clear separation and documentation
- Streamlined agent creation via JSON configs (instant file-based loading)
- Scalable architecture ready for 100+ agents
Current Agents:
- Webhook Agents (4): Social Ads Generator, Job Posting Generator, PDF Summarizer, 5 Whys Analyzer
- Direct Access Agents (4): CyberSec Career Navigator, AI Brand Strategist, Lean Six Sigma Expert, SWOT Analysis Expert
Latest Changes:
- Added SWOT Analysis Expert with proper category assignment (analysis)
- Streamlined agent creation process to use only JSON files (instant loading)
- Separated documentation into focused files (
docs/AGENT_CREATION.md) - Removed 10+ redundant management commands for cleaner codebase
- Fixed marketplace consistency and updated documentation
Architecture Status:
- Error-free agent creation via file-based JSON configuration
- Railway-ready deployment with automatic agent population
- Consistent UI standards across all marketplace components
- Comprehensive documentation prevents common development mistakes
Future Development:
- New agents should follow patterns in
docs/AGENT_CREATION.md - Use existing categories first to avoid unnecessary proliferation
- JSON file-based approach is the only supported creation method
Last updated: 2025-01-08
Documentation
- Quick Agent Requests: See
docs/AGENT_REQUEST_TEMPLATE.mdfor simple agent request template - Agent Creation: See
docs/AGENT_CREATION.mdfor comprehensive agent creation guide - Project Overview: This file (CLAUDE.md) for Django development and architecture