Built for Serious Data Layers
An AI-first database framework with built-in skills, powerful privacy modeling, and guardrails that prevent destructive operations.
Declarative Data Modeling
Define your entire data model in a simple, readable format. Specify field types, defaults, required constraints, and indexing — then let MoleculeDB generate everything from API endpoints to storage logic.
atom(
"FileAtom",
[field("name", required=True),
field("path", required=True),
field("size", required=True),
field("owner", required=True,
indexable=index_query_type.EQUALITY),
field("description"),
field("status", default="active")],
[],
{},
)Connected Data
Model real-world relationships between your data types. Edges support direction, cardinality, and automatic lifecycle management — so deleting a parent can cascade, restrict, or orphan related records.
atom(
"MediaAtom",
[field("label", required=True),
field("owner", required=True,
indexable=index_query_type.EQUALITY)],
[edge("MediaFileEdge", "FileAtom",
edge_direction.BOTH)],
{},
)Privacy & Access Control
Build powerful privacy models with chainable access policies. Control exactly who can read what — by ownership, role, group membership, or any custom logic. Policies are evaluated on every read, giving you field-level and record-level privacy out of the box.
def check(schema, data, key, ctx):
ctx_name = ctx.get("name", "")
if ctx_name == "":
return deny("no context provided")
data_owner = data.get("owner", "")
if ctx_name == data_owner:
return allow("owner matched")
return deny("owner mismatch")Data Integrity & Versioning
Every write is automatically versioned, preventing lost updates and enabling full change history. Concurrent writers never silently overwrite each other — conflicts are detected and surfaced immediately.
# Create (version must be 1)
$ atom_cli set --schema FileAtom \
--key photo-001 --version 1 \
--json '{"name":"beach.jpg"}'
# Update (version must be current + 1)
$ atom_cli set --schema FileAtom \
--key photo-001 --version 2 \
--json '{"name":"sunset.jpg"}'
# Conflict! (stale version)
$ atom_cli set ... --version 1
Error: VERSION_CONFLICTAI-First Database Development
MoleculeDB is designed from the ground up for AI agents. Pre-written skills guide LLMs through schema creation, access policy setup, and context configuration — turning complex database tasks into simple, guided workflows. The declarative architecture means AI agents work with high-level definitions instead of raw SQL or imperative code, dramatically reducing the risk of destructive operations like accidental deletes or schema corruption.
# AI agent creates a new schema
/create-atom
> Name: UserProfile
> Fields: name (required), email (required),
> role (default="viewer")
# AI agent adds access control
/create-checker
> Policy: owner-match
> Rule: only the user can read their profile
# AI agent configures auth context
/create-context
> Fields: user_id, roleSecure Identity & Authentication
Every request carries cryptographically signed identity context. Access policies can inspect caller identity, roles, and custom claims — ensuring data access is always authenticated and tamper-proof.
# Config: atom_config.json
{
"backend": "FileSystem",
"context_proto": "./context.proto",
"port": 50051
}
# Pass context with CLI
$ atom_cli get --schema FileAtom \
--key photo-001 --json \
--ctx name=alice \
--ctx role=adminDeveloper-Friendly CLI
Manage your data directly from the command line. Full CRUD, querying, edge operations, and JSON output make development and debugging fast.
# CRUD operations
$ atom_cli set --schema MyData \
--key item-001 --version 1 \
--json '{"title":"Hello"}'
$ atom_cli get --schema MyData \
--key item-001 --json
$ atom_cli delete --schema MyData \
--key item-001
# Query by indexed field
$ atom_cli query --schema MyData \
--field owner --value alice --json
# Edge operations
$ atom_cli set --field MediaFileEdge \
media-001 file-001
$ atom_cli get --field MediaFileEdge \
media-001Same API, Three Backends
MoleculeDB ships with Filesystem, DynamoDB, and Spanner backends. Pick the one that fits your scale and operational model — the gRPC API, schemas, and checkers stay identical.
Every backend implements the same versioned key-value contract with optimistic concurrency control. Filesystem is ideal for local development and tests. DynamoDB gives you a fully managed, AWS-native option. Spanner adds globally-distributed, externally-consistent storage with the option to run managed in Google Cloud or self-hosted.
| Feature | Filesystem | DynamoDB | Spanner |
|---|---|---|---|
| Setup | Drop a directory | AWS account + table | Spanner instance + database |
| Scale | Single host | Horizontal, AWS-managed | Horizontal, globally distributed |
| Consistency | Strong (single host) | Tunable per-request | Strong, externally consistent |
| Concurrency control | File locking | Conditional writes | Read-write transactions |
| Best for | Local dev, tests, single-tenant | Cloud-native, AWS-hosted apps | Multi-region, SQL-queryable, complex schemas |
| Operational model | Filesystem | Managed (capacity units) | Managed or self-hosted (incl. Spanner Omni) |
Filesystem
The default for local development and tests. Writes to a directory on disk, uses file locking for optimistic concurrency, and ships with the binary — nothing to provision.
{
"backend": "FileSystem",
"storage_path": "./molecule_data",
"port": 50051,
"schema_files": ["./MyAtom.star"]
}DynamoDB
Single-table design on Amazon DynamoDB. Conditional writes back the version counter, and tables can be auto-created on first start.
{
"backend": "DynamoDb",
"dynamodb": {
"region": "us-east-1",
"table_name": "atom_storage",
"auto_create_table": true
},
"port": 50051,
"schema_files": ["./MyAtom.star"]
}Spanner
Globally-distributed, externally-consistent SQL storage. Optimistic concurrency uses Spanner read-write transactions instead of conditional DML.
{
"backend": "Spanner",
"spanner": {
"project": "my-project",
"instance": "my-instance",
"database": "atomdb",
"endpoint_url": "http://localhost:9010"
},
"port": 50051,
"schema_files": ["./MyAtom.star"]
}Set endpoint_url to point at the open-source Spanner emulator or a self-hosted Spanner Omni deployment; omit it to use managed Cloud Spanner with Application Default Credentials.
Interested in MoleculeDB?
We're building the next generation of schema-driven data infrastructure. Register to stay updated.