MCPcopy Index your code
hub / github.com/FerretDB/FerretDB

github.com/FerretDB/FerretDB @v2.7.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.7.0 ↗ · + Follow
1,821 symbols 8,939 edges 443 files 1,279 documented · 70% updated 31d agov2.7.0 · 2025-11-10★ 10,990353 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

FerretDB

[!TIP] Looking for FerretDB v1? It is there.

Go Reference

Go codecov

Security Packages Docs

FerretDB is an open-source alternative to MongoDB. It is a proxy that converts MongoDB 5.0+ wire protocol queries to SQL and uses PostgreSQL with DocumentDB extension as a database engine.

flowchart LR
  A["Any application

Any MongoDB driver"]
  F{{FerretDB}}
  P[(PostgreSQL

DocumentDB extension)]

  A -- "MongoDB protocol

BSON" --> F
  F -- "PostgreSQL protocol

SQL" --> P

Why do we need FerretDB?

MongoDB was originally an eye-opening technology for many of us developers, empowering us to build applications faster than using relational databases. In its early days, its ease-to-use and well-documented drivers made MongoDB one of the simplest database solutions available. However, as time passed, MongoDB abandoned its open-source roots; changing the license to SSPL - making it unusable for many open-source and early-stage commercial projects.

Most MongoDB users do not require any advanced features offered by MongoDB; however, they need an easy-to-use open-source document database solution. Recognizing this, FerretDB is here to fill that gap.

Scope and current state

FerretDB is compatible with MongoDB drivers and popular MongoDB tools. It functions as a drop-in replacement for MongoDB 5.0+ in many cases. Features are constantly being added to further increase compatibility and performance.

We welcome all contributors. See our public roadmap, lists of known differences and supported commands, and contributing guidelines.

Quickstart

Run this command to start FerretDB with PostgreSQL, make sure to update <username> and <password>:

docker run -d --rm --name ferretdb -p 27017:27017 \
  -e POSTGRES_USER=<username> \
  -e POSTGRES_PASSWORD=<password> \
  ghcr.io/ferretdb/ferretdb-eval:2

This command will start a container with FerretDB, pre-packaged PostgreSQL with DocumentDB extension, and MongoDB Shell for quick testing and experiments. However, it is unsuitable for production use cases because it keeps all data inside and loses it on shutdown. See our installation guides for instructions that don't have those problems.

With that container running, you can:

  • Connect to it with any MongoDB client application using the MongoDB URI mongodb://<username>:<password>@127.0.0.1:27017/.
  • Connect to it using the MongoDB Shell by just running mongosh. If you don't have it installed locally, you can run docker exec -it ferretdb mongosh.
  • For PostgreSQL, connect to it by running docker exec -it ferretdb psql -U <username> postgres.

You can stop the container with docker stop ferretdb.

We also provide binaries and packages for various Linux distributions. as well as Go library package that embeds FerretDB into your application. See our documentation for more details.

Building and packaging

[!NOTE] We advise users not to build FerretDB themselves. Instead, use binaries, Docker images, or packages provided by us.

FerretDB could be built as any other Go program, but a few generated files and build tags could affect it. See there for more details.

Managed FerretDB at cloud providers

Community

If you want to contact FerretDB Inc., please use this form.

Extension points exported contracts — how you extend this code

Response (Interface)
go:generate ../../../bin/oapi-codegen --config=./oapi-config.yml ./openapi.json Response types are used to represent the [8 …
internal/dataapi/api/api.go
Handler (Interface)
Handler is a common interface for [handler.Handler] and [proxy.Handler] (but not for [Middleware]). [3 implementers]
internal/handler/middleware/handler.go
Provider (Interface)
Provider is implemented by shared data sets that provide documents. [1 implementers]
integration/shareddata/provider.go
LazyString (FuncType)
LazyString is a lazily evaluated [slog.LogValuer] for string.
internal/util/logging/lazy.go
AnyDocument (Interface)
(no doc)
tools/checkswitch/testdata/bson/bson.go
ServerInterface (Interface)
ServerInterface represents all server handlers. [2 implementers]
internal/dataapi/api/gen.go
BenchmarkProvider (Interface)
BenchmarkProvider is implemented by shared data sets that provide documents for benchmarks. [1 implementers]
integration/shareddata/benchmark_provider.go
Probe (FuncType)
Probe should return true on success and false on failure (or context cancellation). It may log additional information if
internal/util/debug/debug.go

Core symbols most depended-on inside this repo

Make
called by 465
internal/mongoerrors/mongoerrors.go
Name
called by 447
integration/shareddata/provider.go
Run
called by 409
internal/handler/middleware/handler.go
Get
called by 259
internal/util/state/provider.go
Error
called by 238
internal/mongoerrors/error.go
Error
called by 181
internal/dataapi/api/gen.go
Remove
called by 125
integration/shareddata/shareddata.go
Setup
called by 124
integration/setup/setup.go

Shape

Function 1,244
Method 394
Struct 154
TypeAlias 13
Interface 8
Class 4
FuncType 4

Languages

Go96%
TypeScript4%

Modules by API surface

internal/documentdb/documentdb_api_internal/documentdb_api_internal.go245 symbols
internal/documentdb/documentdb_api_catalog/documentdb_api_catalog.go121 symbols
internal/dataapi/api/gen.go78 symbols
website/static/codapi/snippet.js66 symbols
internal/documentdb/documentdb_core/documentdb_core.go49 symbols
internal/documentdb/documentdb_api/documentdb_api.go41 symbols
integration/integration.go28 symbols
integration/aggregate_compat_test.go27 symbols
integration/commands_administration_test.go26 symbols
integration/basic_test.go22 symbols
internal/handler/session/registry.go20 symbols
integration/update_field_compat_test.go17 symbols

Dependencies from manifests, versioned

4d63.com/gocheckcompilerdirectivesv1.3.0 · 1×
4d63.com/gochecknoglobalsv0.2.2 · 1×
cloud.google.com/gov0.121.6 · 1×
cloud.google.com/go/compute/metadatav0.8.0 · 1×
dario.cat/mergov1.0.2 · 1×
github.com/4meepo/tagalignv1.4.2 · 1×
github.com/Abirdcfly/dupwordv0.1.3 · 1×
github.com/AlekSi/lazyerrorsv0.0.0-2025110212032 · 1×
github.com/AlekSi/pointerv1.2.0 · 1×
github.com/Antonboom/errnamev1.0.0 · 1×
github.com/Antonboom/nilnilv1.0.1 · 1×

Datastores touched

AllCollection · 1 repos
doesnotexistCollection · 1 repos
nonexistentCollection · 1 repos
(mongodb)Database · 1 repos
postgresDatabase · 1 repos
ferretdbDatabase · 1 repos
ferretdbDatabase · 1 repos
adminDatabase · 1 repos

For agents

$ claude mcp add FerretDB \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact