Skip to content

startvibecoding/AgentNativeDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AgentNativeDB

AgentNativeDB

๐Ÿค– Agent-Native Database โ€” Sessions, Memory, Decisions as First-Class Citizens

A purpose-built database system designed from the ground up for AI agents.
Combines a SQL query engine, vector search (HNSW), graph store, knowledge/lineage tracking, and MCP server integration โ€” all in a single Go binary.

npm downloads PyPI version GitHub release License: MIT Go Report Card GoDoc


โœจ Why AgentNativeDB?

The Problem: AI agents need persistent memory, structured data, vector search, and knowledge graphs โ€” but stitching together multiple databases is fragile and complex.

The Solution: AgentNativeDB is the agent-native database that combines everything into a single binary. Sessions, memories, and decisions are first-class data types, not afterthoughts.

๐ŸŽฏ Key Highlights

Feature What It Means for You
๐Ÿค– Agent-Native Schema Sessions, memories, decisions, and tasks are built-in table types with optimized storage
โšก SQL Query Engine Hand-written lexer โ†’ parser โ†’ planner โ†’ executor โ€” SELECT/INSERT/UPDATE/DELETE, WHERE, JOIN, GROUP BY, ORDER BY, LIMIT, aggregations
๐Ÿ” Vector Search Custom HNSW index with cosine/L2/dot-product distance โ€” no third-party vector libraries
๐Ÿ•ธ๏ธ Graph Store Adjacency-list storage with BFS, K-hop, shortest-path queries โ€” all persisted on BadgerDB
๐Ÿ“Š Data Lineage Track data provenance and transformation history through the knowledge layer
๐Ÿ”— MCP Server Model Context Protocol (stdio) โ€” plug into Cursor, Claude Desktop, or any MCP-compatible client
๐ŸŒ HTTP API RESTful endpoints for sessions, memories, decisions, and SQL queries
๐Ÿ’ป Interactive CLI Local SQL REPL with syntax highlighting, command history, and auto-completion
๐Ÿ–ฅ๏ธ Web UI Svelte-based dashboard embedded into the binary โ€” table management, data visualization, SQL editor
๐Ÿ“ฆ Pure Go Single binary, zero CGO, no external runtime dependencies โ€” only BadgerDB (pure Go KV store)

๐Ÿš€ Get Started in 30 Seconds

# Install (pick one)
npm install -g andb-installer               # npm
pip install andb-installer                  # PyPI / pipx
go install github.com/startvibecoding/AgentNativeDB/cmd/andb@latest  # Go

# Build from source
git clone https://github.com/startvibecoding/AgentNativeDB.git
cd AgentNativeDB
make build

Supported Platforms: Linux (x86_64, arm64), macOS (x86_64, arm64), Windows (x86_64)

Run

# HTTP server (default: 0.0.0.0:8400)
./bin/andb server

# MCP server (stdio transport)
./bin/andb server -mode mcp

# Interactive SQL CLI (local)
./bin/andb cli

# HTTP client (connect to remote server)
./bin/andb client -server localhost:8400

# Version
./bin/andb version

Uninstall:

npm uninstall -g andb-installer
pip uninstall andb-installer

๐ŸŽฎ SQL Query Examples

-- Create tables
CREATE TABLE agent_sessions (
  id VARCHAR(64) PRIMARY KEY,
  agent_id VARCHAR(64),
  state VARCHAR(32),
  created_at INTEGER
);

CREATE TABLE agent_memories (
  id VARCHAR(64) PRIMARY KEY,
  session_id VARCHAR(64),
  content TEXT,
  importance FLOAT
);

-- Basic queries
SELECT * FROM agent_sessions WHERE state = 'active';

-- Aggregation
SELECT agent_id, COUNT(*) as cnt FROM agent_sessions GROUP BY agent_id;

-- JOIN
SELECT s.agent_id, m.content
FROM agent_sessions s
JOIN agent_memories m ON s.id = m.session_id
WHERE m.importance > 0.7;

-- Sorting and pagination
SELECT * FROM agent_memories ORDER BY importance DESC LIMIT 10;

-- Full-text search (INVERTED index)
CREATE TABLE docs (id VARCHAR(64) PRIMARY KEY, body TEXT);
CREATE FULLTEXT INDEX idx_docs_body ON docs(body);
SELECT * FROM docs WHERE MATCH(body) AGAINST ('agent memory');

-- Vector search
CREATE TABLE embeddings (id VARCHAR(64) PRIMARY KEY, embedding FLOAT);
CREATE VECTOR INDEX idx_emb ON embeddings(embedding) WITH (dimensions=128);
SELECT * FROM vector_search(idx_emb, '[0.1, 0.2, ...]', 10);

-- Graph queries
CREATE GRAPH TABLE edges (src VARCHAR(64), dst VARCHAR(64));
SELECT * FROM graph_bfs(edges, 'node_001', 3);
SELECT * FROM graph_shortest_path(edges, 'node_001', 'node_010');

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  API Layer                       โ”‚
โ”‚   HTTP REST  โ”‚  MCP Server  โ”‚  CLI  โ”‚  Web UI   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚              Agent Runtime                       โ”‚
โ”‚  Session โ”‚ Memory โ”‚ Decision โ”‚ Coordinator โ”‚ Auditโ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚             Unified Query Layer                  โ”‚
โ”‚   SQL Engine  โ”‚  Graph Query  โ”‚  Vector Search   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚              Storage Engine                      โ”‚
โ”‚   BadgerDB  โ”‚  HNSW Index  โ”‚  Graph Store       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Project Structure

AgentNativeDB/
โ”œโ”€โ”€ cmd/andb/                 # Single entry point (server, cli, client, version)
โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ http/                 # RESTful HTTP API
โ”‚   โ””โ”€โ”€ mcp/                  # MCP Server (stdio transport)
โ”œโ”€โ”€ config/                   # Configuration management
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ storage/              # Storage engine abstraction + LRU cache
โ”‚   โ”œโ”€โ”€ storage/badger/       # BadgerDB implementation
โ”‚   โ”œโ”€โ”€ model/                # Core data types (Session, Memory, Decision, Entity)
โ”‚   โ”œโ”€โ”€ agent/                # Agent runtime (session, memory, decision, RAG, audit)
โ”‚   โ”œโ”€โ”€ query/sql/            # SQL engine (lexer โ†’ parser โ†’ planner โ†’ executor)
โ”‚   โ”œโ”€โ”€ query/sql/index/      # Secondary indexes (Hash, BTree, Inverted/FullText)
โ”‚   โ”œโ”€โ”€ query/graph/          # Graph query surface
โ”‚   โ”œโ”€โ”€ query/vector/         # Vector query surface
โ”‚   โ”œโ”€โ”€ vector/               # HNSW vector index
โ”‚   โ”œโ”€โ”€ graph/                # Graph store (adjacency list, BFS, K-hop)
โ”‚   โ”œโ”€โ”€ knowledge/            # Data lineage tracking
โ”‚   โ””โ”€โ”€ util/                 # UUID v7 generation
โ”œโ”€โ”€ sdk/                      # Go SDK
โ”œโ”€โ”€ ui/                       # Svelte + Vite Web UI (embedded into binary)
โ”œโ”€โ”€ docs/                     # Design document
โ””โ”€โ”€ examples/                 # Example scripts

๐Ÿ“š API Reference

HTTP Endpoints

Method Path Description
POST /api/v1/sessions Create session
GET /api/v1/sessions/{id} Get session
PATCH /api/v1/sessions/{id} Update session
DELETE /api/v1/sessions/{id} Delete session
GET /api/v1/sessions List sessions
POST /api/v1/memories Store memory
GET /api/v1/memories?session_id= List memories
POST /api/v1/decisions Record decision
GET /api/v1/decisions?session_id= List decisions
GET /api/v1/decisions/{id}/tree Decision tree
POST /api/v1/query SQL query
GET /health Health check

MCP Tools

Tool Description
query_sql Execute SQL query
create_session Create agent session
store_memory Store agent memory
recall_memories Retrieve agent memories
record_decision Record agent decision

๐Ÿ› ๏ธ Built-in Commands

Command Description
./bin/andb server Start HTTP API server (default: 0.0.0.0:8400)
./bin/andb server -mode mcp Start MCP server (stdio transport)
./bin/andb cli Interactive SQL REPL (local database)
./bin/andb client -server host:port HTTP client (connect to remote)
./bin/andb version Show version

๐Ÿ”ง Configuration

Settings File

Location Platform Scope
config.json All Project-level configuration
{
  "server": {
    "host": "0.0.0.0",
    "port": 8400
  },
  "storage": {
    "data_dir": "./data"
  }
}

Command-Line Flags

./bin/andb server                    # Default: 0.0.0.0:8400
./bin/andb server -host 127.0.0.1    # Bind to localhost
./bin/andb server -port 9000         # Custom port
./bin/andb cli                       # Default data dir
./bin/andb cli -data /path/to/data   # Custom data dir
./bin/andb client -server host:port  # Connect to remote

๐Ÿ› ๏ธ Development

# Build the Web UI (Vite) then the binary
make build

# Build only the Go binary (no UI rebuild)
go build -o bin/andb ./cmd/andb

# Run server
make run

# Run tests
make test

# Run tests with race detector
make race

# Benchmarks
make bench

# Lint / format / vet
make lint

# Full check (fmt + vet + test)
make check

# Clean build artifacts
make clean

๐Ÿ“Š Tech Stack

Component Choice Rationale
Language Go 1.23+ Single binary, no runtime deps, cross-compile
KV Store BadgerDB Pure Go, no CGO, built-in LSM-tree, WAL, MVCC
Vector Index Custom HNSW Supports cosine/L2/dot distance, zero external deps
Graph Store Custom adjacency list Persisted on BadgerDB
SQL Engine Custom recursive descent Supports full SQL subset
Web UI Svelte + Vite Embedded into binary at build time
Protocol MCP (stdio) Standard agent-tool integration protocol

๐Ÿค Contributing

We welcome contributions! See AGENTS.md for project conventions.

git clone https://github.com/startvibecoding/AgentNativeDB.git
cd AgentNativeDB
make build
make test

๐Ÿ“„ License

MIT โ€” see LICENSE for details.


Ready to build agent-native data infrastructure? โญ Star this repo and get started!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors