pip install -r requirements.txtpython -m backend.mainThe API will be available at: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/api/v1/health
Health Check:
curl http://localhost:8000/api/v1/healthCreate a Session:
curl -X POST http://localhost:8000/api/v1/chat/sessions \
-H "Content-Type: application/json" \
-d '{"title": "My First Research Session"}'Upload a Document:
curl -X POST http://localhost:8000/api/v1/documents/upload \
-F "file=@path/to/your/document.pdf"Stream a Query (in browser console):
const eventSource = new EventSource('http://localhost:8000/api/v1/chat/sessions/1/stream?query=What%20is%20AI');
eventSource.addEventListener('node_start', (e) => {
console.log('Node started:', JSON.parse(e.data));
});
eventSource.addEventListener('synthesis_complete', (e) => {
console.log('Answer ready:', JSON.parse(e.data));
});
eventSource.addEventListener('complete', (e) => {
console.log('Done:', JSON.parse(e.data));
eventSource.close();
});
eventSource.addEventListener('error', (e) => {
console.error('Error:', e.data);
});GET /api/v1/health- Basic health checkGET /api/v1/health/detailed- Detailed system status
POST /api/v1/documents/upload- Upload a documentGET /api/v1/documents- List all documentsGET /api/v1/documents/{id}- Get document detailsDELETE /api/v1/documents/{id}- Delete a documentGET /api/v1/documents/stats- Get statistics
POST /api/v1/chat/sessions- Create a new sessionGET /api/v1/chat/sessions- List all sessionsGET /api/v1/chat/sessions/{id}- Get session with messagesPATCH /api/v1/chat/sessions/{id}- Update sessionDELETE /api/v1/chat/sessions/{id}- Delete session
POST /api/v1/chat/sessions/{id}/messages- Send message (non-streaming)GET /api/v1/chat/sessions/{id}/stream?query=...- Stream research (SSE)
The SQLite database is automatically created at data/research_agent.db on first run.
sessions- Chat sessionsmessages- Chat messagesdocuments- Uploaded documents metadatasession_documents- Links between sessions and documents
The streaming endpoint emits these events:
node_start- Workflow node beginsnode_complete- Workflow node completestoken- Individual LLM token (if available)synthesis_complete- Final answer with sourcescomplete- Message saved, includes message_iderror- Error occurred
The React frontend will be initialized next. It will connect to this backend API.
- Make sure your
.envfile hasGEMINI_API_KEYconfigured - The vector store (Chroma) is shared with the CLI version
- All existing CLI functionality remains available