libsqlite is a self-hosted control plane for SQLite and libsql databases. It is intended for local servers, VPS deployments and Coolify-based hosting.
The design follows clear separation between domain logic, application orchestration, infrastructure and presentation.
flowchart LR
U[User] --> UI[Admin UI]
UI --> API[Backend API]
API --> CP[Control Plane]
API --> SP[Secret Plane]
API --> DP[Data Plane]
DP --> LDB[SQLite files]
DP --> RDB[libsql endpoints]
Stores metadata about:
- users
- roles and permissions
- projects
- databases
- sessions
- audit logs
- migration history
Stores or accesses the actual database workload:
- managed SQLite files
- imported SQLite files
- mounted SQLite files discovered on disk
- remote libsql databases
Stores sensitive values encrypted with MASTER_KEY:
- database tokens
- connection credentials
- future secret material if a vault integration is added
Pure business rules and entities.
Examples:
UserProjectDatabaseRolePermissionSessionAuditLogDatabaseMigration
Use cases and orchestration.
Examples:
- authentication workflows
- project creation
- database provisioning
- SQLite discovery and adoption
- migration application
- query execution
Concrete adapters and integrations.
Examples:
- TypeORM data source
- SQLite file access (with robust
DatabaseErrorclassification and integrity checks) - libsql client (with remote fallback handling)
- AES-GCM encryption
- token hashing
- storage layout service
HTTP controllers, request guards and plugins.
Examples:
- auth routes
- project routes
- database routes
- migration routes
- discovery routes
- health routes
- User creates a project.
- User requests a new SQLite database.
- The backend creates metadata in the control plane.
- The backend creates a file in the structured storage tree.
- The database is marked active and returned to the user.
- User provides a server-side
.dbpath. - The backend copies the file into managed storage.
- Metadata is saved and the database becomes manageable.
- User configures a discovery directory.
- The backend scans for
.dbfiles. - Each file is registered in the control plane.
- Optionally, the file is adopted into managed storage.
- User registers URL and token.
- The backend encrypts the token.
- The backend verifies connectivity.
- Queries and schema introspection use the registered connection.
Managed SQLite files are written using a structured hierarchy:
data/sqlite/projects/<projectId>/databases/<databaseId>.db
This keeps the filesystem predictable and easy to back up.
- the control plane is independent from the data plane
- database records are isolated by project and database identifier
- secret handling is centralized
- storage paths are deterministic
- the backend can be deployed the same way on local machines, VPS or Coolify
To prevent data corruption and application crashes:
- Error Classification: All database errors are wrapped in a generic
DatabaseErrorstructure to safely distinguishSQLITE_CORRUPT,SQLITE_BUSY, constraints, and syntax errors, bubbling up meaningful HTTP codes. - Migration Atomicity: Local SQLite migrations are enclosed in
BEGIN...COMMIT/ROLLBACKtransactions to ensure partial migrations do not leave databases in a broken state. - Integrity Checks:
PRAGMA integrity_checkis automatically validated when a database connection is tested, immediately alerting if underlying disk files are corrupt.