Skip to content

Core Components

OstrichDB is built with a modular architecture where each component has specific responsibilities. This document details each core component and how they work together.

The engine is the heart of OstrichDB, containing the core database logic and data processing functionality.

  • Data processing: Core algorithms for data manipulation
  • Query execution: Processing search and filter operations
  • Transaction management: Ensuring data consistency
  • Memory management: Efficient allocation and cleanup
  • Database initialization and startup
  • Core data operation handlers
  • Memory pool management
  • Query processing engine

The HTTP server component provides the REST API interface and handles all client communications.

  • HTTP request handling: Processing incoming API requests
  • Response formatting: Converting internal data to JSON responses
  • Routing: Mapping URLs to appropriate handlers
  • Middleware: CORS, authentication, and logging
  • Error handling: Converting internal errors to HTTP responses
  • RESTful API with complete CRUD operations
  • CORS support for web applications
  • Request/response logging
  • Health check endpoints
  • Graceful shutdown handling
Client Request → Router → Authentication → Handler → Engine → Response

The data layer manages the hierarchical data structures and file operations for all data types.

  • Collection lifecycle: Create, read, update, delete operations
  • Metadata management: Collection properties and configuration
  • Encryption integration: Seamless encrypt/decrypt operations
  • Cluster organization: Grouping and managing record clusters
  • Query optimization: Efficient cluster-level searches
  • Storage management: File system integration
  • Record operations: CRUD operations for individual records
  • Type validation: Ensuring data type integrity
  • Indexing: Fast record lookup and retrieval
data/
├── projects/
│ └── {project_name}/
│ └── collections/
│ └── {collection_name}/
│ ├── metadata.json
│ └── clusters/
│ └── {cluster_name}/
│ ├── metadata.json
│ └── records/
│ └── {record_files}

The security component handles all cryptographic operations, authentication, and access control.

  • Master key management: User-specific encryption keys
  • AES encryption: Industry-standard encryption algorithms
  • Key derivation: Secure key generation from user credentials
  • Automatic operations: Transparent encrypt/decrypt cycles
  • JWT tokens: Stateless authentication system
  • Token validation: Request-level authentication
  • User management: User registration and login
  • Session handling: Token refresh and expiration
  • Project ownership: User-based project isolation
  • Permission checking: Request-level authorization
  • Multi-tenancy: Complete user data isolation

The configuration system manages all runtime settings and environment-specific configurations.

  • development.json: Development environment settings
  • production.json: Production environment settings
{
"server": {
"port": 8042,
"host": "localhost",
"max_connections": 1000,
"timeout": 30
}
}
{
"database": {
"data_path": "./data",
"max_file_size": "100MB",
"backup_enabled": true,
"backup_interval": "24h"
}
}
{
"security": {
"jwt_secret": "your-secret-key",
"jwt_expiration": "1h",
"encryption_enabled": true,
"rate_limiting": true
}
}
  • Runtime updates: Configuration changes without restart
  • Environment detection: Automatic environment selection
  • Validation: Configuration validation on startup

The projects component manages the top-level organizational structure and user isolation.

  • Creation: New project initialization
  • Management: Project metadata and configuration
  • Access control: User-based project ownership
  • Cleanup: Project deletion and resource management
  • Namespace separation: Each user has isolated project spaces
  • Access verification: All operations verify project ownership
  • Resource limits: Per-user resource quotas and limits

The library component contains shared functionality, common types, and utility functions used across all components.

  • Data types: Definitions for all supported data types
  • Error types: Standardized error handling structures
  • Response types: Consistent API response formats
  • String operations: Common string manipulation functions
  • Date/time handling: Date parsing and formatting
  • JSON processing: Serialization and deserialization
  • File operations: Safe file system interactions
  • Logging: Centralized logging system
  • Validation: Data validation functions
  • Conversion: Type conversion utilities
  • Constants: System-wide constants and defaults
  1. Server receives HTTP request
  2. Configuration provides runtime settings
  3. Security validates authentication and authorization
  4. Engine processes the request
  5. Data Layer performs storage operations
  6. Projects manages user isolation
  7. Library provides shared utilities throughout
  8. Server returns formatted response
Client → Server → Security → Engine → Data Layer → Storage
↓ ↑
Configuration Library
  1. Create component directory under appropriate namespace
  2. Implement core functionality with proper error handling
  3. Add configuration options if needed
  4. Integrate with security layer for access control
  5. Add comprehensive logging
  6. Write tests for all functionality
  • Use well-defined interfaces between components
  • Implement proper error propagation
  • Use library utilities for common operations
  • Follow established patterns for data flow

Learn more about specific aspects: