···33//! The core runtime which different UI apps can leverage
44//! Generally the core will be run as daemon and interact with other sub components
5566-use anyhow::Result;
66+use anyhow::{Context, Result};
7788-use crate::core::{accounts::save_root_account_db, storage::db::Dbconn};
88+use crate::{
99+ core::{
1010+ accounts::save_root_account_db,
1111+ storage::db::{Dbconn, init_db},
1212+ },
1313+ utils::config::{ConfigProvider, DefaultProvider},
1414+};
9151016pub mod accounts;
1117pub mod chats;
···1420pub mod storage;
15211622// Entrypoint of the core
1717-pub fn init(db_conn: &Dbconn) -> Result<()> {
2323+pub fn init() -> Result<Dbconn> {
2424+ let config_provider = DefaultProvider;
2525+ config_provider
2626+ .get_or_create_config_dir()
2727+ .context("Failed in creating config folder")?;
2828+ config_provider
2929+ .get_or_create_data_dir()
3030+ .context("Failed to create data dir")?;
3131+ init_db()
3232+}
3333+3434+pub fn init_account(db_conn: &Dbconn) -> Result<()> {
1835 save_root_account_db(db_conn)
1936}