Skip to content

Engine Database Concept ​

This document details the database persistence architecture of the Niksphere Engine, explaining how relational data storage and storage drivers operate under the hood.

1. Dual-Driver Storage Architecture ​

The Niksphere Engine incorporates a flexible dual-driver storage abstraction supporting two distinct relational backends:

Rendering diagram...

PostgreSQL (Enterprise & Cloud Production) ​

  • Architecture: Client-server relational database.
  • Use Case: Production environments, multi-tenant cloud deployments, high-concurrency enterprise workloads.
  • Features: Connection pooling, SSL/TLS transport security, online backups, horizontal read scaling.

Embedded SQLite (Zero-Config & Edge) ​

  • Architecture: In-process, serverless CGO-free file database engine.
  • Use Case: Local developer workstations, edge devices, single-tenant installations, testing environments.
  • Features: Zero external installation, single-file storage (niksphere.db by default), zero network latency.

File Location ​

By default (db_name: niksphere, no db_url set), the Engine resolves the SQLite file against the OS-standard State directory described in the Standard Directories Concept — e.g. %LOCALAPPDATA%\Niksphere\Engine\niksphere.db on Windows — rather than the process' working directory. This keeps the database in a stable, backed-up location regardless of where the Engine binary or service is started from.

This default only applies when db_name is a bare file name with no directory component. Setting db_name to a relative or absolute path (e.g. ./data/niksphere or /var/lib/niksphere/niksphere), or providing an explicit db_url, overrides this and is used exactly as given.

2. Storage Backend Decision Matrix ​

CriteriaPostgreSQLEmbedded SQLite
Target EnvironmentSelf-Hosted Enterprise / Niksphere Cloud (Fully Managed)Local Dev / Edge / Testing
Concurrent Write PerformanceHigh (Row-level locking)Moderate (WAL mode / file locking)
External Setup NeededYes (DB Server / Container)No (Built-in file engine)
Backup Mechanismpg_dump / Point-in-time recoverySingle file copy (.db)
Network OverheadLow (TCP/IP socket)Zero (In-process memory/disk)

Release v1.0.0-build.67-channel.insider