//! Server startup and initialization modules
//!
//! This module contains all the server initialization logic broken down into
//! focused, testable modules. Each module handles a specific aspect of server
//! startup and uses the existing Config and AppState structures.
//!
//! ## Module Organization
//!
//! - **`server`** - Environment setup, configuration loading, logging setup,
//!   server startup
//! - **`cache`** - Cache system initialization with persistent storage and
//!   prewarming
//! - **`auth`** - Authentication services and security component initialization
//! - **`database`** - Database connection setup and content services
//! - **`email`** - Email service initialization with multiple provider support
//! - **`router`** - Main application router with static file serving and
//!   dynamic routes
//! - **`api`** - API router creation with feature-gated service routes
//! - **`middleware`** - Middleware layer application (auth, metrics, security,
//!   etc.)
//!
//! ## Usage
//!
//! ```rust
//! use startup::*;
//!
//! // Initialize all components step by step
//! setup_environment().await?;
//! let config = load_and_validate_config().await?;
//! setup_logging_and_panic_handling(&config)?;
//! // ... continue with other initialization steps
//! ```

pub mod api;
pub mod auth;
pub mod cache;
pub mod database;
pub mod email;
pub mod handlers;
pub mod middleware;
#[cfg(feature = "nats-admin")]
pub mod nats;
pub mod router;
pub mod server;

// Re-export all public functions for convenience
pub use api::create_api_router;
#[cfg(feature = "auth")]
pub use auth::initialize_auth_services;
pub use auth::initialize_security_components;
pub use cache::initialize_cache_system;
#[cfg(feature = "content-db")]
pub use database::initialize_content_services;
#[cfg(any(feature = "auth", feature = "content-db", feature = "post-engagement"))]
pub use database::initialize_database;
#[cfg(feature = "email")]
pub use email::initialize_email_service;
#[cfg(feature = "metrics")]
pub use email::initialize_metrics_service;
pub use middleware::apply_middleware_layers;
pub use router::create_main_router;
// Re-export startup functions from server module
pub use server::{
    initialize_navigation_tracking, load_and_validate_config, setup_environment,
    setup_logging_and_panic_handling, setup_site_options, start_server,
};
