1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use clap::Parser;
use std::path::PathBuf;
/// Server configuration parsed from command line arguments and environment variables
#[derive(Parser, Debug)]
#[command(name = "ceres-server")]
#[command(author, version, about = "REST API server for Ceres semantic search")]
pub struct ServerConfig {
/// PostgreSQL database connection URL
#[arg(long, env = "DATABASE_URL")]
pub database_url: String,
/// Embedding provider to use: gemini (default) or openai
#[arg(long, env = "EMBEDDING_PROVIDER", default_value = "gemini")]
pub embedding_provider: String,
/// Google Gemini API key (required when embedding_provider=gemini)
#[arg(long, env = "GEMINI_API_KEY")]
pub gemini_api_key: Option<String>,
/// OpenAI API key (required when embedding_provider=openai)
#[arg(long, env = "OPENAI_API_KEY")]
pub openai_api_key: Option<String>,
/// Embedding model name (provider-specific, uses default if not set)
#[arg(long, env = "EMBEDDING_MODEL")]
pub embedding_model: Option<String>,
/// Server port to listen on
#[arg(short, long, env = "PORT", default_value = "3000")]
pub port: u16,
/// Server host to bind to
#[arg(long, env = "HOST", default_value = "0.0.0.0")]
pub host: String,
/// Path to portals.toml configuration file
#[arg(long, env = "PORTALS_CONFIG")]
pub portals_config: Option<PathBuf>,
/// Allowed CORS origins (comma-separated). Use "*" for any origin (dev only).
/// Example: "<https://example.com>,<https://app.example.com>"
#[arg(long, env = "CORS_ALLOWED_ORIGINS", default_value = "*")]
pub cors_origins: String,
/// Rate limit: maximum requests per second per IP
#[arg(long, env = "RATE_LIMIT_RPS", default_value = "10")]
pub rate_limit_rps: u32,
/// Rate limit: burst size (max requests allowed in a burst)
#[arg(long, env = "RATE_LIMIT_BURST", default_value = "30")]
pub rate_limit_burst: u32,
/// Maximum number of database connections in the pool
#[arg(long, env = "DB_MAX_CONNECTIONS", default_value = "10")]
pub max_connections: u32,
/// Admin API key for protecting write endpoints.
/// If unset, admin endpoints return 403 Forbidden.
#[arg(long, env = "CERES_ADMIN_TOKEN")]
pub admin_token: Option<String>,
}