{"id":47261364,"url":"https://github.com/cobaltdb/cobaltdb","last_synced_at":"2026-04-01T17:15:53.543Z","repository":{"id":341278695,"uuid":"1169526204","full_name":"cobaltdb/cobaltdb","owner":"cobaltdb","description":"The Modern Embedded Database for Go","archived":false,"fork":false,"pushed_at":"2026-04-01T00:42:33.000Z","size":4504,"stargazers_count":25,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-01T02:41:14.076Z","etag":null,"topics":["database","go","sql"],"latest_commit_sha":null,"homepage":"http://cobaltdb.dev/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cobaltdb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-02-28T20:23:37.000Z","updated_at":"2026-04-01T00:42:08.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cobaltdb/cobaltdb","commit_stats":null,"previous_names":["cobaltdb/cobaltdb"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/cobaltdb/cobaltdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobaltdb%2Fcobaltdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobaltdb%2Fcobaltdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobaltdb%2Fcobaltdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobaltdb%2Fcobaltdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cobaltdb","download_url":"https://codeload.github.com/cobaltdb/cobaltdb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cobaltdb%2Fcobaltdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","go","sql"],"created_at":"2026-03-14T23:07:48.699Z","updated_at":"2026-04-01T17:15:53.536Z","avatar_url":"https://github.com/cobaltdb.png","language":"Go","readme":"# 🔷 CobaltDB\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Go-1.24+-00ADD8?style=for-the-badge\u0026logo=go\u0026logoColor=white\" alt=\"Go Version\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Version-0.3.1-blue?style=for-the-badge\" alt=\"Version\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-MIT-green?style=for-the-badge\" alt=\"License\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/CGO-Free-ff6b6b?style=for-the-badge\" alt=\"Zero CGO\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Coverage-92%25-brightgreen?style=for-the-badge\" alt=\"Test Coverage\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Production-Ready-success?style=for-the-badge\" alt=\"Production Ready\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003e⚡ The Modern SQL Database Engine — Embedded or Standalone Server\u003c/b\u003e\u003cbr\u003e\n  \u003ci\u003eMySQL Protocol · SQL + JSON · ACID · MVCC · Encryption · Replication · Pure Go\u003c/i\u003e\n\u003c/p\u003e\n\n---\n\n## 🚀 Two Modes, One Database\n\nCobaltDB runs in two modes — use it as an **embedded library** inside your Go application, or deploy it as a **standalone database server** that any MySQL client can connect to.\n\n```\n┌─────────────────────────────────────────────────────────┐\n│                     CobaltDB                            │\n│                                                         │\n│  ┌─────────────┐           ┌───────────────────────┐    │\n│  │ Embedded    │           │ Standalone Server     │    │\n│  │ (Go Library)│           │ (MySQL Protocol)      │    │\n│  │             │           │                       │    │\n│  │ db.Query()  │           │ mysql -h host -P 4200 │    │\n│  │ db.Exec()   │           │ Any MySQL client/ORM  │    │\n│  └─────────────┘           └───────────────────────┘    │\n└─────────────────────────────────────────────────────────┘\n```\n\n### Comparison\n\n| Feature | CobaltDB | PostgreSQL | MySQL | SQLite |\n|---------|----------|------------|-------|--------|\n| **Deployment** | Embedded + Server | Server only | Server only | Embedded only |\n| **Protocol** | MySQL wire protocol | PostgreSQL | MySQL | C API |\n| **Language** | Pure Go (Zero CGO) | C | C/C++ | C |\n| **Query Language** | SQL + JSON | SQL + JSON | SQL + JSON | SQL |\n| **Encryption at Rest** | ✅ AES-256-GCM | Plugin | Plugin | ❌ |\n| **WAL Encryption** | ✅ Built-in | ❌ | ❌ | ❌ |\n| **TLS** | ✅ TLS 1.2+ | ✅ | ✅ | ❌ |\n| **Replication** | ✅ Master-Slave | ✅ | ✅ | ❌ |\n| **Row-Level Security** | ✅ Policy-based | ✅ | ❌ | ❌ |\n| **Audit Logging** | ✅ Encrypted | Plugin | Plugin | ❌ |\n| **Vector Search** | ✅ HNSW | pgvector | ❌ | ❌ |\n| **Temporal Queries** | ✅ AS OF | ✅ | ❌ | ❌ |\n| **Zero Dependencies** | ✅ | ❌ | ❌ | ✅ |\n| **Cross-Compile** | ✅ Any OS/Arch | ❌ | ❌ | CGO needed |\n| **Single Binary** | ✅ | ❌ | ❌ | Library |\n\n---\n\n## 📦 Installation\n\n```bash\ngo get github.com/cobaltdb/cobaltdb\n```\n\n**Requirements:** Go 1.24+ (`toolchain go1.26.1`) · Zero CGO runtime dependency\n\n### Verification and Security Checks\n\nRun core checks locally:\n\n```bash\nmake verify\n```\n\nRun full security/concurrency gate (requires CGO toolchain and `gcc` for race detector):\n\n```bash\nmake verify-security\n```\n\nIf tool commands are missing locally, install:\n\n```bash\ngo install golang.org/x/vuln/cmd/govulncheck@latest\ngo install github.com/securego/gosec/v2/cmd/gosec@latest\ngo install github.com/golangci/golangci-lint/cmd/golangci-lint@latest\n```\n\n---\n\n## ⚡ Quick Start\n\n### 1. Server Mode — Connect with Any MySQL Client\n\n```bash\n# Start CobaltDB server\n./cobaltdb-server --mysql-addr 127.0.0.1:3307 --admin-pass \"StrongPass123!\" --data ./mydb.db\n\n# Connect with standard MySQL client\nmysql -h 127.0.0.1 -P 3307 -u admin -p\n```\n\n```sql\nmysql\u003e CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);\nmysql\u003e INSERT INTO users VALUES (1, 'Alice', 'alice@example.com');\nmysql\u003e SELECT * FROM users;\n+----+-------+-------------------+\n| id | name  | email             |\n+----+-------+-------------------+\n|  1 | Alice | alice@example.com |\n+----+-------+-------------------+\n```\n\n\u003e **Verified working** with `go-sql-driver/mysql`, `mysql` CLI, and standard MySQL wire protocol.\n\u003e Works with **any MySQL-compatible client**: Python (mysql-connector, SQLAlchemy), Node.js (mysql2, Prisma), Java (JDBC), Ruby, PHP, etc.\n\n**Server features:** MySQL protocol, TLS 1.2+, authentication (Argon2id), connection pooling, rate limiting, circuit breaker, health checks, encrypted audit logging, master-slave replication.\n\n### 2. Embedded Mode — Use as a Go Library\n\n```go\nimport \"github.com/cobaltdb/cobaltdb/pkg/engine\"\n\ndb, _ := engine.Open(\":memory:\", \u0026engine.Options{InMemory: true})\ndefer db.Close()\n\nctx := context.Background()\ndb.Exec(ctx, `CREATE TABLE users (\n    id INTEGER PRIMARY KEY,\n    name TEXT NOT NULL,\n    email TEXT UNIQUE,\n    metadata JSON\n)`)\n\ndb.Exec(ctx, \"INSERT INTO users VALUES (?, ?, ?, ?)\",\n    1, \"Alice\", \"alice@example.com\", `{\"role\": \"admin\"}`)\n\nrows, _ := db.Query(ctx, `SELECT name, JSON_EXTRACT(metadata, '$.role') FROM users`)\n```\n\n\u003e Zero CGO, zero dependencies. Import and use — no external server needed.\n\n### CLI Mode\n\n```bash\n# Interactive shell\n./cobaltdb-cli -i\n\n# Execute SQL directly\n./cobaltdb-cli -memory \"SELECT * FROM users\"\n\n# Connect to running server\n./cobaltdb-cli -host localhost:4200\n```\n\n### Docker Mode\n\n```bash\n# Start with Docker Compose (includes Prometheus + Grafana monitoring)\ndocker-compose up -d\n\n# Or run standalone\ndocker build -t cobaltdb .\ndocker run -d -p 4200:4200 -v cobaltdb_data:/data/cobaltdb cobaltdb\n\n# Connect to containerized database\ncobaltdb-cli -host localhost:4200\n```\n\nSee [DOCKER.md](DOCKER.md) for detailed Docker setup instructions.\n\n---\n\n## 🌍 Multi-Language SDKs\n\nCobaltDB speaks the MySQL wire protocol — connect from **any language** using standard MySQL drivers.\n\n### Go (Embedded)\n```go\nimport (\n    \"database/sql\"\n    _ \"github.com/cobaltdb/cobaltdb/sdk/go\"  // register driver\n)\n\ndb, _ := sql.Open(\"cobaltdb\", \"file://./data/mydb.cb?cache=1024\")\ndb.Exec(\"CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)\")\ndb.Exec(\"INSERT INTO users VALUES (?, ?)\", 1, \"Alice\")\n```\n\n### Go (Network Client)\n```go\nimport \"database/sql\"\nimport _ \"github.com/go-sql-driver/mysql\"\n\ndb, _ := sql.Open(\"mysql\", \"admin@tcp(127.0.0.1:3307)/\")\nrows, _ := db.Query(\"SELECT * FROM users\")\n```\n\n### Python\n```python\nimport cobaltdb  # sdk/python\n\nconn = cobaltdb.connect(host='127.0.0.1', port=3307, user='admin')\ncursor = conn.execute(\"SELECT * FROM users\")\nfor row in cursor.fetchall():\n    print(row)\n```\n\n### Node.js\n```javascript\nconst cobaltdb = require('./sdk/js');\n\nconst conn = await cobaltdb.connect({ host: '127.0.0.1', port: 3307 });\nconst [rows] = await conn.execute('SELECT * FROM users');\nconsole.log(rows);\n```\n\n### Java\n```java\nimport com.cobaltdb.sdk.CobaltDB;\n\nConnection conn = CobaltDB.connect(\"127.0.0.1\", 3307, \"admin\", \"\");\nResultSet rs = conn.createStatement().executeQuery(\"SELECT * FROM users\");\n```\n\n### Any MySQL Client\n```bash\nmysql -h 127.0.0.1 -P 3307 -u admin -e \"SELECT * FROM users\"\n```\n\n\u003e **Tip:** Any MySQL-compatible ORM works too — SQLAlchemy, Prisma, Hibernate, GORM, Sequelize, ActiveRecord, etc.\n\n---\n\n## 🔥 Performance Benchmarks\n\n**Test Environment:** AMD Ryzen 9 9950X3D · Go 1.26 · Windows 11\n\n### Core Operations (B-Tree Level)\n\n| Operation | Latency | Throughput |\n|-----------|---------|------------|\n| **PUT** | ~641 ns | **1.56M ops/sec** |\n| **PUT (Sequential)** | ~694 ns | **1.44M ops/sec** |\n| **GET (Point Lookup)** | ~64 ns | **15.7M ops/sec** |\n| **UPDATE** | ~153 ns | **6.5M ops/sec** |\n| **DELETE** | ~197 ns | **5.1M ops/sec** |\n| **SCAN (1K range)** | ~270 µs | **3.7K ops/sec** |\n\n### SQL Engine Performance (10K rows)\n\n| Operation | Latency | Detail |\n|-----------|---------|--------|\n| **INSERT** | ~2.0 µs | Single row with SQL parsing |\n| **Point Lookup** | ~2.1 µs | WHERE id = ? (indexed) |\n| **Full Scan (1K)** | ~598 µs | Custom fast decoder, no reflection |\n| **Full Scan (10K)** | ~8.8 ms | 130K allocs (42% less than json.Unmarshal) |\n| **SUM/AVG** | ~5.0 ms | Byte-level fast path, no JSON decode |\n| **COUNT(*)** | ~4.4 ms | Fast path, skip row decode |\n| **LIMIT 100 OFFSET 1K** | ~3.7 ms | Early termination |\n| **WHERE (10K)** | ~10.3 ms | Custom decoder + expression eval |\n| **Index vs No Index** | 458 µs vs 8.7 ms | **19x faster with index** |\n| **Inner JOIN (1K)** | ~724 µs | Hash join |\n| **3-Way JOIN (1K×3)** | ~2.0 ms | Hash join |\n| **Recursive CTE** | ~3.6 µs | 1000 nodes |\n| **Simple CTE** | ~584 µs | View-based resolution |\n| **Concurrent Read (×20)** | ~669 ns | Parallel goroutines |\n| **Transaction** | ~347 µs | Single statement |\n| **Rollback** | ~167 µs | 100 statements |\n| **Window (RowNumber)** | ~10.0 ms | OVER (ORDER BY) on 10K rows |\n| **DELETE (bulk)** | ~998 µs | WHERE age \u003c 50 on 1K rows |\n| **UPDATE (bulk)** | ~9.2 ms | WHERE age \u003c 50 on 10K rows |\n\n### Parser \u0026 Storage Performance\n\n| Component | Operation | Latency | Throughput |\n|-----------|-----------|---------|------------|\n| **SQL Parser** | Parse SELECT | ~826 ns | **1.2M ops/sec** |\n| **SQL Parser** | Parse INSERT | ~1.0 µs | **960K ops/sec** |\n| **SQL Parser** | Parse Complex Query | ~4.7 µs | **214K ops/sec** |\n| **Lexer** | Tokenize | ~499 ns | **2.0M ops/sec** |\n| **Buffer Pool** | Get Page | ~27 ns | **36.5M ops/sec** |\n| **Buffer Pool** | Memory Read | ~34 ns | **29.4M ops/sec** |\n| **WAL** | Append | ~192 µs | **5.2K ops/sec** |\n\n\u003e 💡 **In-memory benchmarks.** Disk persistence adds ~20-40% overhead depending on storage.\n\n---\n\n## 🔐 Security Features\n\nCobaltDB provides enterprise-grade security features:\n\n### Encryption at Rest\n\n```go\nimport \"github.com/cobaltdb/cobaltdb/pkg/storage\"\n\n// Generate encryption key\nkey, _ := storage.GenerateSecureKey()\n\n// Open encrypted database\ndb, _ := engine.Open(\"encrypted.db\", \u0026engine.Options{\n    EncryptionKey: key,\n})\n```\n\n- **AES-256-GCM** authenticated encryption\n- **Argon2id** for secure key derivation\n- Transparent encryption/decryption\n\n### TLS Support\n\n```go\nimport \"github.com/cobaltdb/cobaltdb/pkg/server\"\n\nconfig := \u0026server.Config{\n    Address: \":4200\",\n    TLS: \u0026server.TLSConfig{\n        Enabled:              true,\n        GenerateSelfSigned:   true,  // Auto-generate certs\n        // Or provide your own:\n        // CertFile: \"server.crt\",\n        // KeyFile:  \"server.key\",\n    },\n}\n\nsrv, _ := server.New(db, config)\nsrv.Listen(\":4200\", config.TLS)\n```\n\n- **TLS 1.2/1.3** support\n- Self-signed certificate generation\n- Client certificate authentication\n\n### Audit Logging\n\n```go\nimport \"github.com/cobaltdb/cobaltdb/pkg/audit\"\n\nauditConfig := \u0026audit.Config{\n    Enabled:  true,\n    LogFile:  \"audit.log\",\n    LogFormat: \"json\",  // or \"text\"\n}\n\ndb, _ := engine.Open(\"audited.db\", \u0026engine.Options{\n    AuditConfig: auditConfig,\n})\n```\n\n- JSON and text format support\n- Query, DDL, and authentication events\n- Automatic log rotation (100MB default)\n\n### Row-Level Security (RLS)\n\n```go\nimport \"github.com/cobaltdb/cobaltdb/pkg/security\"\n\n// Enable RLS\ndb, _ := engine.Open(\"secure.db\", \u0026engine.Options{\n    EnableRLS: true,\n})\n\n// Create policies via SQL\n// CREATE POLICY tenant_isolation ON users\n//   USING (tenant_id = current_tenant());\n```\n\n---\n\n## 🏭 Production Features\n\nCobaltDB includes enterprise-grade production features for resilience, observability, and high availability:\n\n### Circuit Breaker\n\n```go\nimport \"github.com/cobaltdb/cobaltdb/pkg/engine\"\n\nconfig := \u0026engine.CircuitBreakerConfig{\n    MaxFailures:         5,\n    MinSuccesses:        3,\n    ResetTimeout:        30 * time.Second,\n    MaxConcurrency:      100,\n    HalfOpenMaxRequests: 1,\n}\n\ncb := engine.NewCircuitBreaker(config)\n\nif err := cb.Allow(); err != nil {\n    return err // Circuit open\n}\ndefer cb.Release()\n\nerr := doOperation()\nif err != nil {\n    cb.ReportFailure()\n} else {\n    cb.ReportSuccess()\n}\n```\n\n- Three states: Closed, Open, Half-Open\n- Automatic recovery with configurable timeout\n- Concurrency control and rate limiting in half-open state\n\n### Retry Logic\n\n```go\nconfig := \u0026engine.RetryConfig{\n    MaxAttempts:  3,\n    InitialDelay: 100 * time.Millisecond,\n    MaxDelay:     30 * time.Second,\n    Multiplier:   2.0,\n    Jitter:       0.1, // 10% randomization\n}\n\nerr := engine.Retry(ctx, config, func() error {\n    return db.Query(\"SELECT * FROM users\")\n})\n\n// Or with result\nresult, err := engine.RetryWithResult(ctx, config, func() (string, error) {\n    return fetchData()\n})\n```\n\n- Exponential backoff with jitter\n- Context cancellation support\n- 4 predefined policies: Fast, Standard, Aggressive, Background\n\n### Rate Limiter\n\n```go\nimport \"github.com/cobaltdb/cobaltdb/pkg/server\"\n\nconfig := \u0026server.RateLimiterConfig{\n    RPS:             1000,\n    Burst:           100,\n    PerClient:       true,\n    CleanupInterval: 5 * time.Minute,\n    MaxClients:      10000,\n}\n\nrl := server.NewRateLimiter(config)\ndefer rl.Stop()\n\nif !rl.Allow(\"client-id\") {\n    return errors.New(\"rate limit exceeded\")\n}\n```\n\n- Token bucket algorithm\n- Global and per-client rate limiting\n- Adaptive rate limiting based on system load\n\n### SQL Injection Protection\n\n```go\nconfig := \u0026server.SQLProtectionConfig{\n    Enabled:             true,\n    BlockOnDetection:    true,\n    MaxQueryLength:      10000,\n    MaxORConditions:     10,\n    MaxUNIONCount:       5,\n    SuspiciousThreshold: 3,\n}\n\nsp := server.NewSQLProtector(config)\n\nresult := sp.CheckSQL(sql)\nif !result.Allowed {\n    return errors.New(\"SQL injection detected\")\n}\n```\n\n- 15 SQL injection pattern detection\n- UNION-based, time-based blind, conditional blind, OOB exfil detection\n- Whitelist support for trusted queries\n\n### Distributed Tracing\n\n```go\n// Generate request ID\nctx = server.ContextWithRequestID(ctx, server.NewRequestContext().ID)\n\n// Extract from context\nrequestID := server.RequestIDFromContext(ctx)\n```\n\n- Request ID tracking across components\n- Span-based tracing\n- Context propagation\n\n### Health Checks \u0026 Monitoring\n\n```bash\n# Liveness probe (Kubernetes)\ncurl http://localhost:8420/health\n\n# Readiness probe (Kubernetes)\ncurl http://localhost:8420/ready\n\n# Detailed health status\ncurl http://localhost:8420/healthz\n\n# Circuit breaker statistics\ncurl http://localhost:8420/circuit-breakers\n\n# Rate limiter statistics\ncurl http://localhost:8420/rate-limits\n\n# System statistics\ncurl http://localhost:8420/stats\n```\n\n### Production Server\n\n```go\nconfig := \u0026server.ProductionConfig{\n    Lifecycle: \u0026server.LifecycleConfig{\n        ShutdownTimeout: 30 * time.Second,\n        DrainTimeout:    10 * time.Second,\n    },\n    EnableCircuitBreaker: true,\n    CircuitBreaker:       engine.DefaultCircuitBreakerConfig(),\n    EnableRetry:          true,\n    Retry:                engine.DefaultRetryConfig(),\n    EnableRateLimiter:    true,\n    EnableSQLProtection:  true,\n    EnableHealthServer:   true,\n    HealthAddr:           \":8420\",\n}\n\nps := server.NewProductionServer(db, config)\nif err := ps.Start(); err != nil {\n    log.Fatal(err)\n}\n\nps.Wait() // Wait for shutdown signal\n```\n\n- Graceful shutdown with configurable timeouts\n- Signal handling for SIGTERM/SIGINT\n- Component lifecycle management\n\n---\n\n## 📁 Project Structure\n\n```\ncobaltdb/\n├── 📂 cmd/                     # Command-line tools\n│   ├── cobaltdb-server/        # Production server\n│   ├── cobaltdb-cli/           # Interactive CLI\n│   ├── cobaltdb-migrate/       # Migration tool\n│   ├── cobaltdb-bench/         # Benchmark tool\n│   └── demo*/                  # Demo applications\n│\n├── 📂 pkg/                     # Core packages\n│   ├── engine/                 # Database engine (CB, retry)\n│   ├── catalog/                # SQL execution layer\n│   │   ├── catalog_core.go     # Core types \u0026 helpers\n│   │   ├── catalog_insert.go   # INSERT operations\n│   │   ├── catalog_update.go   # UPDATE operations\n│   │   ├── catalog_delete.go   # DELETE operations\n│   │   ├── catalog_select.go   # SELECT \u0026 JOIN\n│   │   ├── catalog_aggregate.go # GROUP BY \u0026 aggregates\n│   │   ├── catalog_window.go   # Window functions\n│   │   ├── catalog_cte.go      # CTE operations\n│   │   ├── catalog_ddl.go      # DDL operations\n│   │   ├── catalog_txn.go      # Transactions\n│   │   ├── catalog_eval.go     # Expression evaluation\n│   │   ├── catalog_index.go    # Index operations\n│   │   ├── catalog_rls.go      # Row-Level Security\n│   │   └── ...\n│   ├── query/                  # SQL parser \u0026 optimizer\n│   ├── btree/                  # B+Tree storage engine\n│   ├── storage/                # Storage layer (WAL, buffer pool)\n│   ├── server/                 # Network server (TLS, auth)\n│   ├── security/               # RLS \u0026 security\n│   ├── audit/                  # Audit logging\n│   ├── auth/                   # Authentication\n│   ├── protocol/               # MySQL protocol\n│   ├── metrics/                # Metrics collection\n│   └── txn/                    # Transaction manager\n│\n├── 📂 test/                    # Integration tests (5,000+)\n├── 📂 docs/                    # Documentation\n├── 📂 scripts/                 # Utility scripts\n│\n├── 📂 sdk/                     # Multi-language SDKs\n│   ├── go/                     # Go SDK (database/sql driver)\n│   ├── python/                 # Python SDK (mysql-connector wrapper)\n│   ├── js/                     # Node.js SDK (mysql2 wrapper)\n│   └── java/                   # Java SDK (JDBC wrapper)\n│\n└── 📂 website/                 # Project website\n```\n\n### Module Organization\n\n| Package | Purpose | Lines of Code |\n|---------|---------|---------------|\n| `pkg/catalog` | SQL execution (18 files) | ~8,500 |\n| `pkg/query` | SQL parser \u0026 optimizer | ~6,000 |\n| `pkg/btree` | B+Tree storage | ~1,500 |\n| `pkg/storage` | Storage layer | ~2,500 |\n| `pkg/server` | Network \u0026 production | ~3,500 |\n| `pkg/engine` | Resilience (CB, retry) | ~800 |\n\n---\n\n## ✨ Feature Highlights\n\n### 🗄️ SQL Support\n\n```sql\n-- DDL: Schema Definition\nCREATE TABLE products (\n    id INTEGER PRIMARY KEY,\n    name TEXT NOT NULL,\n    price REAL CHECK (price \u003e 0),\n    category TEXT,\n    tags JSON,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE INDEX idx_category ON products(category);\nCREATE VIEW expensive_products AS \n    SELECT * FROM products WHERE price \u003e 100;\n\n-- DML: Data Manipulation\nINSERT INTO products (name, price, category, tags) \nVALUES ('MacBook Pro', 1999.99, 'Electronics', '[\"laptop\", \"apple\"]');\n\n-- Complex SELECT with JOINs, Aggregates, Window Functions\nSELECT \n    p.category,\n    COUNT(*) as total,\n    AVG(p.price) as avg_price,\n    MAX(p.price) as max_price,\n    ROW_NUMBER() OVER (PARTITION BY p.category ORDER BY p.price DESC) as rank\nFROM products p\nLEFT JOIN orders o ON p.id = o.product_id\nWHERE p.price BETWEEN 100 AND 500\nGROUP BY p.category\nHAVING COUNT(*) \u003e 5\nORDER BY avg_price DESC\nLIMIT 10;\n```\n\n### 📊 Advanced Features\n\n**Window Functions**\n```sql\nSELECT \n    name,\n    salary,\n    AVG(salary) OVER (PARTITION BY dept) as dept_avg,\n    RANK() OVER (ORDER BY salary DESC) as salary_rank,\n    LAG(salary) OVER (ORDER BY salary) as prev_salary\nFROM employees;\n```\n\n**JSON Operations**\n```sql\n-- Extract nested values\nSELECT JSON_EXTRACT(metadata, '$.user.address.city') FROM users;\n\n-- Modify JSON\nUPDATE users SET metadata = JSON_SET(metadata, '$.last_login', '2026-03-02');\n\n-- Array operations\nSELECT * FROM products WHERE JSON_ARRAY_LENGTH(tags) \u003e 2;\n```\n\n**Transactions (ACID)**\n```sql\nBEGIN;\n    UPDATE accounts SET balance = balance - 100 WHERE id = 1;\n    UPDATE accounts SET balance = balance + 100 WHERE id = 2;\n    -- Atomic transfer\nCOMMIT;\n-- Or ROLLBACK on error\n```\n\n**Triggers \u0026 Procedures**\n```sql\n-- Audit logging trigger\nCREATE TRIGGER audit_log \nAFTER INSERT ON users\nBEGIN\n    INSERT INTO audit (table_name, action, record_id, created_at)\n    VALUES ('users', 'INSERT', NEW.id, CURRENT_TIMESTAMP);\nEND;\n\n-- Stored procedure\nCREATE PROCEDURE transfer_funds(from_id INT, to_id INT, amount REAL)\nBEGIN\n    UPDATE accounts SET balance = balance - amount WHERE id = from_id;\n    UPDATE accounts SET balance = balance + amount WHERE id = to_id;\nEND;\n\nCALL transfer_funds(1, 2, 100.00);\n```\n\n---\n\n## 🏗️ Architecture\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                      CLIENT LAYER                           │\n│    Go SDK  ·  CLI  ·  TCP/Wire Protocol  ·  REST API        │\n└─────────────────────────────────────────────────────────────┘\n                              │\n┌─────────────────────────────▼───────────────────────────────┐\n│                    SQL QUERY ENGINE                         │\n│  Parser → Planner → Optimizer → Executor (Iterator Model)   │\n└─────────────────────────────┬───────────────────────────────┘\n                              │\n┌─────────────────────────────▼───────────────────────────────┐\n│              TRANSACTION MANAGER (MVCC)                     │\n│         Snapshot Isolation · Conflict Detection             │\n└─────────────────────────────┬───────────────────────────────┘\n                              │\n┌─────────────────────────────▼───────────────────────────────┐\n│                   STORAGE ENGINE                            │\n│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────┐  │\n│  │   B+Tree     │  │ Index Mgr    │  │  Buffer Pool     │  │\n│  │  (Row Store) │  │ (Secondary)  │  │  (LRU Cache)     │  │\n│  └──────────────┘  └──────────────┘  └──────────────────┘  │\n│  ┌────────────────────────────────────────────────────────┐ │\n│  │  Page Manager · WAL (Write-Ahead Log) · Free Page List │ │\n│  └────────────────────────────────────────────────────────┘ │\n└─────────────────────────────────────────────────────────────┘\n                              │\n┌─────────────────────────────▼───────────────────────────────┐\n│                      I/O LAYER                              │\n│              Disk Backend  ·  Memory Backend                │\n└─────────────────────────────────────────────────────────────┘\n```\n\n### Key Components\n\n| Component | Technology | Purpose |\n|-----------|------------|---------|\n| **Storage** | B+Tree | Efficient range queries, ordered iteration |\n| **Buffer Pool** | LRU | Page caching, reduces disk I/O |\n| **WAL** | Write-Ahead Log | Durability, crash recovery |\n| **Transactions** | MVCC | Lock-free reads, snapshot isolation |\n| **JSON** | Native Parser | Document storage without external deps |\n\n---\n\n## 📋 SQL Reference\n\n### Data Types\n\n| Type | Description | Example |\n|------|-------------|---------|\n| `INTEGER` | 64-bit signed integer | `42`, `-17` |\n| `REAL` | 64-bit floating point | `3.14159`, `-0.001` |\n| `TEXT` | Variable-length string | `'hello'`, `\"world\"` |\n| `BOOLEAN` | True/False | `TRUE`, `FALSE` |\n| `JSON` | Native JSON document | `'{\"key\": \"value\"}'` |\n| `VECTOR(n)` | n-dimensional vector | `VECTOR(128)` for embeddings |\n| `DATE` | Date only | `'2026-03-02'` |\n| `TIMESTAMP` | Date + Time | `'2026-03-02 14:30:00'` |\n\n### SQL Functions\n\n**String:** `LENGTH`, `UPPER`, `LOWER`, `TRIM`, `SUBSTR`, `CONCAT`, `REPLACE`, `INSTR`  \n**Numeric:** `ABS`, `ROUND`, `FLOOR`, `CEIL`  \n**Aggregate:** `COUNT`, `SUM`, `AVG`, `MIN`, `MAX`  \n**JSON:** `JSON_EXTRACT`, `JSON_SET`, `JSON_REMOVE`, `JSON_VALID`, `JSON_ARRAY_LENGTH`, `JSON_MERGE`  \n**Window:** `ROW_NUMBER`, `RANK`, `DENSE_RANK`, `LAG`, `LEAD`, `FIRST_VALUE`, `LAST_VALUE`  \n**Date/Time:** `DATE`, `TIME`, `DATETIME`, `STRFTIME`  \n**Utility:** `COALESCE`, `IFNULL`, `NULLIF`, `CAST`\n\n### Supported Statements\n\n```sql\n-- DDL\nCREATE TABLE ... [PRIMARY KEY] [NOT NULL] [UNIQUE] [CHECK] [FOREIGN KEY]\nCREATE INDEX ... ON ...\nCREATE VIEW ... AS SELECT ...\nCREATE TRIGGER ... BEFORE|AFTER INSERT|UPDATE|DELETE\nCREATE PROCEDURE ...\nDROP TABLE|INDEX|VIEW|TRIGGER|PROCEDURE ... [IF EXISTS]\n\n-- DML\nINSERT INTO ... VALUES (...)\nINSERT INTO ... SELECT ...\nUPDATE ... SET ... WHERE ...\nDELETE FROM ... WHERE ...\nSELECT ... FROM ... [JOIN ... ON ...] [WHERE ...] [GROUP BY ...] [HAVING ...] [ORDER BY ...] [LIMIT ...] [OFFSET ...]\n\n-- DCL\nBEGIN | COMMIT | ROLLBACK\nCALL procedure_name(...)\n```\n\n---\n\n## 🔧 Development\n\n```bash\n# Clone the repository\ngit clone https://github.com/cobaltdb/cobaltdb.git\ncd cobaltdb\n\n# Run tests\ngo test ./... -v\n\n# Run tests with coverage\ngo test -coverprofile=coverage.out ./...\ngo tool cover -func=coverage.out\n\n# Run benchmarks\ngo test -bench=. -benchtime=2s ./test/...\n\n# Build CLI\ngo build -o cobaltdb-cli ./cmd/cobaltdb-cli\n\n# Build Server\ngo build -o cobaltdb-server ./cmd/cobaltdb-server\n\n# Run demo\ngo run cmd/demo/main.go\n```\n\n### Test Coverage\n\n| Package | Coverage | Package | Coverage |\n|---------|----------|---------|----------|\n| `pkg/pool` | 98.0% ✅ | `pkg/wasm` | 93.4% ✅ |\n| `pkg/auth` | 96.8% ✅ | `pkg/btree` | 92.4% ✅ |\n| `pkg/cache` | 95.5% ✅ | `pkg/backup` | 91.9% ✅ |\n| `pkg/protocol` | 95.1% ✅ | `pkg/security` | 91.9% ✅ |\n| `pkg/metrics` | 94.8% ✅ | `pkg/replication` | 91.8% ✅ |\n| `pkg/wire` | 94.7% ✅ | `pkg/query` | 90.9% ✅ |\n| `pkg/optimizer` | 93.8% ✅ | `pkg/audit` | 90.9% ✅ |\n| `pkg/logger` | 93.8% ✅ | `pkg/storage` | 90.5% ✅ |\n| `pkg/txn` | 93.5% ✅ | `pkg/server` | 90.2% ✅ |\n| `pkg/engine` | 90.0% ✅ | `pkg/catalog` | 85.5% ✅ |\n\n\u003e **10,400+ tests** across 22 packages, all passing. 19/20 packages above 90% coverage.\n\n---\n\n## 📚 Documentation\n\n| Document | Description |\n|----------|-------------|\n| [CHANGELOG.md](CHANGELOG.md) | Version history, all changes |\n| [COVERAGE_GUIDE.md](COVERAGE_GUIDE.md) | Test coverage analysis and targets |\n| [FEATURES.md](FEATURES.md) | **Feature status - what works 100% vs partially** |\n| [docs/PRODUCTION.md](docs/PRODUCTION.md) | **Production features guide (Circuit Breaker, Retry, Rate Limiting)** |\n| [docs/ARCHITECTURE_FULL.md](docs/ARCHITECTURE_FULL.md) | System design \u0026 components |\n| [docs/API.md](docs/API.md) | Go SDK documentation |\n| [docs/SQL.md](docs/SQL.md) | Complete SQL syntax |\n| [docs/BENCHMARKS.md](docs/BENCHMARKS.md) | Performance benchmarks |\n| [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md) | Getting started guide |\n\n---\n\n## 🛣️ Roadmap\n\n### ✅ Completed Features (v0.1.51)\n\n- [x] **SQL Support** - SELECT, INSERT, UPDATE, DELETE with JOINs, GROUP BY, ORDER BY, LIMIT\n- [x] **Window Functions** - ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, FIRST_VALUE, LAST_VALUE\n- [x] **JSON Support** - Native JSON type with JSON_EXTRACT, JSON_SET, JSON_REMOVE, JSON_ARRAY_LENGTH\n- [x] **Indexes** - CREATE INDEX, DROP INDEX with B+Tree implementation\n- [x] **Views** - CREATE VIEW, DROP VIEW support\n- [x] **Triggers** - CREATE TRIGGER with BEFORE/AFTER, INSERT/UPDATE/DELETE events\n- [x] **Stored Procedures** - CREATE PROCEDURE, CALL support\n- [x] **Transactions** - BEGIN, COMMIT, ROLLBACK with ACID compliance\n- [x] **User Management** - Authentication with permissions and sessions\n- [x] **Constraints** - PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, NOT NULL\n- [x] **MySQL Protocol** - Wire-compatible MySQL protocol support\n\n### ✅ Completed Features (v0.2.0)\n\n- [x] **Full-Text Search** - MATCH ... AGAINST syntax with inverted indexes\n- [x] **Materialized Views** - CREATE MATERIALIZED VIEW, REFRESH, and DROP support\n- [x] **Common Table Expressions** - WITH clause support for recursive and non-recursive CTEs\n- [x] **VACUUM** - Database compaction and storage reclamation\n- [x] **ANALYZE** - Table statistics collection for query optimization\n\n### ✅ Production Hardening (v0.2.11)\n\n- [x] **Panic Recovery** - Server survives any query panic\n- [x] **Resource Leak Fixes** - All iterators properly closed\n- [x] **Race Condition Fixes** - Statement cache thread-safety\n- [x] **Transaction Fixes** - Connection leak plugged\n- [x] **Data Corruption Fix** - Free list loading corrected\n\n### ✅ Enterprise Production Features (v0.2.20)\n\n- [x] **Circuit Breaker** - Three-state breaker with automatic recovery\n- [x] **Retry Logic** - Exponential backoff with 4 policies\n- [x] **Rate Limiter** - Token bucket with adaptive limiting\n- [x] **SQL Injection Protection** - 10+ pattern detection\n- [x] **Distributed Tracing** - Request ID tracking\n- [x] **Graceful Shutdown** - Signal handling with drain timeout\n- [x] **Health Checks** - Kubernetes-compatible probes\n\n### ✅ v0.2.22 - WASM \u0026 Advanced Features (2026-03-17)\n\n- [x] **WASM Compilation** - Compile SQL queries to WebAssembly bytecode\n- [x] **Query Plan Cache** - LRU cache for parsed query plans with statistics\n- [x] **Vector Support** - VECTOR data type with HNSW index for similarity search\n- [x] **Temporal Queries** - AS OF SYSTEM TIME for time-travel queries\n\n### ✅ v0.3.0 - Security Hardening \u0026 Stability (2026-03-20)\n\n- [x] **WAL Encryption** - AEAD encryption for write-ahead log with header authentication\n- [x] **Audit Log Encryption** - AES-256-GCM encrypted audit log entries\n- [x] **RLS Hardening** - Fixed bypass in UPDATE...FROM and DELETE...USING\n- [x] **Auth Hardening** - Password policy, brute force rate limiting, random default password\n- [x] **SQL Injection Protection** - 15 detection patterns (conditional blind, OOB exfil, etc.)\n- [x] **Concurrency Fixes** - Panic recovery, double-close protection, lifecycle tracking\n- [x] **10,400+ Tests** - 19/20 packages above 90% coverage\n\n### ✅ v0.3.1 - Production Ready Release (2026-03-31)\n\n- [x] **Deadlock Detection** - Wait-for graph with automatic cycle detection and resolution\n- [x] **Transaction Timeout** - Configurable per-transaction and lock wait timeouts\n- [x] **Transaction Metrics** - Real-time monitoring of active, committed, aborted transactions\n- [x] **Chaos Engineering** - Comprehensive stress tests for production readiness\n- [x] **Lock Management** - Fine-grained lock tracking with automatic release\n- [x] **Production Readiness Score: 93.5/100**\n- [x] **Graceful Shutdown** - Signal handling with drain timeout\n- [x] **Health Checks** - Kubernetes-compatible probes\n\n### ✅ v0.2.22 - WASM \u0026 Advanced Features (2026-03-17)\n\n- [x] **WASM Compilation** - Compile SQL queries to WebAssembly bytecode\n- [x] **Query Plan Cache** - LRU cache for parsed query plans with statistics\n- [x] **Vector Support** - VECTOR data type with HNSW index for similarity search\n- [x] **Temporal Queries** - AS OF SYSTEM TIME for time-travel queries\n\n### ✅ v0.3.0 - Security Hardening \u0026 Stability (2026-03-20)\n\n- [x] **WAL Encryption** - AEAD encryption for write-ahead log with header authentication\n- [x] **Audit Log Encryption** - AES-256-GCM encrypted audit log entries\n- [x] **RLS Hardening** - Fixed bypass in UPDATE...FROM and DELETE...USING\n- [x] **Auth Hardening** - Password policy, brute force rate limiting, random default password\n- [x] **SQL Injection Protection** - 15 detection patterns (conditional blind, OOB exfil, etc.)\n- [x] **Concurrency Fixes** - Panic recovery, double-close protection, lifecycle tracking\n- [x] **10,400+ Tests** - 19/20 packages above 90% coverage\n\n### 📋 Planned Features\n\n- [ ] **v0.4.0** - Distributed mode, Sharding support\n- [ ] **v0.5.0** - Cloud-native features, Kubernetes operator\n\n---\n\n## 💪 Why CobaltDB?\n\n1. **🚀 Pure Go** - Zero CGO, single binary, cross-compile to any OS/architecture\n2. **📱 Embedded + Server** - Use as Go library OR deploy as standalone MySQL-compatible server\n3. **🔒 Security First** - AES-256-GCM encryption (data + WAL + audit), TLS 1.2+, RLS, Argon2id auth\n4. **🔄 ACID + MVCC** - Snapshot isolation, lock-free reads, WAL durability\n5. **🗂️ SQL + JSON + Vector** - Relational queries, JSONPath, HNSW similarity search\n6. **⚡ Blazing Fast** - 15M+ point lookups/sec, 1.5M+ inserts/sec\n7. **🏭 Production Ready** - 10,400+ tests, 92% coverage, circuit breaker, rate limiter, replication\n\n---\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) file.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eBuilt with ❤️ by Ersin KOÇ\u003c/b\u003e\u003cbr\u003e\n  \u003ca href=\"https://github.com/cobaltdb/cobaltdb\"\u003eGitHub\u003c/a\u003e · \n  \u003ca href=\"https://pkg.go.dev/github.com/cobaltdb/cobaltdb\"\u003eGo Reference\u003c/a\u003e · \n  \u003ca href=\"https://goreportcard.com/report/github.com/cobaltdb/cobaltdb\"\u003eReport Card\u003c/a\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcobaltdb%2Fcobaltdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcobaltdb%2Fcobaltdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcobaltdb%2Fcobaltdb/lists"}