# Smartbotic Database A standalone key-value document database with gRPC API, designed for microservice architectures. ## Features - **Document Storage** - JSON document store with collections - **Health Check** - gRPC `HealthCheck()` RPC for service status verification - **Replication** - Multi-master replication via `StorageReplication` gRPC service - **Persistence** - WAL (Write-Ahead Log) + snapshots with LZ4 compression - **Encryption** - Field-level AES-256-GCM encryption for sensitive data - **Events** - Pub/sub event subscription for real-time updates - **File Storage** - Binary file management with streaming support - **Migrations** - Declarative JSON-based schema migrations ## Architecture ``` smartbotic-database/ ├── client/ # Client library (injectable into projects) ├── service/ # Database service (standalone deployable) ├── proto/ # gRPC protocol buffer definitions └── packaging/ # Docker build and systemd files ``` ## Building ### Standalone Build ```bash cmake -B build -G Ninja ninja -C build ``` ### As Embedded Submodule When used as a submodule, configure build options: ```cmake set(SMARTBOTIC_DB_BUILD_CLIENT ON) # Always need client set(SMARTBOTIC_DB_BUILD_SERVICE ON) # Optional: include service binary add_subdirectory(external/smartbotic-database) ``` ## Configuration ```json { "database": { "bind_address": "0.0.0.0", "rpc_port": 9004, "data_directory": "/var/lib/smartbotic/database", "migrations": { "enabled": true, "directory": "/etc/smartbotic/migrations", "auto_apply": true }, "persistence": { "wal_sync_interval_ms": 100, "snapshot_interval_sec": 3600 }, "encryption": { "enabled": true, "auto_generate_key": true }, "replication": { "enabled": false, "peers": [] } } } ``` ## Migrations Create JSON migration files in the migrations directory: ```json { "version": "001", "name": "create_users", "description": "Create users collection", "operations": [ { "type": "create_collection", "collection": "users", "options": {"encrypted": true} } ] } ``` Supported operations: - `create_collection` - Create collection if not exists - `drop_collection` - Drop collection (requires `confirm: true`) - `insert` - Insert document (fails if exists) - `insert_if_not_exists` - Insert only if ID doesn't exist - `upsert` - Insert or update document - `update` - Update existing document - `delete` - Delete document ## CMake Targets | Target | Description | |--------|-------------| | `smartbotic_db_proto` | Generated protobuf/gRPC code | | `smartbotic-db-client` | Client library | | `smartbotic-database` | Service executable | ## License Proprietary - Smartbotics AI