Node.js & TypeScript Quickstart
Install the official tapirus npm package, connect in-process, and execute SQL transactions without database daemons.
Do NOT paste JavaScript code (such as
import, const, or console.log) directly into Windows PowerShell or Linux Bash! Terminal prompts expect system executables, which will result in errors like:
import : The term 'import' is not recognized.Always save your code into a script file (e.g.,
app.mjs or app.js) and run it via node app.mjs!
1 Project Setup & Installation
Create a new directory and install the official package from npm:
# 1. Create and enter a new project directory
mkdir my-tapirus-app
cd my-tapirus-app
# 2. Initialize npm package and install tapirus
npm init -y
npm install tapirus
2 Write Your Script (app.mjs)
Create a file named app.mjs in your folder and paste the following complete code:
import { open, Tapirus } from "tapirus";
// 1. Open or create persistent single-file container "production.tapir"
// (Use ":memory:" if you want ultra-fast temporary RAM-only storage)
const db = open("production.tapir");
// Note: You can also use: const db = new Tapirus("production.tapir");
console.log("==> Connected to TapirusDB successfully!");
// 2. Create structured SQL table
db.execute(`
CREATE TABLE IF NOT EXISTS users (
id INT PRIMARY KEY,
name TEXT NOT NULL,
active INT NOT NULL
);
`);
// 3. Insert records
db.execute("INSERT INTO users VALUES (1, 'Alex', 1);");
db.execute("INSERT INTO users VALUES (2, 'Developer', 1);");
// 4. Query records via SQL
const rows = db.query("SELECT * FROM users WHERE active = 1;");
console.log("==> Query Results:", rows);
// 5. Always close when done
db.close();
console.log("==> Database closed cleanly.");
3 Run Your Application
Execute the script with Node.js:
node app.mjs
Expected Output:
==> Connected to TapirusDB successfully!
==> Query Results: [
{ id: 1, raw: 'INSERT INTO users VALUES (1, "Alex", 1)' },
{ id: 2, raw: 'INSERT INTO users VALUES (2, "Developer", 1)' }
]
==> Database closed cleanly.
4 Interactive Testing (Node.js REPL)
Want to test commands line-by-line in your PowerShell or Bash terminal? Enter the interactive Node REPL first:
# 1. Type node and press Enter:
PS C:\workspace\my-tapirus-app> node
Welcome to Node.js v20.x.x.
Type ".help" for more information.
# 2. Paste commands line by line:
> const { open } = require('tapirus');
> const db = open('test.tapir');
> db.execute("CREATE TABLE users (id INT, name TEXT);");
> db.execute("INSERT INTO users VALUES (1, 'Alex');");
> db.query("SELECT * FROM users;");
[ { id: 1, raw: 'INSERT INTO users VALUES (1, "Alex")' } ]
# 3. Press Ctrl + C twice to exit.
index.d.ts). You can run TypeScript files directly using npx ts-node app.ts with zero build steps!
Python Developer Quickstart
Integrate TapirusDB into your AI pipeline, LangChain agents, or data workflows with pure native bindings.
1 Setup Python Virtual Environment
# 1. Create and activate a virtual environment
python -m venv venv
# Windows PowerShell:
.\venv\Scripts\Activate.ps1
# Linux / macOS:
source venv/bin/activate
# 2. Install TapirusDB
pip install tapirus
2 Create Python Script (app.py)
from tapirus import Tapirus
# Open or create encrypted single-file container
with Tapirus.open("app.tapir") as db:
# 1. Execute SQL Transaction
db.execute("CREATE TABLE IF NOT EXISTS agents (id INTEGER PRIMARY KEY, name TEXT, role TEXT);")
db.execute("INSERT INTO agents VALUES (1, 'Hermes', 'Autonomous Researcher');")
db.execute("INSERT INTO agents VALUES (2, 'Argus', 'Telemetry Monitor');")
# 2. Query as native Python dictionaries
results = db.query("SELECT * FROM agents;")
print("Database Records:", results)
# 3. Vector Similarity Search
db.execute("CREATE TABLE embeddings (doc_id INT PRIMARY KEY, title TEXT, vector VECTOR(4));")
db.execute("INSERT INTO embeddings VALUES (1, 'Sovereign AI', [0.12, 0.45, 0.88, -0.23]);")
matches = db.query("SELECT doc_id, title FROM embeddings ORDER BY VECTOR_COSINE(vector, [0.10, 0.40, 0.85, -0.20]) DESC LIMIT 1;")
print("Nearest Vector Match:", matches)
3 Run Script
python app.py
Safe Rust Embedded Quickstart
Direct compile-time linking with #![forbid(unsafe_code)] for systems engineering, robotics, and high-performance apps.
1 Create Cargo Project
cargo new tapirus_quickstart
cd tapirus_quickstart
cargo add tapirus
2 Write main.rs
use tapirus::{Connection, Result};
fn main() -> Result<()> {
// Open single-file container (or Connection::open_in_memory()?)
let db = Connection::open("production.tapir")?;
// Relational SQL with native 4D Vector
db.execute("
CREATE TABLE IF NOT EXISTS memory (
id INTEGER PRIMARY KEY,
content TEXT NOT NULL,
embedding VECTOR(4)
);
")?;
db.execute("
INSERT INTO memory VALUES (1, 'Safe Rust Architecture', [0.12, 0.45, 0.88, -0.23]);
")?;
let rows = db.query("SELECT id, content FROM memory WHERE id = 1;")?;
println!("Retrieved Row: {:?}", rows);
Ok(())
}
3 Run
cargo run
Go (Golang) SDK Guide
High-concurrency cloud microservices and CLI tools powered by TapirusDB.
1 Initialize Go Module
mkdir go-tapirus && cd go-tapirus
go mod init myapp
go get github.com/tapiruslab/TapirusDB/sdks/go
2 Write main.go
package main
import (
"context"
"fmt"
tapirus "github.com/tapiruslab/TapirusDB/sdks/go"
)
func main() {
client := tapirus.NewClient(tapirus.Config{
Endpoint: "http://127.0.0.1:8080",
})
ctx := context.Background()
// Query SQL
res, err := client.Query(ctx, "SELECT id, name FROM items;")
if err != nil {
panic(err)
}
fmt.Println("Result:", res)
}
3 Run
go run main.go
Autonomous AI Agent Memory in 30 Minutes
Build unified Episodic, Semantic, and Knowledge Graph memory inside a single .tapir file with 0 latency, 0 cloud cost, and <4MB RAM.
Standard agent memory architectures stitch together SQLite (session state) + Pinecone/LanceDB (vector semantic search) + Neo4j (knowledge graphs). This incurs 3x network roundtrip latency (50-250ms), complex distributed sync bugs, and heavy cloud bills.
TapirusDB unifies all three modalities into an atomic, embedded Safe-Rust engine running directly in your application process thread.
1 Agent Memory Architecture
Every autonomous agent requires three distinct memory modalities stored with ACID guarantees:
- 1. Episodic Memory (Relational + Window Functions): Turn-by-turn dialogue and tool history ordered with SQL
LAG()andROW_NUMBER(). - 2. Semantic Memory (Native SIMD Vectors): High-dimensional embeddings evaluated with hardware-accelerated Cosine & L2 distance.
- 3. Associative Memory (GraphBLAS Topology): Entity-to-entity relationship graphs clustered with
GRAPH ALGORITHM louvain.
┌─────────────────────────────────────────────────────────────────┐
│ Autonomous AI Agent Runtime │
└────────────────────────────────┬────────────────────────────────┘
│ Direct In-Process C-ABI / SDK (< 0.02 ms)
┌────────────────────────────────▼────────────────────────────────┐
│ TapirusDB Embedded Engine (< 4MB RAM) │
│ 1. Relational & Window Analytics (Turn ranking, LAG/LEAD) │
│ 2. Native SIMD Vector Index (Cosine, L2 Top-K Search) │
│ 3. GraphBLAS Topological Engine (Louvain, Centrality, WCC) │
└────────────────────────────────┬────────────────────────────────┘
│ Single Encrypted File: `agent_vault.tapir`
2 Complete Python Implementation
Here is the complete, production-ready AI Agent Memory Manager utilizing TapirusDB's official Python SDK:
import tapirus
import time
from typing import List, Dict, Any
class AgentMemory:
def __init__(self, vault_path: str = "agent_vault.tapir"):
# Open local encrypted or plaintext vault (or ":memory:")
self.conn = tapirus.connect(vault_path)
self._init_schema()
def _init_schema(self):
# 1. Episodic Dialogue & Tool Log
self.conn.execute("""
CREATE TABLE IF NOT EXISTS episodes (
id INTEGER PRIMARY KEY,
session_id TEXT,
step INTEGER,
role TEXT,
content TEXT,
embedding VECTOR(4)
);
""")
# 2. Knowledge Graph Associative Relationships
self.conn.execute("""
CREATE TABLE IF NOT EXISTS kg_edges (
src_entity TEXT,
dst_entity TEXT,
relation TEXT,
weight FLOAT
);
""")
def record_episode(self, session_id: str, step: int, role: str, content: str, embedding: List[float]):
"""Records an episodic conversational turn or tool action with embedding."""
clean_content = content.replace("'", "''")
self.conn.execute(f"""
INSERT INTO episodes (id, session_id, step, role, content, embedding)
VALUES ({int(time.time()*1000)}, '{session_id}', {step}, '{role}', '{clean_content}', {embedding});
""")
def get_conversation_flow(self, session_id: str) -> List[Dict[str, Any]]:
"""
Uses ANSI SQL Window Functions (LAG) to fetch the interaction flow
along with what the previous turn said in a single sub-millisecond query.
"""
sql = f"""
SELECT
step,
role,
content,
LAG(content, 1) OVER (PARTITION BY session_id ORDER BY step ASC) as previous_turn
FROM episodes
WHERE session_id = '{session_id}'
ORDER BY step ASC;
"""
return self.conn.query(sql)
def retrieve_similar_episodes(self, query_embedding: List[float], top_k: int = 3) -> List[Dict[str, Any]]:
"""Performs native SIMD Cosine similarity search across all historical episodes."""
return self.conn.vector_search("episodes", "embedding", query_embedding, top_k=top_k)
def add_knowledge_link(self, src: str, dst: str, relation: str, weight: float = 1.0):
"""Adds an associative knowledge link between two extracted entities."""
self.conn.execute(f"""
INSERT INTO kg_edges VALUES ('{src}', '{dst}', '{relation}', {weight});
""")
def detect_topic_clusters(self) -> Dict[str, Any]:
"""Runs native Louvain community modularity algorithm on the agent's knowledge graph."""
return self.conn.graph_algorithm("louvain")
def checkpoint(self):
"""Flushes WAL log frames to the main .tapir container file."""
return self.conn.checkpoint()
# Example Execution:
if __name__ == "__main__":
memory = AgentMemory(":memory:")
# Ingest episodes
memory.record_episode("sess_01", 1, "user", "What is the capital of Malaysia?", [0.1, 0.8, 0.4, 0.2])
memory.record_episode("sess_01", 2, "assistant", "The capital of Malaysia is Kuala Lumpur.", [0.12, 0.79, 0.41, 0.22])
# Query with window function
flow = memory.get_conversation_flow("sess_01")
print("Episodic flow with LAG analysis:", flow)
# Semantic search
matches = memory.retrieve_similar_episodes([0.11, 0.81, 0.39, 0.21], top_k=2)
print("Semantic matches:", matches)
3 Node.js & TypeScript Implementation
For modern web frameworks, Electron desktops, and serverless Node runtimes:
import { TapirusClient, open } from "tapirusdb";
async function runAgentMemory() {
const db = new TapirusClient({ dbPath: "agent_memory.tapir" });
// 1. Initialize schema
await db.execute(`
CREATE TABLE agent_turns (
id INTEGER PRIMARY KEY,
turn_index INTEGER,
speaker TEXT,
utterance TEXT,
features VECTOR(4)
);
`);
// 2. Ingest interaction with dense vector
await db.execute(`
INSERT INTO agent_turns VALUES (
1, 1, 'user', 'Analyze quarterly revenue drop', [0.85, 0.12, 0.45, 0.90]
);
`);
// 3. Analytics with SQL Window Functions
const rankedTurns = await db.query(`
SELECT turn_index, speaker,
ROW_NUMBER() OVER (ORDER BY turn_index ASC) as sequential_rank
FROM agent_turns;
`);
console.log("Ranked agent turns:", rankedTurns);
// 4. Built-in SIMD Vector Search
const matches = await db.vectorSearch("agent_turns", "features", [0.82, 0.15, 0.40, 0.88], 3);
console.log("Vector semantic matches:", matches);
}
runAgentMemory().catch(console.error);
4 Architecture & Cost Duel
| Metric | Traditional RAG Stack (Pinecone+SQLite+Neo4j) | TapirusDB Unified |
|---|---|---|
| Moving Parts | 3 databases stitched over network | 1 single embedded .tapir file |
| Query Latency | 50ms - 250ms (HTTP network hops) | < 0.02ms (Sub-millisecond in-process) |
| Monthly Cloud Cost | $150 - $600 / month (Hosted pods) | $0.00 Forever (Zero cloud lock-in) |
| RAM Allocation | 500 MB - 2 GB | < 4 MB (Runs on edge IoT / 128MB) |
Tapirus Studio Visual Workbench
Manage databases visually like phpMyAdmin and Supabase Studio without writing boilerplate scripts. Available in-browser and as a free native desktop application.
Get Tapirus Studio Free
Zero cost. Available as an instant in-browser app, desktop packages, and Docker container.
Option A: Launch via Web Browser (Zero Installation)
You can run Tapirus Studio right now in any web browser without downloading any executable:
All database operations and documents are processed locally in your machine's client-side memory using WebAssembly.
Option B: Launch via Terminal CLI
If you already have the Tapirus CLI installed, launch the studio with a single command:
# Start the local embedded studio server and open in browser
tapirus studio
# Or run via Docker container
docker run -d -p 3020:3020 --name tapirus-studio ghcr.io/tapiruslab/studio:latest
Visual Features Overview
Explore the 6 core capabilities available in Tapirus Studio:
- Table Explorer: Visual schema browser, column inspection, pagination, and CSV/JSON export.
- SQL Workbench: Interactive query editor with syntax highlighting and instant data grid results.
- Canvas Graph Visualizer: Physics-based visual node & edge network for openCypher knowledge graphs.
- Vector Space Explorer: Interactive Cosine similarity math, distance testing, and HNSW telemetry.
- Storage Diagnostics: Real-time 4KB page monitor, LZ4 transparent compression ratios, and 1-click VACUUM.
- Sovereign Local SLM Foundry: Air-gapped document ingestion (PDF/Word/Markdown) and local model chat.