attuned-http

Crates.ioattuned-http
lib.rsattuned-http
version1.0.1
created_at2025-12-18 17:39:58.121082+00
updated_at2025-12-18 19:42:27.485449+00
descriptionHTTP reference server for Attuned
homepage
repositoryhttps://github.com/JtPerez-Acle/Attuned
max_upload_size
id1992984
size91,464
jt.. (JtPerez-Acle)

documentation

README

attuned-http

HTTP reference server for Attuned.

Overview

Production-ready HTTP server built with Axum providing:

  • RESTful API for state management
  • Authentication middleware
  • Rate limiting
  • OpenTelemetry tracing
  • Prometheus metrics

Quick Start

use attuned_http::{Server, ServerConfig, AuthConfig};
use attuned_store::MemoryStore;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ServerConfig {
        host: "127.0.0.1".to_string(),
        port: 8080,
        auth: AuthConfig::None,
        ..Default::default()
    };

    let store = Arc::new(MemoryStore::new());
    let server = Server::new(config, store);
    server.run().await?;

    Ok(())
}

API Endpoints

Method Path Description
POST /v1/state Upsert state (patch semantics)
GET /v1/state/{user_id} Get latest state
GET /v1/context/{user_id} Get translated PromptContext
DELETE /v1/state/{user_id} Delete state (GDPR)
POST /v1/translate Translate arbitrary state
GET /health Health check
GET /ready Readiness check
GET /metrics Prometheus metrics

Example Requests

# Set user state
curl -X POST http://localhost:8080/v1/state \
  -H "Content-Type: application/json" \
  -d '{"user_id": "user_123", "axes": {"cognitive_load": 0.8}}'

# Get context for LLM
curl http://localhost:8080/v1/context/user_123

Authentication

// API Key auth
AuthConfig::ApiKey { key: "secret".to_string() }

// Bearer token
AuthConfig::Bearer { secret: "jwt-secret".to_string() }

// No auth (development only)
AuthConfig::None

License

Apache-2.0

Commit count: 0

cargo fmt