Skip to main content

cai_web/
lib.rs

1//! CAI Web - Local web interface
2//!
3//! Provides a local web server with REST API and dashboard for exploring
4//! AI coding history.
5//!
6//! # Features
7//!
8//! - REST API for queries
9//! - Interactive HTML/JS dashboard
10//! - WebSocket for real-time updates
11//! - Static file serving
12//!
13//! # Example
14//!
15//! ```rust,no_run
16//! use cai_web::run;
17//!
18//! // Create a storage implementation and pass to run()
19//! // let storage = ...;
20//! // run(storage, 3000).await?;
21//! ```
22
23#![warn(missing_docs, unused_crate_dependencies)]
24
25pub use cai_core::Result;
26
27mod api;
28mod handlers;
29mod server;
30
31pub use server::run;
32
33use cai_storage::Storage;
34
35/// Web server configuration
36#[derive(Debug, Clone)]
37pub struct Config {
38    /// Port to listen on
39    pub port: u16,
40    /// Host to bind to
41    pub host: String,
42}
43
44impl Default for Config {
45    fn default() -> Self {
46        Self {
47            port: 3000,
48            host: "127.0.0.1".to_string(),
49        }
50    }
51}
52
53/// Shared application state
54#[derive(Clone)]
55pub struct AppState {
56    /// Storage backend
57    pub storage: std::sync::Arc<dyn Storage + Send + Sync>,
58}