Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>BeatSQL — Zero-Trust Database EngineNew to Visual Studio Code? Get it now.
BeatSQL — Zero-Trust Database Engine

BeatSQL — Zero-Trust Database Engine

Vishnu Deviprasad Shetty

|
1 install
| (0) | Free
A next-generation zero-trust database language with native AES-256-GCM column encryption, blind searchable indexes, partially homomorphic arithmetic, Merkle tamper-evident ledger, AI vector search, and a built-in interactive learning academy.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info
BeatSQL Logo

BeatSQL (BSQL)

Zero-Trust Embedded Database Engine & Interactive Academy for Node.js & TypeScript

BeatSQL is a next-generation embedded database language and engine that treats security as a first-class mathematical primitive. Every column is encrypted at rest using AES-256-GCM or ChaCha20-Poly1305. Search queries execute in $O(1)$ time over HMAC blind indexes without full-table decryption. Every write mutation appends to an immutable, cryptographically verifiable Merkle state ledger. Sensitive numerical columns support partially homomorphic arithmetic directly on ciphertexts.


Quick Navigation

  • Installation
  • How to Run BeatSQL
  • Interactive REPL Shell
  • CLI Command Reference
  • Programmatic API (Node.js / TypeScript)
  • BSQL Language Syntax Reference
  • HTTP REST API
  • Dynamic Data Masking (RBAC)
  • Interactive Learning Academy
  • Security Architecture

Installation

As a Project Dependency (Library)

npm install beatsql

As a Global CLI Tool

npm install -g beatsql

(Or if developing locally: npm link inside the repository root)


How to Run BeatSQL

Method Command Description
Interactive REPL beatsql Interactive database shell with multi-line SQL & dot commands
Direct Query beatsql "SELECT * FROM users;" Execute SQL directly from terminal and print ASCII table
Run Script File beatsql run schema.bsql Execute .bsql / .beatsql script files with transaction verification
Project Scaffolding beatsql init ./myapp Initialize a new project with schema, app.js, and gitignore
Visual Studio beatsql studio Open browser-based visual query runner & cryptographic enclave
Learning Academy beatsql academy Launch interactive learning platform with 500+ lessons
HTTP Server beatsql server --port 7432 Start headless JSON over HTTP database server
Integrity Audit beatsql verify Verify mathematical Merkle state ledger proof chain

Interactive REPL Shell

Start the REPL shell by typing:

beatsql

Example Interactive Session

 ██████╗ ███████╗ ██████╗ ██╗
 ██╔══██╗██╔════╝██╔═══██╗██║
 ██████╔╝███████╗██║   ██║██║
 ██╔══██╗╚════██║██║▄▄ ██║██║
 ██████╔╝███████║╚██████╔╝███████╗
 ╚═════╝ ╚══════╝ ╚══▀▀═╝ ╚══════╝

 BeatSQL v1.0.0 — Zero-Trust Embedded Database Engine
 AES-256-GCM · Blind Indexes · Merkle Ledger · PHE · Vector Search

 Type .help for commands, or enter BSQL queries ending with ;
 Run beatsql studio to open the visual Studio UI in your browser.

bsql> SELECT * FROM users;
┌─────────┬────────────────────────────────────────┬──────────┬─────────────────────┬────────────────────────┬─────────┬─────────┬────────────────────────────┐
│ (index) │ id                                     │ username │ email               │ password               │ api_key │ role    │ created_at                 │
├─────────┼────────────────────────────────────────┼──────────┼─────────────────────┼────────────────────────┼─────────┼─────────┼────────────────────────────┤
│ 0       │ '4aa53f15-1c27-4aa7-a305-ab4a875441f9' │ 'admin'  │ 'admin@example.com' │ 'hashed_password_here' │ null    │ 'ADMIN' │ '2026-08-18T16:00:05.629Z' │
└─────────┴────────────────────────────────────────┴──────────┴─────────────────────┴────────────────────────┴─────────┴─────────┴────────────────────────────┘
(1 row, 0.71ms)

bsql> VERIFY INTEGRITY;
[OK] Merkle State Ledger VERIFIED: All 4 blocks & hashes are mathematically valid. (0.46ms)

[MERKLE VALID] 4 blocks verified, chain intact.

bsql> .tables
┌─────────┬────────────┬────────────┬───────────────┬────────────────────────────────────────────┬─────────────────────────┐
│ (index) │ table_name │ rows_count │ columns_count │ encrypted_columns                          │ blind_indexed_columns   │
├─────────┼────────────┼────────────┼───────────────┼────────────────────────────────────────────┼─────────────────────────┤
│ 0       │ 'users'    │ 1          │ 7             │ 'username, email, password, api_key, role' │ 'username, email, role' │
│ 1       │ 'sessions' │ 0          │ 6             │ 'token, ip_address'                        │ 'token, ip_address'     │
└─────────┴────────────┴────────────┴───────────────┴────────────────────────────────────────────┴─────────────────────────┘
(2 rows, 0.20ms)

bsql> .schema users
┌─────────┬──────────────┬────────────────┬─────────────┬───────────────────────────┬─────────────────────┬─────────────┬────────────┐
│ (index) │ column_name  │ data_type      │ primary_key │ encrypted                 │ blind_searchable    │ homomorphic │ masked_for │
├─────────┼──────────────┼────────────────┼─────────────┼───────────────────────────┼─────────────────────┼─────────────┼────────────┤
│ 0       │ 'id'         │ 'UUID'         │ 'YES'       │ 'NO'                      │ 'NO'                │ 'NO'        │ 'NONE'     │
│ 1       │ 'username'   │ 'VARCHAR(80)'  │ 'NO'        │ 'YES (AES_256_GCM)'       │ 'YES (HMAC-SHA256)' │ 'NO'        │ 'NONE'     │
│ 2       │ 'email'      │ 'VARCHAR(255)' │ 'NO'        │ 'YES (AES_256_GCM)'       │ 'YES (HMAC-SHA256)' │ 'NO'        │ 'NONE'     │
│ 3       │ 'password'   │ 'TEXT'         │ 'NO'        │ 'YES (CHACHA20_POLY1305)' │ 'NO'                │ 'NO'        │ 'NONE'     │
│ 4       │ 'api_key'    │ 'TEXT'         │ 'NO'        │ 'YES (AES_256_GCM)'       │ 'NO'                │ 'NO'        │ 'NONE'     │
│ 5       │ 'role'       │ 'VARCHAR(30)'  │ 'NO'        │ 'YES (AES_256_GCM)'       │ 'YES (HMAC-SHA256)' │ 'NO'        │ 'NONE'     │
│ 6       │ 'created_at' │ 'TIMESTAMP'    │ 'NO'        │ 'NO'                      │ 'NO'                │ 'NO'        │ 'NONE'     │
└─────────┴──────────────┴────────────────┴─────────────┴───────────────────────────┴─────────────────────┴─────────────┴────────────┘
(7 rows, 0.28ms)

bsql> .exit

Session ended. Keys zeroized.

REPL Dot Commands Reference

Command Syntax Description
.help .help Display command reference and REPL shortcuts
.tables .tables List all tables, row counts, and encryption statuses
.schema .schema <table_name> Display column types, primary keys, cipher algorithms & masking rules
.verify .verify Verify mathematical integrity of all Merkle state ledger blocks
.tamper .tamper <block_index> Simulate an adversarial raw disk corruption attack on block index
.role .role <SUPERADMIN\|DEVELOPER\|PUBLIC> Switch active user role to inspect dynamic data masking in real time
.keys .keys Display active cryptographic key enclave status, PBKDF2 iterations & KEK/DEK state
.clear .clear Clear the terminal window
.exit / .quit .exit Exit the REPL and immediately zeroize in-memory cryptographic key buffers

CLI Command Reference

1. beatsql studio

Launches the Web Studio on http://localhost:8080 (or specified --port) and automatically opens your default browser.

beatsql studio
beatsql studio --port 9000

2. beatsql academy

Launches the interactive learning academy directly on http://localhost:8080/academy.html.

beatsql academy

3. beatsql init [dir]

Scaffolds a complete BeatSQL project structure:

beatsql init ./my-project

Creates:

  • schema.bsql — Initial database schema with AES-256-GCM encrypted tables
  • app.js — Node.js quickstart utilizing the connect() API
  • .gitignore — Configured to safely ignore .beatdb_data/
  • README.md — Project instructions and cheat sheet

4. beatsql "<sql>" or beatsql query "<sql>"

Executes a single or multi-statement query and formats output in an ASCII table:

beatsql "SHOW TABLES;"
beatsql "FROM users |> SELECT id, username, role;"
beatsql query "SELECT HOMOMORPHIC_SUM(salary) FROM employees;"

5. beatsql run <file.bsql>

Executes a .bsql or .beatsql script file with transaction proof generation:

beatsql run schema.bsql
beatsql run ./migrations/001_init.bsql --data-dir ./data

6. beatsql server

Starts the HTTP REST API server:

beatsql server --port 7432

7. beatsql verify

Verifies the cryptographic Merkle chain of the local database vault:

beatsql verify

CLI Global Flags

Flag Argument Default Description
--db <name> beatsql_main Target database vault identifier
--passphrase <string> Default key Master passphrase for PBKDF2 key derivation
--data-dir <path> ./.beatdb_data Directory for encrypted database storage
--role <role> SUPERADMIN Active RBAC role (SUPERADMIN, DEVELOPER, PUBLIC)
--port <number> 8080 / 7432 Port number for Studio or HTTP Server

Programmatic API (Node.js / TypeScript)

TypeScript (ESM)

import { connect, createConnection, Database } from 'beatsql';

// Connect to local encrypted vault
const db = connect({
  name: 'production_vault',
  passphrase: process.env.DB_MASTER_PASSPHRASE || 'SecureSecretPassphrase!2026',
  dataDir: './.beatdb_data',
  defaultRole: 'SUPERADMIN'
});

// 1. Create zero-trust table
db.execute(`
  CREATE TABLE IF NOT EXISTS patients (
    id         UUID          PRIMARY KEY AUTO_GENERATE,
    full_name  VARCHAR(120)  SEARCHABLE,
    ssn        VARCHAR(11)   ENCRYPTED WITH 'CHACHA20_POLY1305'
                             MASKED FOR 'DEVELOPER' AS 'XXX-XX-####'
                             MASKED FOR 'PUBLIC' AS '[REDACTED]',
    email      VARCHAR(255)  ENCRYPTED WITH 'AES_256_GCM' BLIND_INDEXED,
    salary     DECIMAL       ENCRYPTED WITH 'PAILLIER_PHE' HOMOMORPHIC,
    bio_vector VECTOR(768)   AI_EMBEDDING,
    created_at TIMESTAMP     DEFAULT NOW() IMMUTABLE
  );
`);

// 2. Insert record (auto-encrypted & blind-indexed)
db.execute(`
  INSERT INTO patients (full_name, ssn, email, salary, bio_vector)
  VALUES (
    'Alice Walker',
    '987-65-4321',
    'alice@example.com',
    145000.00,
    [0.12, -0.45, 0.89, 0.22]
  );
`);

// 3. O(1) Blind Search without full table decryption
const result = db.execute(`
  FROM patients
  |> WHERE email = 'alice@example.com'
  |> SELECT id, full_name, email, ssn, salary;
`);
console.table(result.rows);

// 4. Role-based Dynamic Data Masking
const devView = db.execute(`SELECT full_name, ssn FROM patients;`, 'DEVELOPER');
console.log(devView.rows); // ssn: 'XXX-XX-4321'

// 5. Homomorphic addition over ciphertexts
const totalPayroll = db.execute(`SELECT HOMOMORPHIC_SUM(salary) AS total FROM patients;`);
console.log('Total Payroll:', totalPayroll.rows[0].total);

// 6. Merkle Ledger Verification
const proof = db.verifyIntegrity();
console.log('Merkle chain valid:', proof.integrityResult?.isValid);

CommonJS (CJS)

const { connect } = require('beatsql');

const db = connect({ name: 'myapp' });

db.execute(`CREATE TABLE IF NOT EXISTS users (id UUID PRIMARY KEY AUTO_GENERATE, email VARCHAR(255) ENCRYPTED WITH 'AES_256_GCM' BLIND_INDEXED);`);
db.execute(`INSERT INTO users (email) VALUES ('admin@example.com');`);

const res = db.execute(`SELECT * FROM users WHERE email = 'admin@example.com';`);
console.log(res.rows);

BSQL Language Syntax Reference

1. CREATE TABLE with Enclave Directives

CREATE TABLE IF NOT EXISTS accounts (
  id          UUID          PRIMARY KEY AUTO_GENERATE,
  account_no  VARCHAR(30)   SEARCHABLE,
  email       VARCHAR(255)  ENCRYPTED WITH 'AES_256_GCM' BLIND_INDEXED,
  card_pin    TEXT          ENCRYPTED WITH 'CHACHA20_POLY1305',
  balance     DECIMAL       ENCRYPTED WITH 'PAILLIER_PHE' HOMOMORPHIC,
  face_vec    VECTOR(512)   AI_EMBEDDING,
  created_at  TIMESTAMP     DEFAULT NOW() IMMUTABLE
);

2. Stream Pipelines (|>)

FROM accounts
|> WHERE balance > 50000
|> SELECT account_no, email, balance
|> ORDER BY balance DESC
|> LIMIT 10;

3. Homomorphic Aggregation

-- Computes the sum directly over ciphertext without decrypting individual cells
SELECT HOMOMORPHIC_SUM(balance) AS total_balance FROM accounts;

4. AI Vector Similarity Search

-- Computes Cosine Similarity against high-dimensional AI embeddings
SELECT account_no, COSINE_SIMILARITY(face_vec, [0.05, 0.91, -0.32, 0.44]) AS score
FROM accounts
|> ORDER BY score DESC
|> LIMIT 5;

5. Merkle Integrity Verification

VERIFY INTEGRITY;

HTTP REST API

Start the API server:

beatsql server --port 7432

Execute Query (POST /query)

curl -X POST http://localhost:7432/query \
  -H "Content-Type: application/json" \
  -H "X-User-Role: SUPERADMIN" \
  -d '{"sql": "FROM users |> SELECT id, username, role;"}'

Response:

{
  "success": true,
  "results": [
    {
      "statementType": "SELECT",
      "rowCount": 1,
      "rows": [{ "id": "4aa53f15-...", "username": "admin", "role": "ADMIN" }],
      "executionTimeMs": 0.54
    }
  ]
}

Server Health Check (GET /health)

curl http://localhost:7432/health

Dynamic Data Masking (RBAC)

Column masking rules are enforced at the database query engine level:

Role Query Result
SUPERADMIN alice@example.com, $145,000.00, 987-65-4321 (Decrypted Plaintext)
DEVELOPER al***@***.com, $***, XXX-XX-4321 (Partially Masked)
PUBLIC [REDACTED], [REDACTED], [REDACTED] (Fully Redacted)

Interactive Learning Academy

BeatSQL includes a built-in learning academy:

beatsql academy
  • 500+ Progressive Lessons: From basic stream pipelines to zero-trust encryption enclaves.
  • 200+ MySQL Lessons: Complete traditional relational SQL curriculum.
  • 5 Multi-Language Capstone Projects: 100+ line real-world integration architectures with drivers for Python, Java, C++, and Rust.
  • Mobile Reading Mode: Full-screen documentation view optimized for reading on phone and tablet screens without typing.
  • GeeksforGeeks-Style Docs Engine: Syntax diagrams, time/space complexity analysis, common pitfalls, and enterprise use cases for every topic.

Security Architecture

Security Layer Cryptographic Primitive Implementation
Master Key Derivation PBKDF2-SHA512 100,000 iterations + 32-byte cryptographic salt
Key Encryption Key (KEK) HKDF-SHA256 Isolated per vault version
Data Encryption Key (DEK) AES-256-GCM 256-bit envelope key with authenticated tag validation
Column Encryption AES-256-GCM / ChaCha20 Authenticated cipher with AAD binding
Blind Indexing HMAC-SHA256 Column-isolated secret salt for zero-plaintext search
Homomorphic Arithmetic Paillier Cryptosystem Additive ciphertext arithmetic without private key disclosure
State Tamper Detection Merkle DAG Hash Chain SHA-256 block header chaining with mathematical proofs
Memory Security Buffer Zeroization Immediate wiping of key buffers after cryptographic operations

License

Apache-2.0 © BeatSQL Foundation

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft