burncloud-database-client
High-level database client with migrations, connection pooling, and specialized AI model management repositories for BurnCloud.
Overview
burncloud-database-client is the complete database solution for BurnCloud AI management systems. It provides a high-level, batteries-included approach to database operations with specialized repositories for AI model management, monitoring, and system administration.
Features
- 🤖 AI Model Management: Specialized repositories for managing AI models, deployments, and configurations
- 📊 Monitoring & Metrics: Built-in support for system and model performance tracking
- 🔒 Security & Access Control: User management, API keys, and firewall rule management
- 🔄 Database Migrations: Automatic schema management and versioning
- 🏊 Connection Pooling: Efficient connection management for high-performance applications
- 🎯 Repository Pattern: Type-safe, high-level data access layer
- 📈 Metrics Collection: Comprehensive monitoring and logging capabilities
- ⚙️ Configuration Management: Backup, restore, and configuration management tools
Quick Start
Installation
[]
= "0.1"
Basic Usage
use *;
async
Core Components
BurnCloudDatabase Manager
The central hub that provides access to all repositories and management functions:
let db = new
.with_postgres
.build_and_initialize
.await?;
// Access specialized repositories
db.ai_models // AI model management
db.deployments // Model deployments
db.system_metrics // System monitoring
db.model_metrics // Model performance
db.request_logs // API request logging
db.user_settings // User preferences
db.security_config // Security management
AI Model Management
// Search for models
let chat_models = db.ai_models.find_by_type.await?;
// Find by status
let available = db.ai_models.find_by_status.await?;
// Text search
let search_results = db.ai_models.search.await?;
Deployment Management
// Get running deployments
let running = db.deployments.get_running_deployments.await?;
// Find deployments by model
let model_deployments = db.deployments.find_by_model_id.await?;
// Check port availability
let port_in_use = db.deployments.find_by_port.await?;
Monitoring & Metrics
// Record system metrics
let metrics = SystemMetrics ;
db.system_metrics.base.create.await?;
// Get latest metrics
let latest = db.system_metrics.get_latest.await?;
// Query time range
let start = now - hours;
let end = now;
let recent = db.system_metrics.find_by_time_range.await?;
Database Migrations
Automatic schema management with versioned migrations:
// Migrations run automatically on initialization
db.initialize.await?;
// Manual migration management
let status = db.migration_manager.get_migration_status.await?;
db.migration_manager.rollback_migration.await?;
Configuration Management
// Backup configuration
let backup = db.backup_config.await?;
// Restore from backup
db.restore_config.await?;
// Cleanup old data
let stats = db.cleanup_old_data.await?; // Keep 30 days
println!;
Database Support
All major databases are supported through feature flags:
[]
= { = "0.1", = ["postgres"] } # Default
= { = "0.1", = ["mysql"] }
= { = "0.1", = ["sqlite"] }
= { = "0.1", = ["mongodb"] }
= { = "0.1", = ["all"] } # All databases
Examples
See the examples directory for complete usage examples:
- Basic Usage - Complete example with all features
- Model Management - AI model operations
- Monitoring - Metrics and logging
- Migrations - Database schema management
Performance
- Connection Pooling: Efficient resource management with configurable pool sizes
- Prepared Statements: All queries use prepared statements for security and performance
- Batch Operations: Support for bulk inserts and updates
- Indexing: Optimized database schemas with comprehensive indexing strategies
- Cleanup: Automatic cleanup of old data to maintain performance
Security
- SQL Injection Protection: All queries use parameterized statements
- Access Control: Role-based permissions and API key management
- Audit Logging: Comprehensive logging of all database operations
- Encryption: Support for encrypted connections to all database backends
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.