The Entry Layer contains binary entry points that wire all layers together. These crates produce the executables users interact with.

Characteristics

  • Binary targets - Produce executable files
  • Wire dependencies - Connect all layers
  • Handle signals - Graceful shutdown
  • No business logic - Delegates to lower layers

Crates

Crate Purpose
systemprompt-api HTTP server built on Axum
systemprompt-cli Command-line interface

Dependency Rules

Entry layer crates:

  • Can depend on all lower layers
  • Are the top of the dependency tree
  • Should minimize their own logic

API Entry Point

The API crate creates an HTTP server:

// systemprompt-api/src/main.rs

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize logging
    systemprompt_logging::init();

    // Load configuration
    let config = Config::load()?;

    // Create application context
    let ctx = AppContext::new(config).await?;

    // Build router
    let app = Router::new()
        // Health checks
        .route("/health", get(health_check))
        // Discovery endpoints
        .route("/.well-known/agent-card.json", get(agent_card))
        .route("/.well-known/agent-cards", get(agent_cards))
        // API routes
        .nest("/api/v1", api_routes(&ctx))
        // Extension routes
        .merge(ctx.extensions.routes())
        // Middleware
        .layer(middleware_stack(&ctx));

    // Start server
    let listener = TcpListener::bind(&ctx.config.api.bind_addr).await?;
    axum::serve(listener, app)
        .with_graceful_shutdown(shutdown_signal())
        .await?;

    Ok(())
}

CLI Entry Point

The CLI crate provides command-line interface:

// systemprompt-cli/src/main.rs

#[tokio::main]
async fn main() -> Result<()> {
    let cli = Cli::parse();

    match cli.command {
        Commands::Cloud(cmd) => cloud::execute(cmd).await,
        Commands::Infra(cmd) => infra::execute(cmd).await,
        Commands::Admin(cmd) => admin::execute(cmd).await,
        Commands::Core(cmd) => core::execute(cmd).await,
        // ...
    }
}

#[derive(Parser)]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    /// Cloud operations
    Cloud(CloudCommand),
    /// Infrastructure management
    Infra(InfraCommand),
    /// Admin operations
    Admin(AdminCommand),
    /// Core operations
    Core(CoreCommand),
}

Layer Diagram

┌────────────────────────────────────────────────────────────┐
│                      ENTRY LAYER                           │
│                                                            │
│        ┌─────────────┐        ┌─────────────┐             │
│        │     api     │        │     cli     │             │
│        │  (binary)   │        │  (binary)   │             │
│        └──────┬──────┘        └──────┬──────┘             │
│               │                      │                     │
│               └──────────┬───────────┘                     │
│                          ↓                                 │
│              Depends on ALL lower layers                   │
└────────────────────────────────────────────────────────────┘