+
+
+
+
+```
+
+## Step 7: Integration
+
+### 7.1 Add to Django Settings
+```python
+# netcop_hub/settings.py
+INSTALLED_APPS = [
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+
+ # Core apps
+ 'core',
+ 'authentication',
+ 'wallet',
+ 'agent_base',
+
+ # Agent apps
+ 'weather_reporter',
+ 'agent_pdf_analyzer', # Add this line
+]
+```
+
+### 7.2 Run Migrations
+```bash
+python manage.py makemigrations agent_pdf_analyzer
+python manage.py migrate
+```
+
+### 7.3 Create BaseAgent Entry
+```python
+# In Django shell or management command
+python manage.py shell
+
+from agent_base.models import BaseAgent
+from decimal import Decimal
+
+BaseAgent.objects.create(
+ name="PDF Analyzer",
+ slug="pdf-analyzer",
+ description="Extract text, generate summaries, and analyze sentiment from PDF documents",
+ category="utilities",
+ price=Decimal('5.00'),
+ icon="📄",
+ agent_type="api",
+ rating=Decimal('4.5'),
+ review_count=25,
+ is_active=True
+)
+```
+
+### 7.4 Environment Variables
+```bash
+# Add to .env file
+DOCPARSER_API_KEY=your_api_key_here
+```
+
+### 7.5 Admin Configuration
+```python
+# agent_pdf_analyzer/admin.py
+from django.contrib import admin
+from .models import PdfAnalyzerRequest, PdfAnalyzerResponse
+
+@admin.register(PdfAnalyzerRequest)
+class PdfAnalyzerRequestAdmin(admin.ModelAdmin):
+ list_display = ['id', 'user', 'status', 'analysis_type', 'created_at']
+ list_filter = ['status', 'analysis_type', 'created_at']
+ search_fields = ['user__email', 'user__username']
+ readonly_fields = ['id', 'created_at', 'processed_at']
+
+@admin.register(PdfAnalyzerResponse)
+class PdfAnalyzerResponseAdmin(admin.ModelAdmin):
+ list_display = ['id', 'request', 'success', 'confidence_score', 'created_at']
+ list_filter = ['success', 'created_at']
+ readonly_fields = ['id', 'created_at']
+```
+
+## Step 8: Testing
+
+### 8.1 Test Checklist
+- [ ] Agent appears in marketplace
+- [ ] Agent detail page loads correctly
+- [ ] Authentication required for access
+- [ ] File upload works
+- [ ] Form submission processes correctly
+- [ ] Wallet balance is checked
+- [ ] Payment is deducted
+- [ ] Processing completes successfully
+- [ ] Results are displayed
+- [ ] Error handling works
+
+### 8.2 Test Commands
+```bash
+# Test URL routing
+python manage.py check
+
+# Test database queries
+python manage.py shell
+>>> from agent_pdf_analyzer.models import *
+>>> from agent_base.models import BaseAgent
+>>> BaseAgent.objects.filter(slug='pdf-analyzer').exists()
+
+# Test processor
+>>> from agent_pdf_analyzer.processor import PdfAnalyzerProcessor
+>>> processor = PdfAnalyzerProcessor()
+>>> # Test with sample data
+```
+
+### 8.3 Browser Testing
+1. Visit `/marketplace/` - verify agent appears
+2. Click "Use Agent" - verify redirect to detail page
+3. Try without login - verify authentication required
+4. Upload test PDF file
+5. Submit form and monitor processing
+6. Check wallet balance deduction
+7. Verify results display
+
+## Troubleshooting
+
+### Common Issues
+
+#### 1. URL Namespace Errors
+**Error**: `NoReverseMatch: Reverse for 'wallet' not found`
+**Fix**: Use proper namespaces in templates:
+```html
+
+{% url 'wallet' %}
+
+
+{% url 'core:wallet' %}
+```
+
+#### 2. Template Not Found
+**Error**: `TemplateDoesNotExist: detail.html`
+**Fix**: Ensure template is in correct location within the agent app:
+```bash
+# Correct location:
+agent_[name]/templates/detail.html
+
+# Example:
+agent_pdf_analyzer/templates/detail.html
+
+# NOT in global templates folder
+# Restart Django server after moving templates
+```
+
+**Test template loading**:
+```bash
+python manage.py shell -c "
+from django.template.loader import get_template
+template = get_template('detail.html')
+print('✅ Template found:', template.origin.name)
+"
+```
+
+#### 3. Migration Issues
+**Error**: Database migration fails
+**Fix**:
+```bash
+python manage.py makemigrations agent_[name] --empty
+# Edit migration file if needed
+python manage.py migrate
+```
+
+#### 4. Import Errors
+**Error**: Module import fails
+**Fix**: Check `INSTALLED_APPS` and Python path:
+```python
+# Ensure app is in INSTALLED_APPS
+INSTALLED_APPS = [
+ # ...
+ 'agent_pdf_analyzer',
+]
+```
+
+#### 5. File Upload Issues
+**Error**: File upload fails
+**Fix**: Configure media settings:
+```python
+# settings.py
+MEDIA_URL = '/media/'
+MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
+
+# urls.py (in development)
+if settings.DEBUG:
+ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+```
+
+#### 6. API Integration Issues
+**Error**: External API calls fail
+**Fix**: Check API credentials and endpoints:
+```python
+# Test API connection
+import requests
+response = requests.get('https://api.example.com/test', headers={'Authorization': 'Bearer YOUR_KEY'})
+print(response.status_code, response.text)
+```
+
+## Advanced Customization
+
+### Custom Field Types
+```python
+# For complex data structures
+class PdfAnalyzerRequest(BaseAgentRequest):
+ # JSON field for complex configurations
+ analysis_config = models.JSONField(default=dict, blank=True)
+
+ # Custom validation
+ def clean(self):
+ super().clean()
+ if self.pdf_file and self.pdf_file.size > 10 * 1024 * 1024: # 10MB
+ raise ValidationError('PDF file too large (max 10MB)')
+```
+
+### Custom Business Logic
+```python
+# Override processor methods for custom logic
+class PdfAnalyzerProcessor(StandardAPIProcessor):
+
+ def pre_process_request(self, request_obj, **kwargs):
+ """Custom logic before API call"""
+ # Validate file format
+ # Compress large files
+ # Extract metadata
+ pass
+
+ def post_process_response(self, response_obj, **kwargs):
+ """Custom logic after API response"""
+ # Generate additional insights
+ # Send notifications
+ # Update analytics
+ pass
+```
+
+### Multiple API Integration
+```python
+class PdfAnalyzerProcessor(StandardAPIProcessor):
+
+ def process_request(self, request_obj, **kwargs):
+ """Custom multi-step processing"""
+ # Step 1: Extract text
+ text_response = self.call_text_extraction_api(**kwargs)
+
+ # Step 2: Analyze sentiment
+ sentiment_response = self.call_sentiment_api(text_response['text'])
+
+ # Step 3: Generate summary
+ summary_response = self.call_summary_api(text_response['text'])
+
+ # Combine results
+ combined_response = {
+ 'extracted_text': text_response['text'],
+ 'sentiment': sentiment_response['sentiment'],
+ 'summary': summary_response['summary'],
+ }
+
+ return self.process_response(combined_response, request_obj)
+```
+
+### Custom Template Components
+```html
+
+{% include 'components/file_upload.html' with accept='.pdf' max_size='10MB' %}
+{% include 'components/progress_bar.html' with status=request.status %}
+{% include 'components/result_display.html' with response=response %}
+```
+
+### Error Handling Patterns
+```python
+class PdfAnalyzerProcessor(StandardAPIProcessor):
+
+ def handle_api_error(self, error, request_obj):
+ """Custom error handling"""
+ if 'rate_limit' in str(error).lower():
+ # Retry after delay
+ return self.retry_with_delay(request_obj, delay=60)
+ elif 'invalid_file' in str(error).lower():
+ # User error - don't retry
+ return self.create_error_response(request_obj, "Invalid PDF file format")
+ else:
+ # Unknown error - log and notify
+ self.log_error(error, request_obj)
+ return super().handle_api_error(error, request_obj)
+```
+
+## Best Practices
+
+1. **Security**: Always validate file uploads, sanitize inputs, check permissions
+2. **Performance**: Implement caching, optimize database queries, handle large files efficiently
+3. **User Experience**: Provide clear feedback, show progress indicators, handle errors gracefully
+4. **Maintainability**: Use consistent naming, document complex logic, write tests
+5. **Monitoring**: Log important events, track usage metrics, monitor error rates
+
+## Summary
+
+This guide covers the complete process of creating an AI agent manually in the NetCop Hub platform. Following these steps ensures your agent integrates properly with the authentication, payment, and processing systems while providing a professional user experience.
+
+For automated agent creation, use the `create_agent` management command, but this manual approach gives you full control over customization and complex business logic.
\ No newline at end of file
diff --git a/docs/STRUCTURE_UPDATES.md b/docs/STRUCTURE_UPDATES.md
new file mode 100644
index 0000000..19c26c9
--- /dev/null
+++ b/docs/STRUCTURE_UPDATES.md
@@ -0,0 +1,71 @@
+# Project Structure Updates Summary
+
+## What Was Changed
+
+### ✅ **Folder Structure Cleanup**
+- **Root directory cleaned**: Moved test files to `tests/`, documentation to `docs/`
+- **Template organization**: Agent templates moved to their respective app directories
+- **Orphaned templates removed**: Deleted unused agent templates (5 legacy agents)
+- **Clean structure**: Now follows Django best practices
+
+### ✅ **Updated Documentation**
+
+#### **1. AGENT_SETUP_CHECKLIST.md**
+- Added **Step 6: Verify Template Structure**
+- Updated testing section with template verification commands
+- Added troubleshooting for `TemplateDoesNotExist` errors
+- Enhanced testing flow with authentication requirements
+
+#### **2. MANUAL_AGENT_CREATION_GUIDE.md**
+- Updated template troubleshooting section
+- Added template location verification commands
+- Clarified correct template structure within agent apps
+
+#### **3. CLAUDE.md**
+- Added project structure diagram
+- Updated template organization section
+- Replaced "Legacy vs New" with "Current Architecture"
+- Added best practices for clean structure
+
+## New Structure
+
+```
+netcop_django/
+├── 📁 docs/ # ← All guides and documentation
+├── 📁 tests/ # ← All test files
+├── 📁 agent_base/ # Agent framework
+├── 📁 authentication/ # User management
+├── 📁 core/ # Main functionality
+├── 📁 wallet/ # Payment system
+├── 📁 weather_reporter/ # Individual agent
+│ └── templates/ # ← Agent templates HERE (detail.html)
+├── 📁 templates/ # Global templates only
+├── 📁 static/ # Static assets
+├── 📁 media/ # User uploads
+├── 📁 netcop_hub/ # Django project
+└── manage.py
+```
+
+## Key Benefits
+
+1. **📁 Clean Organization**: Everything in logical places
+2. **🔧 Easy Maintenance**: Clear separation of concerns
+3. **📈 Scalable**: Ready for new agents
+4. **🚀 Professional**: Follows Django best practices
+5. **🎯 Developer Friendly**: Easy to navigate and understand
+
+## Important Notes
+
+- **Template Location**: Agent templates should be in `agent_name/templates/detail.html` (simplified structure)
+- **Restart Required**: Django server must be restarted after moving templates
+- **Testing**: Use the new template verification commands to ensure correct setup
+- **Documentation**: All guides now reflect the clean structure
+
+## For Developers
+
+When creating new agents:
+1. Use `create_agent` command for automated setup
+2. Follow the updated **AGENT_SETUP_CHECKLIST.md**
+3. Place templates in agent app directories
+4. Test template loading before deployment
+5. Keep root directory clean using `docs/` and `tests/` folders
\ No newline at end of file
diff --git a/future agent creation b/future agent creation
deleted file mode 100644
index 68b079e..0000000
--- a/future agent creation
+++ /dev/null
@@ -1,48 +0,0 @@
-● Future Agent Creation - What You Need to Tell Me
-
- 🎯 Minimum Required Information
-
- 1. Agent Basic Info
-
- - Agent Name: (e.g., "PDF Document Processor")
- - Description: (what it does)
- - Icon/Emoji: (e.g., 📄)
- - Cost: (credits per use)
-
- 2. Input Requirements
-
- - What inputs does the user provide?
- • File upload? (what file types?)
- • Text input? (what kind?)
- • Form fields? (which ones?)
- • Options/settings? (what choices?)
-
- 3. Processing Method
-
- - How should it work?
- • API integration? (which service?)
- • Mock/simulation? (what response?)
- • External webhook? (URL/endpoint?)
-
- 💡 Example Request
-
- "Create a PDF Document Processor agent:
- - Name: PDF Document Processor
- - Description: Extract text and summarize PDF documents
- - Icon: 📄
- - Cost: 35 credits
- - Input: PDF file upload (max 10MB)
- - Processing: OpenAI API for text extraction and summarization
- - Output: Text summary + key points"
-
- 🚀 What I'll Handle Automatically
-
- - ✅ Suspense wrappers
- - ✅ File structure (/agent/pdf-processor/page.tsx)
- - ✅ Slug mapping in agentUtils.ts
- - ✅ Complete component structure
- - ✅ Error handling
- - ✅ Credit system integration
- - ✅ UI consistency with existing agents
-
- Just give me the basics above and I'll build the complete agent for you!
diff --git a/netcop_hub/settings.py b/netcop_hub/settings.py
index 99a43fa..8151ccb 100644
--- a/netcop_hub/settings.py
+++ b/netcop_hub/settings.py
@@ -30,7 +30,7 @@ SECRET_KEY = config('SECRET_KEY', default='django-insecure-thdd^re4==p$4geq^$52w
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True # Force DEBUG=True for development
-ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1').split(',')
+ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1,testserver').split(',')
# Application definition
@@ -44,9 +44,10 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'rest_framework',
'authentication',
- 'agents',
'wallet',
'core',
+ 'agent_base',
+ 'weather_reporter',
]
MIDDLEWARE = [
@@ -140,7 +141,7 @@ MEDIA_ROOT = BASE_DIR / 'media'
STRIPE_SECRET_KEY = config('STRIPE_SECRET_KEY', default='')
STRIPE_WEBHOOK_SECRET = config('STRIPE_WEBHOOK_SECRET', default='')
-# N8N Webhooks
+# AI Assistant Webhooks
N8N_WEBHOOK_DATA_ANALYZER = config('N8N_WEBHOOK_DATA_ANALYZER', default='')
N8N_WEBHOOK_FIVE_WHYS = config('N8N_WEBHOOK_FIVE_WHYS', default='')
N8N_WEBHOOK_JOB_POSTING = config('N8N_WEBHOOK_JOB_POSTING', default='')
diff --git a/netcop_hub/urls.py b/netcop_hub/urls.py
index 152ccb4..c0bb593 100644
--- a/netcop_hub/urls.py
+++ b/netcop_hub/urls.py
@@ -21,8 +21,9 @@ from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
- path('', include('core.urls')),
path('auth/', include('authentication.urls')),
+ path('agents/weather-reporter/', include('weather_reporter.urls')),
+ path('', include('core.urls')),
]
# Serve static files during development
diff --git a/templates/authentication/login.html b/templates/authentication/login.html
index ce90883..fc9bbf4 100644
--- a/templates/authentication/login.html
+++ b/templates/authentication/login.html
@@ -37,6 +37,9 @@
{% else %}
- Insufficient Balance! You need ${{ agent.price }} to use this agent.
+ Insufficient Balance! You need {{ agent.price }} AED to use this agent.
Top up your wallet
No agents are currently available{% if selected_category %} in the {{ selected_category }} category{% endif %}. Check back later!
+
+ {% endif %}
+
+
+
+
\ No newline at end of file
diff --git a/templates/core/wallet.html b/templates/core/wallet.html
index 996126d..acb0fa5 100644
--- a/templates/core/wallet.html
+++ b/templates/core/wallet.html
@@ -26,21 +26,21 @@