mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 10:12:58 +00:00
- Remove non-working agents: CSV Data Analyzer, PDF Content Analyzer, Website Data Scraper - Clean up empty categories automatically - Update marketplace UI to match workflows design with enhanced styling - Fix PDF Summarizer display issue with array-format sections - Final state: 3 agents across 3 categories (Social Ads, Job Posting, PDF Summarizer) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
6.8 KiB
6.8 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 purchase AI agent services through a web interface, with agent execution handled via N8N webhooks and payments processed through Stripe.
Key Architecture:
- Django Framework: Main web application using Django 5.2.4
- Agent System: Unified workflows app handling all AI agents via N8N webhooks
- Authentication: Custom user model with email verification
- Payments: Stripe integration with wallet system
- 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
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 workflows
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
- workflows/: Unified agent system (marketplace, execution, models)
- wallet/: Stripe payments, wallet management, transactions
Agent System (workflows app)
Key Files:
workflows/config/agents.py: Agent definitions and configurationsworkflows/models.py: WorkflowRequest, WorkflowResponse, WorkflowAnalyticsworkflows/views.py: Marketplace and agent execution viewsworkflows/templates/workflows/: Agent-specific templates
Agent Flow:
- User selects agent from marketplace (
/agents/) - Fills agent-specific form (
/agents/{slug}/) - Form submission creates WorkflowRequest and calls N8N webhook
- N8N processes request and returns response via webhook
- WorkflowResponse stores results for user retrieval
Database Models
User Management:
authentication.User: Custom user model with email verificationauthentication.PasswordResetToken: Password reset tokensauthentication.EmailVerificationToken: Email verification tokens
Workflows:
workflows.WorkflowRequest: Universal agent request modelworkflows.WorkflowResponse: Universal agent response modelworkflows.WorkflowAnalytics: Usage tracking and analytics
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)
N8N Webhook URLs:
N8N_WEBHOOK_DATA_ANALYZER: Data analysis agent webhookN8N_WEBHOOK_FIVE_WHYS: Five whys analysis webhookN8N_WEBHOOK_JOB_POSTING: Job posting generator webhookN8N_WEBHOOK_FAQ_GENERATOR: FAQ generator webhookN8N_WEBHOOK_SOCIAL_ADS: Social ads generator webhook
URL Structure
/ # Homepage (core app)
/auth/ # Authentication (login, register, etc.)
/agents/ # Agent marketplace (workflows 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
Templates:
templates/base.html: Main layout with navigationtemplates/components/: Reusable UI componentsworkflows/templates/workflows/: Agent-specific forms and pages
Adding New Agents
- Add agent config in
workflows/config/agents.py:
'new-agent-slug': {
'name': 'Agent Name',
'description': 'Agent description',
'price': 10.0,
'icon': '🤖',
'webhook_url': 'N8N_WEBHOOK_URL',
}
- Create agent template in
workflows/templates/workflows/{slug}.html - Add webhook URL to environment variables
- Update N8N workflow to handle new agent type
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 config
- Test agent execution flow
- Check WorkflowRequest/WorkflowResponse creation
Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: Last updated: 2025-07-31 19:18:31