mod analysis;
mod companies;
mod configs;
mod market_data;
mod system;
mod session_data;
mod provider_cache;

use crate::AppState;
use axum::{
    routing::{get, post},
    Router,
};

pub fn create_router(_state: AppState) -> Router<AppState> {
    let router: Router<AppState> = Router::new()
        // System
        .route("/health", get(system::get_health))
        // Configs
        .route(
            "/configs/llm_providers",
            get(configs::get_llm_providers_config).put(configs::update_llm_providers_config),
        )
        .route(
            "/configs/analysis_template_sets",
            get(configs::get_analysis_template_sets).put(configs::update_analysis_template_sets),
        )
        .route(
            "/configs/data_sources",
            get(configs::get_data_sources_config).put(configs::update_data_sources_config),
        )
        // Companies
        .route("/companies/{symbol}", get(companies::get_company_by_symbol))
        .route(
            "/companies/{symbol}/providers/{provider_id}/status",
            get(companies::get_provider_status).put(companies::update_provider_status),
        )
        // Market Data
        .route(
            "/market-data/financial-statements/{symbol}",
            get(market_data::get_financials_by_symbol),
        )
        // Analysis Results
        .route(
            "/analysis-results",
            post(analysis::create_analysis_result).get(analysis::get_analysis_results),
        )
        .route(
            "/analysis-results/{id}",
            get(analysis::get_analysis_result_by_id),
        )
        // Session Data
        .route(
            "/session-data",
            post(session_data::insert_session_data),
        )
        .route(
            "/session-data/{request_id}",
            get(session_data::get_session_data).delete(session_data::delete_session_data),
        )
        // Provider Cache
        .route(
            "/provider-cache",
            get(provider_cache::get_cache).post(provider_cache::set_cache),
        );

    router
}
