Zurri Architecture - Agents Marketplace with Chat Protocol
Overview
Zurri has been refactored from a models+agents marketplace to an agents-only marketplace with a standardized chat protocol for communication.
Key Changes
β Removed
- Model entities and endpoints
- Proxy endpoints for model access
- Model-specific subscription logic
β Added/Updated
- Agent-focused architecture: All listings are fully packaged agents
- Chat Protocol: Standardized communication interface (
/api/chat/:id/message) - Conversation History: Persistent message storage per agent-user conversations
- Agent Endpoint Contract: Agents must implement standardized request/response format
Chat Protocol Specification
Agent Requirements
Agents must expose a POST endpoint that accepts:
{
message: string; // User's message
conversationId?: string; // Optional conversation identifier
metadata?: Record<string, any>; // Additional context
systemPrompt?: string; // Optional system prompt if configured
}
And returns:
{
response: string; // Agent's response (or "message" field accepted)
conversationId: string; // Conversation identifier
metadata?: Record<string, any>; // Optional response metadata
}
Client Usage
// Send message
POST /api/chat/:agentId/message
Authorization: Bearer <token>
{
"message": "Hello!",
"conversationId": "conv_123", // Optional
"metadata": {}
}
// Response
{
"response": "Hi there!",
"conversationId": "conv_123",
"metadata": {}
}
// Get history
GET /api/chat/:agentId/history?conversationId=conv_123&limit=50
Authorization: Bearer <token>
Data Flow
1. Agent Listing Creation
Creator β POST /api/agents
β Upload metadata to IPFS (Pinata)
β Store agent with PENDING status
β Admin approves β Status β APPROVED
2. User Subscription
User β POST /api/subscriptions/agent/:agentId
β Generate payment reference
β User pays via Paystack
β Webhook verifies β Subscription ACTIVE
3. Chat Communication
User β POST /api/chat/:agentId/message
β Verify subscription
β Forward to agent endpoint
β Save messages to database
β Return response to user
Database Schema
Core Entities
- Agent: Agent listings with IPFS metadata
- User: Platform users (creators and consumers)
- Subscription: Agent access subscriptions
- ChatMessage: Conversation history
- ApiKey: API key management (for future programmatic access)
Relationships
User 1---* Agent (creator)
User *---* Agent (via Subscription)
Agent 1---* ChatMessage
User 1---* ChatMessage
Security
- JWT Authentication: All protected routes require Bearer token
- Subscription Verification: Chat access requires active subscription
- Rate Limiting: Express rate limiter on all
/api/routes - Admin Only: Approval/rejection requires admin role
- Endpoint Protection: Agent endpoints hidden from non-creators
Payment Flow
User creates subscription
β
Payment reference generated
β
User completes Paystack payment
β
Paystack webhook β /api/subscriptions/webhook/paystack
β
Verify signature & payment
β
Activate subscription
Future Enhancements
- API key-based access (programmatic agent usage)
- Streaming chat responses
- Agent analytics dashboard
- Rating/review system
- Agent categories and tags
- Search and filtering improvements