refactor: refactor database connection with trible layer structure