Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

API Design

The kairos-api crate exposes all core functionality as a REST API, with WebSocket support for streaming LLM responses.

Server

Frameworkaxum (tokio-based, tower middleware)
Default port3001
TransportHTTP/1.1 + WebSocket
SerializationJSON (serde)

Response Envelope

All endpoints return a consistent envelope:

{
  "status": "success",
  "data": { ... },
  "message": null,
  "meta": { "total": 42, "page": 1, "page_size": 20 }
}

Error responses:

{
  "status": "error",
  "data": null,
  "message": "Job not found",
  "code": "JOB_NOT_FOUND"
}

Endpoints

Jobs

MethodPathDescription
POST/api/jobs/searchStart a search across platforms
GET/api/jobsList jobs (paginated, filterable)
GET/api/jobs/:idGet job details
POST/api/jobs/:id/analyzeTrigger JD analysis
GET/api/jobs/:id/analysisGet analysis results
DELETE/api/jobs/:idRemove a job

Resumes

MethodPathDescription
POST/api/resumes/importImport a resume (LaTeX/Markdown)
GET/api/resumesList resumes
GET/api/resumes/:idGet resume details with sections
POST/api/resumes/:id/tailorTailor resume for a specific job
GET/api/resumes/:id/tailoredList tailored versions
GET/api/resumes/:id/tailored/:job_idGet tailored version + diff
POST/api/resumes/:id/tailored/:job_id/approveApprove tailored version
POST/api/resumes/:id/exportExport resume (PDF/LaTeX)

Applications

MethodPathDescription
POST/api/applicationsCreate an application record
GET/api/applicationsList applications (paginated)
GET/api/applications/:idGet application details
PATCH/api/applications/:idUpdate status/notes
GET/api/applications/statsDashboard statistics

Profile & Config

MethodPathDescription
GET/api/profileGet user profile
PUT/api/profileUpdate user profile
GET/api/configGet current config
PATCH/api/configUpdate config fields

Health

MethodPathDescription
GET/api/healthServer health check

WebSocket: LLM Streaming

Long-running LLM operations (analysis, tailoring) support WebSocket streaming:

WS /api/ws

Protocol:

// Client sends
{ "type": "analyze", "job_id": "uuid" }

// Server streams
{ "type": "progress", "stage": "extracting_requirements", "percent": 30 }
{ "type": "progress", "stage": "scoring_match", "percent": 70 }
{ "type": "complete", "data": { "score": 0.85, "analysis": { ... } } }

This allows all frontends (CLI, Web) to show real-time progress.

Authentication

For local use, the API runs on localhost with no auth required. For remote/shared deployments:

MethodUse Case
API Key (header: X-Kairos-Key)CLI scripts, simple setups
JWT (Bearer token)Web App, multi-user scenarios

Auth is implemented as tower middleware and can be toggled in config.toml:

[api]
bind = "127.0.0.1:3001"
auth = "none"           # "none", "api_key", "jwt"
api_key = ""            # or set KAIROS_API_KEY env var
jwt_secret = ""         # or set KAIROS_JWT_SECRET env var

Middleware Stack

Request
  → Logging (tower-http TraceLayer)
  → CORS (tower-http CorsLayer)
  → Auth (custom middleware)
  → Rate limiting (tower governor)
  → Handler
  → Response envelope wrapper

Error Mapping

API errors map domain errors to HTTP status codes:

Domain ErrorHTTP StatusCode
NotFound404*_NOT_FOUND
ValidationError400VALIDATION_ERROR
LlmError502LLM_ERROR
ScrapingError502SCRAPING_ERROR
Unauthorized401UNAUTHORIZED
RateLimited429RATE_LIMITED