Why Did I Build This?
"Interfacing frontend applications or lightweight network clients directly with SQLite typically requires heavy native driver bindings or complex ORMs. I engineered this standalone C++ daemon to act as a highly performant intermediary. It exposes the underlying SQLite engine over standard HTTP, allowing clients to dispatch raw SQL strings and receive clean JSON data structures without managing native database state."
Architecture & Decisions
The core HTTP multiplexing is handled via the header-only `cpp-httplib` library. To prevent address-in-use exceptions during deployment, the initialization routine hooks directly into the Windows Socket API (`Winsock2`), sequentially probing network interfaces via `bind()` to lock an available TCP port. The database engine heavily leverages the SQLite3 C API. To handle arbitrary SQL queries without predefined data models, the execution loop dynamically queries the result schema at runtime using `sqlite3_column_count` and `sqlite3_column_name`, mapping the raw C-string pointers directly into an `nlohmann/json` matrix before returning the HTTP payload.
Key Features
- 01.Dynamic, schema-agnostic execution engine mapping arbitrary SQL result sets directly to JSON matrices
- 02.Native OS-level TCP port probing and allocation utilizing the Windows Socket API (Winsock2)
- 03.System-level table reflection (`sqlite_master`) exposed via dedicated HTTP endpoints
- 04.Thread-safe request multiplexing using `cpp-httplib` directly coupled to the SQLite cursor iteration