All backend API endpoints are served under the /api/v1 prefix. The backend defaults to http://localhost:8000.
Every request follows a strict tiered execution flow across the application stack:
sequenceDiagram
autonumber
participant UI as React Frontend (Axios)
participant GW as FastAPI Router (/api/v1)
participant Svc as Service Layer / AI Agent
participant DB as SQLite (WAL Mode)
UI->>GW: HTTP Request (Method + Path + Payload)
GW->>GW: Pydantic Schema Validation & Dependency Injection
GW->>Svc: Invoke Service Method (db Session)
alt Read Request
Svc->>DB: Query Entities (SQLAlchemy ORM)
DB-->>Svc: Entity Records / Tuples
else Write / Pipeline Request
Svc->>Svc: Agent Processing (LLM / Fallback / Logic)
Svc->>DB: INSERT / UPDATE / DELETE
DB-->>Svc: Commit Transaction
end
Svc-->>GW: Result Dictionary / Schema Model
GW-->>UI: APIResponse(success=True, data=..., message="...")
All responses conform to the standard APIResponse schema:
{
"success": true,
"data": { ... },
"message": "Human-readable status description"
}If an unhandled exception occurs, FastAPI catches it via unhandled_exception_handler, analyzes the failure signature, generates a user-friendly hint, captures the latest LLM diagnostics, and returns HTTP 500:
{
"success": false,
"message": "LLM API key may be missing or invalid. Check GROQ_API_KEY in backend/.env",
"data": {
"error": "Error code 401 - invalid_api_key",
"llm_diagnostics": [
{
"level": "warning",
"message": "LLM provider groq failed: Error code 401",
"timestamp": "2026-09-05T10:00:15.123456",
"duration": 0.42
}
]
}
}| Status Code | Meaning | Typical Trigger |
|---|---|---|
200 OK |
Success | Valid query or command execution |
400 Bad Request |
Validation Error | Request body does not match Pydantic schema |
404 Not Found |
Entity Missing | Task ID or Plan Date does not exist |
429 Too Many Requests |
Rate Limit | Groq TPM / RPM limits reached |
500 Internal Error |
Execution Failure | Database lock, unhandled LLM crash, or network timeout |
-
Purpose: Asynchronously triggers the complete 6-stage pipeline (
Ingestion$\rightarrow$ Extraction$\rightarrow$ Fusion$\rightarrow$ Quality$\rightarrow$ Prioritization$\rightarrow$ Planning). - Authentication: None (Local application).
- Request Body: None.
-
Internal Processing:
- Checks for active pipeline runs in
WorkflowRun. - If an active run exists but started
$> 5$ minutes ago, marks it as stale/failed. If active and$< 5$ minutes old, rejects the request. - Inserts a new
WorkflowRun(status='running', current_agent='ingestion'). - Dispatches
run_pipeline_taskto FastAPIBackgroundTasks. - Returns immediately with the generated
run_id.
- Checks for active pipeline runs in
-
Example Request:
curl -X POST http://localhost:8000/api/v1/orchestrate/run
-
Example Response (HTTP 200):
{ "success": true, "data": { "run_id": "4b2e88a0-7164-4e2a-a521-8f5c09772d1f", "status": "running", "completed_agents": [], "llm_diagnostics": [] }, "message": "Pipeline started in background" }
- Purpose: Polls the real-time execution state of a specific pipeline run.
- Path Parameters:
run_id(string, required) — Unique UUID of the pipeline run. - Processing: Queries
WorkflowRunby ID. - Example Request:
curl -X GET http://localhost:8000/api/v1/orchestrate/status/4b2e88a0-7164-4e2a-a521-8f5c09772d1f
- Example Response (HTTP 200):
{ "success": true, "data": { "run_id": "4b2e88a0-7164-4e2a-a521-8f5c09772d1f", "status": "completed", "started_at": "2026-09-05 10:00:00.123456", "completed_at": "2026-09-05 10:00:18.847120", "current_agent": null, "agents_completed": [ "ingestion", "extraction", "fusion", "quality", "prioritization", "planning" ], "error": null }, "message": "OK" }
- Purpose: Retrieves summary metrics and diagnostic status for the most recent pipeline execution.
- Processing: Queries the latest
WorkflowRun, computes total runs, averagesQualityReportoverall scores to determine system accuracy, and fetches average LLM latency fromLLMClient. - Example Response (HTTP 200):
{ "success": true, "data": { "latest_run": { "run_id": "4b2e88a0-7164-4e2a-a521-8f5c09772d1f", "status": "completed", "started_at": "2026-09-05 10:00:00.123456", "completed_at": "2026-09-05 10:00:18.847120", "current_agent": null, "agents_completed": ["ingestion", "extraction", "fusion", "quality", "prioritization", "planning"], "error": null }, "total_runs": 6, "system_accuracy": 78.4, "environment": "Development", "average_latency": 1420.5, "llm_diagnostics": [ { "level": "info", "message": "Groq request completed in 1.12s", "timestamp": "2026-09-05T10:00:08.120", "duration": 1.12 } ] }, "message": "OK" }
- Purpose: Executes Stage 1: parses raw source JSON files and commits
SourceEventrecords to the database. - Request Schema (
IngestRequest):{ "sources": ["github", "slack", "email", "calendar", "meetings"] } - Processing: Deletes all downstream tables to ensure clean slate, reads JSON data files, standardizes fields, and inserts into
source_events. - Example Response (HTTP 200):
{ "success": true, "data": { "total_events": 48, "per_source": { "github": 9, "slack": 15, "email": 6, "calendar": 10, "meeting": 8 }, "new_events": 48, "skipped_existing": 0, "incremental": false }, "message": "Ingestion completed" }
- Purpose: Returns the total count of ingested
SourceEventrecords currently in the database. - Example Response (HTTP 200):
{ "success": true, "data": { "total_events": 48 }, "message": "OK" }
- Purpose: Executes Stage 2: extracts explicit tasks (GitHub) and discovers hidden tasks (Email, Meeting, Slack).
-
Request Schema (
ExtractRequest):{ "include_hidden": true, "min_confidence": 0.5 } -
Processing:
- Clears existing downstream tables (
master_tasks,quality_reports, etc.). - Directly maps structured sources (
github,jira). - Uses a 4-worker
ThreadPoolExecutorto process unstructured items. Emails and meeting notes invokeopenai/gpt-oss-20bwith few-shot prompts; Slack messages invoke compiled regex heuristics. - Runs all candidates through
TaskValidator(filters noise, enforces bounds, deduplicates). - Discards tasks with confidence
$< \text{min_confidence}$ .
- Clears existing downstream tables (
-
Example Response (HTTP 200):
{ "success": true, "data": { "total_tasks": 42, "explicit_tasks": 9, "hidden_tasks": 33, "filtered_out": 4, "validation_stats": { "total": 46, "passed": 42, "filtered": 4, "reasons": { "title_too_short": 2, "duplicate_in_batch": 2 } }, "incremental": false, "tasks": [ { "id": "c1f76dae-9310-4820-a88a-d99c43d83b10", "title": "Fix payment gateway timeout in checkout", "description": "504 gateway timeout on Stripe endpoint", "task_type": "bug", "is_hidden": false, "assignee": "user-002", "deadline": "2026-09-06", "urgency": "critical", "confidence": 1.0, "source_event_id": "e8a12d8a-9f4c-4e8b-b892-d6683fae2170" } ] }, "message": "Extraction completed" }
- Purpose: Fetches all currently stored
TaskCandidaterecords without re-running extraction. - Example Response (HTTP 200):
{ "success": true, "data": { "total": 42, "explicit": 9, "hidden": 33, "tasks": [ ... ] }, "message": "OK" }
-
Purpose: Executes Stage 3: clusters similar candidates across platforms, merges duplicates, and creates canonical
MasterTaskrecords. - Request Body: None.
-
Processing:
- Computes similarity using title
SequenceMatcher($35%$ ), token Jaccard overlap ($35%$ ), and description similarity ($30%$ ). - Applies contextual penalties for differing assignees, deadlines, and sources.
- Merges duplicates into unified clusters, picking the longest title, aggregating descriptions, and retaining max urgency.
- Inserts
MasterTaskandTaskContextLinkrows.
- Computes similarity using title
-
Example Response (HTTP 200):
{ "success": true, "data": { "input_candidates": 42, "master_tasks": 35, "duplicates_merged": 7 }, "message": "Fusion completed" }
-
Purpose: Executes Stage 4: audits every
MasterTaskacross 7 completeness dimensions and assigns an actionability state. - Request Body: None.
-
Processing:
- Standard tasks are scored using the rule-based 7-dimension rubric (zero token cost).
- Critical tasks (
urgency == "critical") are evaluated usingopenai/gpt-oss-20bviaQUALITY_PROMPT. - Assigns actionability status:
actionable($\ge 55$ ),needs_info($< 55$ ), orblocked. - Formulates context-aware clarification questions for missing elements.
-
Example Response (HTTP 200):
{ "success": true, "data": { "total_evaluated": 35, "actionable": 28, "needs_info": 7, "avg_score": 74.2, "reports": [ { "id": "q-9912", "master_task_id": "m-1001", "task_title": "Fix payment gateway timeout in checkout", "overall_score": 82.5, "clear_title_score": 85.0, "reproduction_steps_score": 80.0, "error_logs_score": 85.0, "environment_score": 80.0, "expected_behavior_score": 80.0, "severity_score": 90.0, "assignee_score": 85.0, "missing_info": [], "clarification_questions": [], "actionability": "actionable" } ] }, "message": "Quality evaluation completed" }
- Purpose: Retrieves all existing
QualityReportrecords with their associated task titles. - Example Response (HTTP 200):
{ "success": true, "data": [ { "id": "q-9912", "master_task_id": "m-1001", "task_title": "Fix payment gateway timeout in checkout", "overall_score": 82.5, "actionability": "actionable", "missing_info": [], "clarification_questions": [] } ], "message": "OK" }
- Purpose: Executes Stage 5: computes 7-factor priority scores, applies anti-noise modifiers and blocker boosts, and generates the ranked Leaderboard.
- Request Body: None.
-
Processing:
- Calculates multi-factor scores: Severity (
$24%$ ), Production ($18%$ ), Customer ($16%$ ), Deadline ($12%$ ), Blocker ($10%$ ), Business ($10%$ ), Quality ($10%$ ). - Applies anti-noise multipliers (vague titles
$0.55\times$ , reporting tasks$0.72\times$ ). - Checks for blocker keywords (
$+2.0$ boost). - Batches critical tasks to
openai/gpt-oss-20b(batch size 8) for nuanced reasoning. - Generates human-readable narrative explanation and dynamic
priority_reasontags. - Ranks tasks in descending order of overall score.
- Calculates multi-factor scores: Severity (
-
Example Response (HTTP 200):
{ "success": true, "data": { "total_ranked": 35, "ranked_tasks": [ { "id": "p-001", "master_task_id": "m-1001", "task_title": "Fix payment gateway timeout in checkout", "overall_score": 9.4, "rank": 1, "severity_score": 9.6, "deadline_score": 9.6, "production_impact_score": 9.8, "customer_impact_score": 9.5, "blocker_score": 3.0, "business_impact_score": 9.7, "quality_factor_score": 8.3, "priority_reason": [ "Classified as incident (elevated priority)", "High severity (9.6/10)", "Critical production impact (9.8/10)", "High customer impact (9.5/10)", "Reported by 2 merged signals" ], "explanation": "This task is prioritized with a score of 9.4/10 due to being classified as a critical incident issue, its elevated technical severity (9.6/10), high risk of production outage or infrastructure impact, and direct customer-facing degradation.", "sources": ["github", "email"] } ] }, "message": "Prioritization completed" }
- Purpose: Retrieves the prioritized Leaderboard sorted strictly by
rank(1 being the highest priority). - Example Response (HTTP 200):
{ "success": true, "data": [ { "id": "p-001", "master_task_id": "m-1001", "task_title": "Fix payment gateway timeout in checkout", "overall_score": 9.4, "rank": 1, "priority_reason": ["High severity (9.6/10)"], "explanation": "...", "sources": ["github", "email"] } ], "message": "OK" }
- Purpose: Queries the complete list of
MasterTaskrecords with filtering support. - Query Parameters:
status(string, optional): Filter by task status ("open","in_progress","done").assignee(string, optional): Filter by assignee ID/name (e.g.,"user-002").source(string, optional): Comma-separated list of sources (e.g.,source=github,email).
- Processing: Uses bulk relational joins (
_bulk_source_platformsand_bulk_context_counts) to avoid N+1 query overhead. - Example Request:
curl -X GET "http://localhost:8000/api/v1/tasks?status=open&source=github" - Example Response (HTTP 200):
{ "success": true, "data": { "total": 9, "tasks": [ { "id": "m-1001", "title": "Fix payment gateway timeout in checkout", "description": "504 gateway timeout on Stripe endpoint", "task_type": "bug", "status": "open", "assignee": "user-002", "deadline": "2026-09-06", "urgency": "critical", "source_count": 2, "estimated_hours": 1.0, "is_hidden": false, "sources": ["github", "email"], "source_platforms": ["github", "email"], "context_count": 2, "agent_summary": "Fusion agent merged 2 related signals from github, email.", "created_at": "2026-09-05T10:00:10.000000" } ] }, "message": "OK" }
- Purpose: Retrieves complete 360-degree telemetry for a single task: master metadata, quality report breakdown, priority score details, and lineage links to original source events.
- Path Parameters:
task_id(string, required) — UUID of theMasterTask. - Example Response (HTTP 200):
{ "success": true, "data": { "task": { "id": "m-1001", "title": "Fix payment gateway timeout in checkout", "description": "...", "task_type": "bug", "status": "open", "assignee": "user-002", "deadline": "2026-09-06", "urgency": "critical", "source_count": 2, "sources": ["github", "email"] }, "quality": { "overall_score": 82.5, "actionability": "actionable", "clear_title_score": 85.0, "reproduction_steps_score": 80.0, "error_logs_score": 85.0, "environment_score": 80.0, "expected_behavior_score": 80.0, "severity_score": 90.0, "assignee_score": 85.0, "missing_info": [], "clarification_questions": [] }, "priority": { "overall_score": 9.4, "rank": 1, "explanation": "...", "priority_reason": ["High severity (9.6/10)"], "severity_score": 9.6, "deadline_score": 9.6, "production_impact_score": 9.8, "customer_impact_score": 9.5, "dependency_score": 4.8, "blocker_score": 3.0, "business_impact_score": 9.7, "quality_factor_score": 8.3 }, "context_links": [ { "source": "github", "title": "Stripe timeout error on checkout page", "content": "Users seeing 504 error...", "link_type": "origin" }, { "source": "email", "title": "URGENT: Payment Gateway Timeouts in Prod", "content": "We are observing 504 gateway timeouts...", "link_type": "related" } ] }, "message": "OK" }
- Purpose: Updates the workflow state of a task (e.g., marks as completed).
- Request Body:
{ "status": "done" } - Example Response (HTTP 200):
{ "success": true, "data": { "task_id": "m-1001", "status": "done" }, "message": "Task status updated to done" }
- Purpose: Executes Stage 6: builds a calendar-aware schedule for a specific date, locking calendar commitments, inserting top priority tasks, and injecting decompression breaks.
-
Request Schema (
DailyPlanRequest):{ "user_id": "user-001", "date": "2026-07-14", "buffer_hours": 1.0 } -
Processing:
- Deletes any pre-existing plan for
(user_id, date). - Queries
calendar.jsonfor fixed meetings on that date. - Calculates available focus hours:
$8.0\text{h} - \text{Meeting Hours} - \text{Buffer Hours}$ . - Fetches top 12 prioritized tasks.
- Invokes
openai/gpt-oss-120b(or deterministic greedy allocator). - Validates schedule constraints (no meeting overlaps, hours within limits).
- Injects 15-minute decompression breaks.
- Commits
DailyPlanandTimeSlotentities.
- Deletes any pre-existing plan for
-
Example Response (HTTP 200):
{ "success": true, "data": { "id": "dp-4401", "user_id": "user-001", "plan_date": "2026-07-14", "available_hours": 5.5, "planned_hours": 4.5, "buffer_hours": 1.0, "load_status": "healthy", "recommendations": [ "Lead with 'Fix payment gateway timeout in checkout' — top-ranked critical work, protect this block first.", "Full backlog fits today; keep buffer reserved for incident follow-ups." ], "overflow_tasks": [], "time_slots": [ { "start_time": "09:00", "end_time": "09:30", "slot_type": "meeting", "priority_level": "neutral", "title": "Engineering Daily Standup", "master_task_id": null }, { "start_time": "09:30", "end_time": "10:30", "slot_type": "task", "priority_level": "critical", "title": "Fix payment gateway timeout in checkout", "master_task_id": "m-1001" }, { "start_time": "10:30", "end_time": "10:45", "slot_type": "buffer", "priority_level": "neutral", "title": "Mid-Morning Coffee Break", "master_task_id": null } ] }, "message": "Daily plan generated" }
- Purpose: Retrieves the saved daily schedule and time slots for a specific date (
YYYY-MM-DD). - Example Response (HTTP 200):
{ "success": true, "data": { "id": "dp-4401", "plan_date": "2026-07-14", "load_status": "healthy", "available_hours": 5.5, "planned_hours": 4.5, "time_slots": [ ... ] }, "message": "OK" }
- Purpose: Lists all dates for which a
DailyPlanhas been generated. - Example Response (HTTP 200):
{ "success": true, "data": ["2026-07-14", "2026-09-05"], "message": "OK" }
- Purpose: Groups all tasks possessing deadlines by date (
YYYY-MM-DD), sorted by priority score. Used by the frontend month/week calendar view. - Example Response (HTTP 200):
{ "success": true, "data": { "2026-09-06": [ { "id": "m-1001", "title": "Fix payment gateway timeout in checkout", "priority": 9.4, "deadline": "2026-09-06", "status": "open" } ] }, "message": "OK" }
- Purpose: Fetches the granular tasks scheduled for a given date. If a plan exists, returns timeslot items; otherwise falls back to tasks with matching deadlines.
- Example Response (HTTP 200):
{ "success": true, "data": [ { "title": "Fix payment gateway timeout in checkout", "priority": 9.4 } ], "message": "OK" }
- Purpose: Generates a multi-day schedule allocation for all uncompleted tasks across future working days.
- Query Parameters:
start_date(string, required, format"YYYY-MM-DD"). - Processing: Distributes work across consecutive days up to 8.0 hours/day before task deadlines.
- Example Request:
curl -X POST "http://localhost:8000/api/v1/planner/schedule?start_date=2026-09-05" - Example Response (HTTP 200):
{ "success": true, "data": { "2026-09-05": [ { "task_id": "m-1001", "title": "Fix payment gateway timeout in checkout", "hours": 1.0 } ] }, "message": "Schedule generated" }
- Purpose: Interactive natural language copilot and P1 incident injection interface.
- Request Schema (
ChatRequest):{ "message": "What is my highest priority task today?", "context": null }
When the message is a general query, the backend injects the top 20 tasks, leaderboard rankings, and active daily plan into the prompt, returning a structured markdown response:
- Example Response (HTTP 200):
{ "success": true, "data": { "reply": "Your highest priority task today is **Fix payment gateway timeout in checkout** (Score: **9.4/10**, Rank: **#1**). It is a critical production bug reported across GitHub and Email affecting payment transactions.", "llm_diagnostics": [ ... ] }, "message": "Response generated" }
When the message contains keywords such as "inject", "p1", or "new defect":
- The LLM extracts incident parameters.
- The event is written directly to the datastore (e.g.,
emails.jsonorgithub_data.json). - The orchestrator triggers an autonomous incremental pipeline run (
run_full_pipeline(incremental=True)). - The new task's priority rank is returned.
-
Example Request:
{ "message": "inject a P1 defect - auth service returning 500 on all mobile logins" } -
Example Response (HTTP 200):
{ "success": true, "data": { "reply": "🚨 **P1 Incident Injected!**\n\nI have successfully injected a new raw event into the system datastore:\n* **Title**: Auth service returning 500 on all mobile logins\n* **Source**: EMAIL\n\n**Pipeline Orchestrator triggered autonomously...** All stages (Ingestion $\\rightarrow$ Extraction $\\rightarrow$ Fusion $\\rightarrow$ Quality check $\\rightarrow$ Prioritization $\\rightarrow$ Daily Schedule Planning) have been re-run. The task has been prioritized with score **9.6** and ranked **#1** on your Leaderboard.\n\nCheck the **Dashboard**, **Priority**, and **Planner** pages to see the live updates!" }, "message": "Event injected and pipeline re-run" }
- Purpose: Liveness and readiness probe for server uptime and LLM provider configuration status.
- Example Response (HTTP 200):
{ "status": "healthy", "config": { "groq_configured": true, "llm_providers_available": true }, "llm_diagnostics": [] }
See also: Agent Architecture for individual agent logic, System Architecture for layer topologies, and Pipeline Flow for end-to-end data processing.