Skip to content
NEW BLOG

Using Surrealism to build your own extensions

Read blog

1/2

The context layer
for AI agents

The database where storage, context, and memory are one transaction.

THE PLATFORM

The only vertical stack
from storage to memory

No other product offers this. Object storage to agent memory. One transaction boundary. One permission model. One deployment.

THE ARCHITECTURE

One stack. Four layers.
Every layer under one roof.

Spectron gives agents persistent memory. SurrealDB unifies every data model in one ACID transaction. The storage engine separates compute from storage on commodity object storage. No glue code. No middleware.

Read the thesis
Applications
Spectron
Spectron
Memory
Entity extraction
Knowledge graph
Temporal facts
Hybrid retrieval
SurrealDB
SurrealDB
Context
Documents
Graphs
Vectors
Time-series
Auth
APIs
SurrealDS
Storage
Storage
TAPIR consensus
Compute-storage sep.
Scale to zero
SurrealDS
Object Storage (S3 / GCS / Azure Blob)

THE PROBLEM

Agents fail due to context.
Not models.

Your model can reason. It just has nothing reliable to reason over. Five systems. Five consistency models. Context that fragments at every seam.

Context that leaks at every seam

Data flows between five systems. Relationships, history, and metadata fragment at every boundary.

App state

User session

Vector DB

Embeddings

Graph DB

Relations

Doc store

Documents

Auth

Identity

Data fragments at every system boundary

Writes that half-succeed

Memory updates in one system, state fails in another. Without unified transactions, partial writes corrupt context.

Single transaction

Vector DB

Write embedding

Graph DB

Write relation

committed

inconsistent state

rolled back

Latency that compounds

Every system adds a network hop. Round trips stack under load until agents miss their response window.

Agent

Vector DB

Graph DB

Doc store

Auth

Total

Cumulative latency

Five systems to keep alive

Five failure modes, five monitoring setups, five sets of credentials. The glue code becomes the product.

Vector DB

Similarity search

auth

config

monitor

Graph DB

Relationship store

auth

config

monitor

Doc store

Raw document index

auth

config

monitor

Auth service

Identity & tokens

auth

config

monitor

Cache layer

Hot key store

auth

config

monitor

Five systems. Five auth configs. Five things to scale, secure, and keep alive.

HOW IT WORKS

The read-think-write loop

Read, think, write - in a single transaction.

WHY SURREALDB

Every failure has a structural fix.

Each failure mode has a structural fix - built into the engine, not bolted on top.

SURREALQL

One query. Every model.

Graph traversals, vector search, transactions, and access control in one expressive language.

MULTI-MODEL QUERY

Graph, vector, and temporal data in one round trip.

LET $vec = fn::embed("running shoes");

SELECT
->purchased->product AS history,
->reviewed->product[WHERE
vector::similarity::cosine(
embedding, $vec
) > 0.8
] AS relevant,
->prefs[WHERE valid_at <= time::now()] AS prefs
FROM ONLY $user;

ACID TRANSACTIONS

Multi-model writes succeed together or not at all.

BEGIN TRANSACTION;

LET $order = CREATE order SET
user = $auth.id,
product = product:headphones,
total = product:headphones.price;

RELATE $auth.id->purchased->product:headphones
SET at = time::now();

UPDATE product:headphones SET stock -= 1;

COMMIT TRANSACTION;

BUILT-IN AUTH

Authentication and row-level security in the database.

DEFINE ACCESS account ON DATABASE
TYPE RECORD
SIGNUP (
CREATE user SET
email = $email,
pass = crypto::argon2::generate($pass)
)
SIGNIN (
SELECT * FROM user WHERE
email = $email AND
crypto::argon2::compare(pass, $pass)
);

DEFINE TABLE order PERMISSIONS
FOR select WHERE user = $auth.id
FOR create WHERE $auth.id != NONE;

USE CASES

Built for agents

Context-aware agents, persistent memory, knowledge graphs, real-time collaboration - see what teams are building on the context layer.

See all use cases
@UnchainedAlgo's avatar

@UnchainedAlgo

I initially explored a more traditional stack: Neo4j for the graph database, RabbitMQ for a task queue, and Postgres with extensions for vector search. However, I realised SurrealDB could cover all of these needs, allowing me to consolidate the backend into a single dependency.

Colman Yau

VP of Engineering, PolyAI

The SurrealDB integration was seamless and delivered performance on par with our internal stack. It proves that enterprises can bring their own knowledge base without sacrificing speed, quality, or control.

Sigismond's avatar

Sigismond

SurrealDB fast tracked our progress with all its features. Graph links + Record links + Full text search + Vector embeddings and Vector search + Surreal WASM for offline-ability... just name it!!!! Thanks Surreal team for making it happen!!!!

Lucy Egan's avatar

Lucy Egan

Aspire

We replaced 5 backend tools with SurrealDB and scaled to 700,000 users in 8 hours.

@KenjiSuza's avatar

@KenjiSuza

Fantastic! Graphrag, etc handles it all. Solid and fast

Chris Bruce's avatar

Chris Bruce

I know people love Supabase and Convex is blowing up. But I think SurrealDB is gonna be the real killer. More modern apps really should be using more graph databases as applications need to provide for more and more complex relationships.

@BeniaminDudek's avatar

@BeniaminDudek

So much easier to write advanced queries compared to SQL. Queries are actually readable! Community on Discord is also very helpful and includes SurrealDB developers.

@AjaySahoo's avatar

@AjaySahoo

Surrealist's way of exploring complex data feels simple as it's intuitive, fast, and removes the need for complex queries.

Or Weis

CEO & Co-founder, Permit.io

SurrealDB is enabling the next phase of our product. It gives us the flexibility and graph-native capabilities we need to keep innovating for customers at every size and industry.

Trevor Parscal's avatar

Trevor Parscal

I'm certainly enjoying that I can replace hundreds of lines of Postgres trigger and function code with a dozen characters in a DEFINE statement in SurrealDB.

Gabriel Manor

VP Marketing & DevRel, Permit.io

With SurrealDB, Permit created the fastest and most comprehensive Google-Zanzibar influenced ReBAC solution in the market, setting the standard for quality and performance in relationship-based access control decisions.

Albert Marashi's avatar

Albert Marashi

SurrealDB has allowed our team to focus more on product and iteration without worrying about database constraints. We can do literally everything we need in SurrealDB.

@UnchainedAlgo's avatar

@UnchainedAlgo

I initially explored a more traditional stack: Neo4j for the graph database, RabbitMQ for a task queue, and Postgres with extensions for vector search. However, I realised SurrealDB could cover all of these needs, allowing me to consolidate the backend into a single dependency.

Colman Yau

VP of Engineering, PolyAI

The SurrealDB integration was seamless and delivered performance on par with our internal stack. It proves that enterprises can bring their own knowledge base without sacrificing speed, quality, or control.

Sigismond's avatar

Sigismond

SurrealDB fast tracked our progress with all its features. Graph links + Record links + Full text search + Vector embeddings and Vector search + Surreal WASM for offline-ability... just name it!!!! Thanks Surreal team for making it happen!!!!

Lucy Egan's avatar

Lucy Egan

Aspire

We replaced 5 backend tools with SurrealDB and scaled to 700,000 users in 8 hours.

@KenjiSuza's avatar

@KenjiSuza

Fantastic! Graphrag, etc handles it all. Solid and fast

Chris Bruce's avatar

Chris Bruce

I know people love Supabase and Convex is blowing up. But I think SurrealDB is gonna be the real killer. More modern apps really should be using more graph databases as applications need to provide for more and more complex relationships.

@BeniaminDudek's avatar

@BeniaminDudek

So much easier to write advanced queries compared to SQL. Queries are actually readable! Community on Discord is also very helpful and includes SurrealDB developers.

@AjaySahoo's avatar

@AjaySahoo

Surrealist's way of exploring complex data feels simple as it's intuitive, fast, and removes the need for complex queries.

Or Weis

CEO & Co-founder, Permit.io

SurrealDB is enabling the next phase of our product. It gives us the flexibility and graph-native capabilities we need to keep innovating for customers at every size and industry.

Trevor Parscal's avatar

Trevor Parscal

I'm certainly enjoying that I can replace hundreds of lines of Postgres trigger and function code with a dozen characters in a DEFINE statement in SurrealDB.

Gabriel Manor

VP Marketing & DevRel, Permit.io

With SurrealDB, Permit created the fastest and most comprehensive Google-Zanzibar influenced ReBAC solution in the market, setting the standard for quality and performance in relationship-based access control decisions.

Albert Marashi's avatar

Albert Marashi

SurrealDB has allowed our team to focus more on product and iteration without worrying about database constraints. We can do literally everything we need in SurrealDB.

GET STARTED

Start building with the context layer

Object storage to agent memory. A single stack, a single transaction, zero glue code.