Hanzo
Hanzo Skills Reference

Hanzo DocDB

DocDB is a MongoDB-compatible document database server. It is a proxy that converts MongoDB 5.0+ wire protocol queries to SQL, using PostgreSQL with the DocumentDB extension as the storage engine. ...

Overview

DocDB is a MongoDB-compatible document database server. It is a proxy that converts MongoDB 5.0+ wire protocol queries to SQL, using PostgreSQL with the DocumentDB extension as the storage engine. This is a full server, not a client library. Any MongoDB driver or tool can connect to it directly.

Fork of FerretDB. Repo: hanzoai/documentdb, branch: main.

Quick reference

ItemValue
Modulegithub.com/hanzoai/docdb
Binarydocdb
Go1.26+
Repogithub.com/hanzoai/documentdb
Branchmain
LicenseApache-2.0
Wire protocolMongoDB 5.0+
BackendPostgreSQL + DocumentDB extension
Default port27017
Docker imageghcr.io/hanzoai/docdb-eval:2

Architecture

Application (any MongoDB driver)
    |
    | MongoDB wire protocol (BSON)
    v
  DocDB proxy (this project)
    |
    | PostgreSQL protocol (SQL)
    v
  PostgreSQL + DocumentDB extension

Quick start (Docker)

docker run -d --rm --name docdb -p 27017:27017 \
  -e POSTGRES_USER=myuser \
  -e POSTGRES_PASSWORD=mypass \
  ghcr.io/hanzoai/docdb-eval:2

Connect with any MongoDB client:

mongosh "mongodb://myuser:mypass@127.0.0.1:27017/"

Or connect to the embedded PostgreSQL:

docker exec -it docdb psql -U myuser postgres

Building from source

go build -o docdb ./cmd/docdb
./docdb --listen-addr=:27017 --postgresql-url=postgres://user:pass@localhost:5432/dbname

Go library embedding

DocDB can be embedded in Go applications:

import "github.com/hanzoai/docdb/v2/docdb"

Key features

  • Drop-in MongoDB replacement for most 5.0+ workloads
  • Uses PostgreSQL as the storage backend (ACID, proven reliability)
  • Any MongoDB driver or tool works (mongosh, Compass, pymongo, etc.)
  • SCRAM authentication
  • Prometheus metrics endpoint
  • OpenTelemetry tracing
  • MCP (Model Context Protocol) integration
  • Health/readiness endpoints

Project structure

PathPurpose
cmd/docdb/Main binary entry point
cmd/envtool/Development environment tool
docdb/Embeddable library package
internal/Core implementation (handlers, backends, wire protocol)
integration/Integration test suite
build/Build configurations, certs, Docker deps

Build and test

# Build
go build ./cmd/docdb

# Unit tests
go test ./...

# Integration tests (requires PostgreSQL)
go test ./integration/...

# Task runner (alternative to make)
task test
task build

How is this guide?

Last updated on

On this page