This system has been redesigned with a clear separation of concerns:
- Next.js Frontend & API: Handles all UI, database operations, and session management
- Python Backend: Handles only browser automation and AI agent execution
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ Frontend │ │ Next.js API │ │ Python Backend │
│ (React) │────│ (Database) │────│ (Browser Auto) │
│ │ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
│
┌─────────────────┐
│ │
│ Supabase DB │
│ │
└─────────────────┘
- Frontend: React components for UI
- API Routes:
/api/benchmark- Create new benchmark sessions, fetch user sessions/api/benchmark/[sessionId]- Get detailed session results/api/benchmark/update- Update benchmark status (called by Python backend)
- Database Service:
src/lib/database.tshandles all Supabase operations
- Browser Automation: Uses browseruse + LangChain for AI agents
- Endpoints:
/api/benchmark/execute- Execute benchmarks for all models/api/benchmark/stream/{session_id}- Stream logs via SSE/api/health- Health check
- No Database Operations: Calls Next.js API to update benchmark status
- User submits form on frontend
- Next.js API creates benchmark session in database
- Next.js API creates individual benchmark records for each model
- Next.js API calls Python backend to start execution
- Python backend runs AI agents and calls back to update status
- Frontend calls Next.js API to fetch sessions
- Next.js API queries database directly
- Results displayed in UI
- Python backend streams logs via SSE
- Python backend updates database via Next.js API
- Frontend can poll or use real-time subscriptions
- Clear Separation: Database logic in one place (Next.js)
- Scalability: Python backend is stateless for browser automation
- Maintainability: Easier to maintain and debug
- Type Safety: Shared TypeScript types between frontend and API
- Performance: Direct database queries from Next.js
NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key
NEXTJS_API_URL=http://localhost:3000
OPENAI_API_KEY=your-openai-api-key
NEXTJS_API_URL=http://localhost:3000
- Database: Ensure Supabase is configured with the schema
- Next.js:
npm run dev(runs on :3000) - Python:
cd python-backend && python main.py(runs on :8000)
Create new benchmark session
{
"websiteUrl": "https://example.com",
"taskDescription": "Find the contact page",
"userId": "user-uuid"
}Get user's benchmark sessions
Get detailed session results
Update benchmark status (internal use by Python backend)
Execute benchmark for all models (called by Next.js)
Stream benchmark logs via Server-Sent Events