#include "csp/app_state.h" #include namespace csp { AppState& AppState::Instance() { static AppState inst; return inst; } void AppState::Init(const std::string& sqlite_path) { if (sqlite_path == ":memory:") { db_ = std::make_unique(db::SqliteDb::OpenMemory()); } else { db_ = std::make_unique(db::SqliteDb::OpenFile(sqlite_path)); } csp::db::ApplyMigrations(*db_); csp::db::SeedDemoData(*db_); } csp::db::SqliteDb& AppState::db() { if (!db_) throw std::runtime_error("AppState not initialized"); return *db_; } } // namespace csp