Tài liệu tham khảo tất cả REST API endpoints của hệ thống.
Base URL: http://localhost:8000
Auth: JWT Bearer token (lấy từ /api/auth/token)
Content-Type: application/json
Liveness probe.
Response:
{ "status": "ok", "queue_backend": "thread" }Readiness probe. Kiểm tra storage có load được không.
Response (200):
{ "status": "ready" }Response (503):
{ "status": "not_ready", "error": "..." }API root info.
Response:
{
"status": "online",
"service": "Unified AI Software Factory API Backend",
"version": "1.0.0",
"docs_url": "/docs"
}Tạo JWT authentication token. Endpoint này là admin-only và bắt buộc header X-Admin-Key.
Headers:
| Name | Type | Required | Description |
|---|---|---|---|
X-Admin-Key |
string | ✅ | Phải khớp ADMIN_API_KEY trong .env |
Body:
{
"team_id": "default",
"role": "admin"
}Response:
{
"token": "eyJhbGciOi...",
"team_id": "default",
"role": "admin",
"expires_in": 86400
}Token payload chứa team_id, role, iat, exp.
Errors:
401— Admin key thiếu hoặc không đúng503—ADMIN_API_KEYchưa được cấu hình
Lấy thông tin user hiện tại từ JWT token.
Headers: Authorization: Bearer <token>
Response:
{ "team_id": "default" }Errors:
401— Token không hợp lệ hoặc thiếu
Liệt kê tất cả generation jobs.
Response: Array of job objects.
Tạo Flutter generation job mới. Enqueue vào thread hoặc RQ.
Body:
{
"name": "My App",
"description": "A todo list app",
"platform": "android,ios",
"style": "modern",
"backend": "none",
"features": "auth,notifications",
"slug": "my-app"
}| Field | Type | Default | Required |
|---|---|---|---|
name |
string | — | ✅ |
description |
string | — | ✅ |
platform |
string | "android,ios" |
❌ |
style |
string | "modern" |
❌ |
backend |
string | "none" |
❌ |
features |
string | "" |
❌ |
slug |
string | auto-generated | ❌ |
Response: 202 with job object.
Lấy thông tin một job.
Response: Job object hoặc 404.
Xóa job.
Parameters:
| In | Name | Type | Default | Description |
|---|---|---|---|---|
| Query | purge |
bool | false |
Nếu true, xóa luôn thư mục generated app trên disk |
Trạng thái chi tiết từng phase của job.
Response:
{
"create": "passed",
"ba": "passed",
"backend": "pending",
"architect": "running",
"uiux": "pending",
"dev": "pending",
"qa": "pending",
"refactor": "pending",
"repair": "pending",
"runtime": "pending",
"security": "pending",
"reviewer": "pending",
"export": "pending"
}Status hợp lệ: pending, running, passed, failed, skipped, cancelled.
Phase 3 target sẽ mở rộng endpoint này thành response dạng list object có phase, agent, started_at, finished_at, error, và log metadata.
Hủy job đang queued hoặc running.
Response:
{
"slug": "my-app",
"status": "cancel_requested",
"cancel_requested": true
}Worker/pipeline sẽ phát hiện cancel_requested trước khi bắt đầu phase tiếp theo và chuyển job sang cancelled.
Errors:
404— Job không tồn tại409— Job không còn ở trạng tháiqueuedhoặcrunning
Tải source code ZIP. Returns FileResponse hoặc 404.
Browse file tree của generated app (chỉ source/ và docs/).
Response:
[
{ "path": "source/lib/main.dart", "name": "main.dart", "isDir": false, "size": 1234 },
{ "path": "source/lib/features", "name": "features", "isDir": true, "size": 0 }
]Đọc nội dung một file trong generated app.
Parameters:
| In | Name | Type | Required | Description |
|---|---|---|---|---|
| Query | path |
string | ✅ | Relative path (chỉ source/ và docs/, max 500KB) |
Response:
{ "path": "source/lib/main.dart", "content": "import ..." }Liệt kê tất cả project initiatives.
Tạo project mới.
Body:
{
"name": "Flutter Todo App",
"description": "A simple todo list application",
"slug": "flutter-todo",
"status": "discovery",
"health": "healthy",
"icon": "📱",
"repository": "",
"monthly_spend": 0,
"sla": "100%",
"build_progress": 0,
"features": ["auth", "notifications"]
}Lấy thông tin project. Returns 404 nếu không tìm thấy.
Cập nhật project (upsert).
Xóa project.
Liệt kê cấu hình tất cả agents.
Response:
[
{ "agent_id": "dev_agent", "name": "Dev Agent", "model": "gpt-4o", "system_prompt": "...", "updated_at": "..." }
]Cập nhật model và system prompt của agent.
Body:
{
"model": "gpt-4o-mini",
"system_prompt": "You are a senior developer..."
}Lấy thông tin chi tiết một agent.
Response:
{
"agent_id": "dev_agent",
"name": "Dev Agent",
"type": "flutter_factory",
"status": "active",
"model": "gpt-4o",
"system_prompt": "...",
"description": "...",
"updated_at": "2025-01-15T10:30:00"
}Cập nhật agent (partial update).
Body:
{
"model": "gpt-4o-mini",
"system_prompt": "Updated prompt..."
}Test agent bằng cách gửi prompt thử nghiệm.
Response:
{
"agent_id": "dev_agent",
"model": "gpt-4o",
"status": "ok",
"response": "OK"
}Lấy tất cả system settings.
Response:
{
"daily_cost_limit": "5.00",
"smart_model_fallback": "anthropic/claude-3.5-sonnet",
"max_repair_attempts": "5"
}Cập nhật system settings. Persist vào SQLite và .env.
Body:
{
"daily_cost_limit": "10.00",
"max_repair_attempts": "3"
}Lấy danh sách models từ LLM provider.
Parameters:
| In | Name | Type | Description |
|---|---|---|---|
| Query | provider |
string | Provider name (optional) |
| Query | key |
string | API key (optional) |
| Query | base_url |
string | Base URL (optional) |
Liệt kê tất cả registered LLM providers.
Thêm provider mới (name trong body).
Body:
{
"name": "my-provider",
"base_url": "https://api.example.com/v1",
"api_key_env": "EXAMPLE_API_KEY",
"default_model": "example-model-v1",
"enabled": true
}Thêm hoặc upsert custom provider (name trong URL).
Body:
{
"base_url": "https://api.example.com/v1",
"api_key_env": "EXAMPLE_API_KEY",
"default_model": "example-model-v1",
"enabled": true
}Cập nhật một phần provider config.
Xóa custom provider.
Kích hoạt provider làm LLM chính (ghi LLM_PROVIDER vào .env).
Test kết nối đến provider.
Response:
{ "provider": "openrouter", "status": "ok", "models_count": 42 }Các endpoint HITL yêu cầu
Authorization: Bearer <token>header.
Liệt kê experiences (pending, approved, rejected) của team hiện tại.
Phê duyệt experience.
Từ chối experience.
Parameters:
| In | Name | Type | Description |
|---|---|---|---|
| Query | reason |
string | Lý do từ chối (optional) |
Liệt kê checkpoints (pending, approved, rejected).
Phê duyệt checkpoint.
Từ chối checkpoint.
Unified queue: gộp experiences + checkpoints pending.
Response:
{
"pending": [
{ "type": "experience", "id": "exp-1", "content": "..." },
{ "type": "checkpoint", "id": "cp-1", "action": "..." }
],
"counts": { "experiences": 3, "checkpoints": 1 }
}Phê duyệt item (tự động tìm trong experiences hoặc checkpoints).
Từ chối item.
Parameters:
| In | Name | Type | Description |
|---|---|---|---|
| Query | reason |
string | Lý do từ chối (optional) |
Tóm tắt workflow tasks: total, success, failed counts + 20 logs gần nhất.
Agent activity logs.
Parameters:
| In | Name | Type | Default | Description |
|---|---|---|---|---|
| Query | limit |
int | 50 |
Số log entries (1-500) |
100 log entries gần nhất có action permission_denied.
Aggregated cost breakdown: total cost, total tokens, by task, by agent.
Cost summary overview.
Response:
{
"total_cost_usd": 12.50,
"total_calls": 42,
"avg_cost_per_call": 0.2976,
"top_agent": "dev_agent"
}Cost breakdown theo agent.
Response:
[
{ "agent": "dev_agent", "cost_usd": 5.20, "calls": 15, "tokens_in": 50000, "tokens_out": 20000 },
{ "agent": "qa_agent", "cost_usd": 3.10, "calls": 10, "tokens_in": 30000, "tokens_out": 10000 }
]Cost breakdown theo job.
Response:
[
{ "job_slug": "my-app", "cost_usd": 8.50, "calls": 25 },
{ "job_slug": "another-app", "cost_usd": 4.00, "calls": 17 }
]Daily cost aggregation.
Parameters:
| In | Name | Type | Default | Description |
|---|---|---|---|---|
| Query | days |
int | 7 |
Số ngày (1-30) |
Response:
[
{ "date": "2025-01-15", "cost_usd": 1.23, "calls": 42 }
]Dashboard KPI summary.
Lấy tất cả system settings.
Alias cho GET /api/settings.
Cập nhật system settings.
Alias cho POST /api/settings (partial update semantics).
System status info.
Response:
{
"status": "ok",
"version": "1.0.0",
"queue_backend": "thread",
"db_path": "/path/to/dashboard/data/app.db",
"db_exists": true,
"generated_apps_dir": "/path/to/generated_apps"
}Response:
{
"total_projects": 5,
"status_breakdown": { "discovery": 2, "development": 2, "production": 1, "blocked": 0 },
"success_rate": 85.0,
"total_cost": 12.50,
"active_models": 3,
"active_providers": 2
}Tất cả errors trả về JSON:
{
"detail": "Mô tả lỗi"
}HTTP status codes:
200— Success201— Created202— Accepted (async job)400— Bad request401— Unauthorized404— Not found409— Conflict500— Internal server error503— Service unavailable