systemprompt-api 0.2.0

HTTP API server and gateway for systemprompt.io OS
Documentation
use anyhow::Result;
use axum::Router;
use axum::routing::post;
use std::sync::Arc;
use systemprompt_analytics::EngagementRepository;
use systemprompt_content::ContentRepository;
use systemprompt_runtime::AppContext;

mod handlers;

pub use handlers::{BatchResponse, EngagementBatchInput, EngagementState};

pub fn router(ctx: &AppContext) -> Result<Router> {
    let state = EngagementState {
        repo: Arc::new(EngagementRepository::new(ctx.db_pool())?),
        content_repo: Arc::new(ContentRepository::new(ctx.db_pool())?),
        content_routing: ctx.content_routing(),
    };

    Ok(Router::new()
        .route("/", post(handlers::record_engagement))
        .route("/batch", post(handlers::record_engagement_batch))
        .with_state(state))
}