mod commands;
mod db;
mod models;

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

fn main() {
    let migrations = db::get_migrations();

    tauri::Builder::default()
        .plugin(tauri_plugin_shell::init())
        .plugin(tauri_plugin_process::init())
        .plugin(tauri_plugin_http::init())
        .plugin(tauri_plugin_dialog::init())
        .plugin(
            tauri_plugin_sql::Builder::default()
                .add_migrations("sqlite:flashcards.db", migrations)
                .build(),
        )
        .invoke_handler(tauri::generate_handler![
            greet,
            commands::start_chat,
            commands::check_model_exists,
            commands::download_model,
            commands::check_vision_model_exists,
            commands::download_vision_model,
            commands::analyze_image,
            commands::check_whisper_dependencies,
            commands::check_whisper_model_exists,
            commands::download_whisper_model,
            commands::transcribe_media
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
