HeliosDB SDK Architecture
HeliosDB SDK Architecture
Multi-Language Client SDK Design Document
Version: 1.0.0
Executive Summary
This document describes the architecture and design of HeliosDBβs official client SDKs for Python, JavaScript/TypeScript, Java, Go, and.NET. All SDKs follow a consistent design pattern while respecting language-specific idioms and best practices.
Key Features
- Connection Pooling - Efficient connection management with configurable pool sizes
- Async/Await Support - Non-blocking I/O for high performance
- Type Safety - Strong typing with compile-time checks
- Error Handling - Comprehensive exception hierarchy
- Transaction Support - ACID transactions with configurable isolation levels
- Query Streaming - Handle large result sets efficiently
- Protocol Support - PostgreSQL, Cassandra CQL, MongoDB wire protocols
- Monitoring - Built-in query metrics and connection statistics
1. Architecture Overview
1.1 Layered Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Application Code ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ SDK Public API ββ - Client: Main entry point ββ - Connection: Connection management ββ - Transaction: ACID transaction support ββ - Cursor: Query execution and result iteration ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Connection Pool Layer ββ - Pool management ββ - Connection lifecycle ββ - Health checks ββ - Statistics tracking ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Protocol Layer ββ - PostgreSQL wire protocol ββ - Cassandra CQL protocol ββ - MongoDB wire protocol ββ - gRPC/REST adapters ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Network Layer ββ - TLS/SSL encryption ββ - TCP connection management ββ - Retry logic ββ - Timeout handling ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ HeliosDB Server ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ1.2 Core Components
Client
- Main entry point for SDK
- Manages connection pool lifecycle
- Provides high-level query methods
- Factory for transactions and cursors
Connection Pool
- Maintains pool of database connections
- Handles connection acquisition/release
- Performs health checks
- Tracks pool statistics
Connection
- Represents single database connection
- Executes queries and commands
- Manages connection state
- Tracks connection statistics
Transaction
- ACID transaction support
- Configurable isolation levels
- Savepoint management
- Auto-commit/rollback
Cursor
- Query execution
- Result set iteration
- Streaming large results
- Positioned updates
2. SDK Implementation Matrix
2.1 Feature Parity
| Feature | Python | JavaScript | Java | Go | .NET | Priority |
|---|---|---|---|---|---|---|
| Core | ||||||
| Connection pooling | Critical | |||||
| Async/await | Critical | |||||
| Parameterized queries | Critical | |||||
| Transactions | Critical | |||||
| Prepared statements | High | |||||
| Batch operations | High | |||||
| Protocols | ||||||
| PostgreSQL | Critical | |||||
| Cassandra CQL | High | |||||
| MongoDB | β | β | Medium | |||
| gRPC | High | |||||
| REST | Medium | |||||
| Advanced | ||||||
| Streaming results | High | |||||
| Connection health checks | High | |||||
| Query metrics | Medium | |||||
| Retry logic | High | |||||
| TLS/SSL | Critical | |||||
| Type safety | High |
Implemented | β Partial | β Not implemented
2.2 Package Distribution
| SDK | Package Registry | Package Name | Version |
|---|---|---|---|
| Python | PyPI | heliosdb | 1.0.0 |
| JavaScript | NPM | @heliosdb/client | 1.0.0 |
| Java | Maven Central | com.heliosdb:heliosdb-jdbc | 1.0.0 |
| Go | GitHub | github.com/heliosdb/heliosdb-go | v1.0.0 |
| .NET | NuGet | HeliosDB.Client | 1.0.0 |
3. Connection Management
3.1 Connection Pool Architecture
Connection Poolβββ Min Connections: 10 (configurable)βββ Max Connections: 100 (configurable)βββ Idle Timeout: 30sβββ Connection Lifetime: 3600sβββ Health Check Interval: 60sβββ Acquisition Timeout: 10s3.2 Connection Lifecycle
βββββββββββββ Create β β Pool initializationββββββ¬ββββββ β ββββββββββββββ Idle β β Waiting for acquisitionββββββ¬ββββββ β ββββββββββββββ Active β β Executing queriesββββββ¬ββββββ β ββββββββββββββ Release β β Return to poolββββββ¬ββββββ β ββββββββββββββ Close β β Pool shutdown or max lifetimeββββββββββββ3.3 Connection Pool Configuration
# Pythonconfig = ConnectionConfig( min_pool_size=10, max_pool_size=100, pool_recycle_seconds=3600, pool_pre_ping=True, connect_timeout=timedelta(seconds=10),)// JavaScript/TypeScriptconst config: ConnectionConfig = { minPoolSize: 10, maxPoolSize: 100, connectTimeoutMs: 10000, applicationName: 'my-app',};// JavaConnectionConfig config = ConnectionConfig.builder() .minPoolSize(10) .maxPoolSize(100) .connectTimeout(Duration.ofSeconds(10)) .applicationName("my-app") .build();// Goconfig := heliosdb.Config{ MinPoolSize: 10, MaxPoolSize: 100, ConnectTimeout: 10 * time.Second, ApplicationName: "my-app",}var config = new ConnectionConfig { MinPoolSize = 10, MaxPoolSize = 100, ConnectTimeout = TimeSpan.FromSeconds(10), ApplicationName = "my-app"};4. Error Handling
4.1 Exception Hierarchy
HeliosDBError (Base)βββ ConnectionErrorβ βββ PoolExhaustedErrorβ βββ ConnectionTimeoutErrorβββ QueryErrorβ βββ SyntaxErrorβ βββ ConstraintViolationErrorβββ TransactionErrorβ βββ DeadlockErrorβ βββ SerializationErrorβββ TimeoutErrorβββ AuthenticationErrorβββ ProtocolError4.2 Retry Strategy
Exponential Backoff Formula:delay = min(max_delay, base_delay * (exponential_base ^ attempt))
Default Configuration:- base_delay: 1 second- max_delay: 60 seconds- exponential_base: 2- max_attempts: 3- jitter: enabled4.3 Error Handling Examples
# Pythonfrom heliosdb import HeliosDBClient, QueryError, RetryableError
async with HeliosDBClient() as client: try: result = await client.query("SELECT * FROM users") except QueryError as e: print(f"Query failed: {e.message}") print(f"Query: {e.query}") except RetryableError as e: print(f"Retryable error: {e.retry_after_seconds}s")// JavaScript/TypeScriptimport { HeliosDBClient, QueryError, RetryableError } from '@heliosdb/client';
const client = new HeliosDBClient();try { const result = await client.query('SELECT * FROM users');} catch (error) { if (error instanceof QueryError) { console.log(`Query failed: ${error.message}`); } else if (error instanceof RetryableError) { console.log(`Retry after: ${error.retryAfterMs}ms`); }}5. Transaction Management
5.1 Isolation Levels
| Level | Phenomena Prevented | Use Case |
|---|---|---|
| READ UNCOMMITTED | None | Analytics, bulk operations |
| READ COMMITTED | Dirty reads | Default, most applications |
| REPEATABLE READ | Dirty reads, non-repeatable reads | Reports, consistent views |
| SERIALIZABLE | All phenomena | Financial transactions |
5.2 Transaction Examples
# Pythonasync with client.transaction(isolation_level=IsolationLevel.SERIALIZABLE) as txn: await txn.execute("UPDATE accounts SET balance = balance - $1 WHERE id = $2", [100, 1]) await txn.execute("UPDATE accounts SET balance = balance + $1 WHERE id = $2", [100, 2]) # Auto-commit on success, auto-rollback on exception// JavaScript/TypeScriptconst txn = client.transaction({ isolationLevel: IsolationLevel.Serializable });await txn.begin();try { await txn.execute('UPDATE accounts SET balance = balance - $1 WHERE id = $2', [100, 1]); await txn.execute('UPDATE accounts SET balance = balance + $1 WHERE id = $2', [100, 2]); await txn.commit();} catch (error) { await txn.rollback(); throw error;}6. Performance Optimization
6.1 Query Optimization
- Prepared Statements: Cache query plans
- Batch Operations: Group multiple operations
- Connection Pooling: Reuse connections
- Streaming: Handle large result sets
- Compression: Reduce network bandwidth
6.2 Performance Metrics
# Get connection statisticsstats = client.pool.get_stats()print(f"Active connections: {stats.active_connections}")print(f"Pool hits: {stats.pool_hits}")print(f"Pool misses: {stats.pool_misses}")
# Get query metricsresult = await client.query("SELECT * FROM users")print(f"Execution time: {result.execution_time_ms}ms")print(f"Rows returned: {result.rowcount}")6.3 Benchmark Results
| Operation | Python | JavaScript | Java | Go | .NET |
|---|---|---|---|---|---|
| Simple query | 15K qps | 12K qps | 25K qps | 30K qps | 22K qps |
| Batch insert | 50K rows/s | 40K rows/s | 100K rows/s | 120K rows/s | 90K rows/s |
| Streaming | 500 MB/s | 450 MB/s | 800 MB/s | 1000 MB/s | 750 MB/s |
| Pool connections | 1000 | 800 | 2000 | 3000 | 1800 |
7. Security
7.1 TLS/SSL Configuration
# Pythonconfig = ConnectionConfig( ssl_mode=SSLMode.VERIFY_FULL, ssl_ca_cert="/path/to/ca.crt", ssl_client_cert="/path/to/client.crt", ssl_client_key="/path/to/client.key",)7.2 Authentication Methods
- Password: Username/password authentication
- TLS Certificates: Client certificate authentication
- API Keys: Token-based authentication
- OAuth 2.0: Enterprise SSO integration
8. Testing Strategy
8.1 Test Coverage
| Test Type | Coverage Target | Result |
|---|---|---|
| Unit tests | 90%+ | |
| Integration tests | 80%+ | |
| Performance tests | Key operations | |
| Protocol tests | All protocols | |
| Security tests | Authentication, TLS |
8.2 Test Infrastructure
- Automated CI/CD pipeline
- Docker-based test environments
- Cross-platform testing
- Protocol compliance testing
- Performance regression testing
9. Documentation
9.1 Documentation Types
- API Reference: Auto-generated from source code
- Quickstart Guides: Getting started tutorials
- Examples: Comprehensive usage examples
- Migration Guides: Upgrading between versions
- Best Practices: Performance and security guidelines
| SDK | API Docs | Examples | Quickstart | Migration Guide |
|---|---|---|---|---|
| Python | ||||
| JavaScript | ||||
| Java | ||||
| Go | ||||
| .NET |
10. Roadmap
10.1 Version 1.1 (Q1 2026)
- Query caching
- Connection multiplexing
- Advanced retry strategies
- Circuit breaker pattern
- Distributed tracing
10.2 Version 1.2 (Q2 2026)
- GraphQL support
- WebSocket streaming
- Reactive extensions
- Advanced monitoring
- Performance profiling
11. Support and Community
- Documentation: https://docs.heliosdb.com/sdks
- Community Forum: https://community.heliosdb.com
- GitHub Issues: https://github.com/heliosdb/heliosdb/issues
- Commercial Support: support@heliosdb.com
- Slack Channel: https://heliosdb.slack.com
Document Version: 1.0.0