Skip to main content

cortiq_server/
lib.rs

1//! Cortiq Server — OpenAI-compatible API + web management dashboard.
2
3pub mod api;
4pub mod dashboard;
5pub mod openai;
6pub mod streaming;
7
8use axum::Router;
9use cortiq_engine::{CortiqRuntime, Pipeline};
10use std::sync::Arc;
11use tokio::sync::Mutex;
12use tower_http::cors::CorsLayer;
13
14/// Shared application state: runtime (masks, metrics) + the inference
15/// pipeline behind a Mutex (single-sequence decode; requests queue).
16pub struct AppState {
17    pub runtime: CortiqRuntime,
18    pub pipeline: Mutex<Pipeline>,
19}
20
21/// Build the full router with all endpoints.
22pub fn build_router(state: Arc<AppState>) -> Router {
23    Router::new()
24        .merge(openai::routes())
25        .merge(api::routes())
26        .merge(dashboard::routes())
27        .layer(CorsLayer::permissive())
28        .with_state(state)
29}