Skip to main content

FerretDB

FerretDB is an open-source database compatibility layer that translates MongoDB wire protocol queries to PostgreSQL operations to provide MongoDB-compatible workloads on top of PostgreSQL (databases).

  • MongoDB wire protocol compatibility layer running on PostgreSQL (databases)
  • Transforms MongoDB queries and commands into Structured Query Language (SQL) for PostgreSQL backends (data access / query translation)
  • Provides MongoDB-like collections and documents backed by relational storage (data modeling)
  • Targets use cases where MongoDB workloads need to run in PostgreSQL environments or avoid proprietary database engines (database portability)
  • Implements a subset of MongoDB features with a focus on correctness and observability over emulation of storage internals (database interoperability)

More About FerretDB

FerretDB is an open-source compatibility layer that enables applications using the MongoDB wire protocol (database protocol compatibility) to run against PostgreSQL as the underlying data store (relational databases). It addresses the problem space where teams want MongoDB-style document APIs and tooling while standardizing operationally on PostgreSQL or preferring an open-source relational database backend. Instead of storing data in a native document engine, FerretDB receives MongoDB client requests and translates them into SQL queries and operations executed by PostgreSQL.

At a technical level, FerretDB listens for MongoDB wire protocol traffic (database protocol handling), parses commands such as inserting documents, querying collections, or running aggregations, and maps them to equivalent PostgreSQL constructs. Collections and documents are represented in PostgreSQL tables and columns, typically leveraging JSONB or related data types where appropriate (schema-flexible storage). The project focuses on correctness of query behavior and compatibility with MongoDB drivers and tools within the subset of features it supports, rather than reproducing MongoDB’s storage internals.

In enterprise environments, FerretDB can be positioned as a bridge between existing MongoDB-based application code and PostgreSQL-centric infrastructure (database platform alignment). This can be relevant for organizations standardizing on PostgreSQL for operational, licensing, or governance reasons while still needing to support MongoDB-compatible workloads. Application teams can keep using established MongoDB drivers, query semantics, and some ecosystem tools, while database operations teams run and manage PostgreSQL clusters using existing skills, monitoring, and backup processes.

From an architectural perspective, FerretDB runs as a separate service between MongoDB clients and PostgreSQL servers (middleware / proxy pattern). It does not replace PostgreSQL; instead, it relies on a configured PostgreSQL instance for persistence, indexing, and query execution. Administrators configure FerretDB to connect to one or more PostgreSQL backends, manage access credentials, and tune database parameters at the PostgreSQL layer. Because it uses the MongoDB wire protocol, many standard MongoDB drivers in various programming languages can connect without code changes, within the scope of supported operations.

For interoperability, FerretDB operates at the protocol and query translation layer, which allows it to fit into environments where MongoDB-compatible tools, ORMs, or client libraries are already in use (developer tooling compatibility). At the same time, PostgreSQL-native tooling for backup, replication, observability, and security remains applicable because the actual data resides in PostgreSQL. In enterprise taxonomies, FerretDB can be categorized under database compatibility layers, document-API-on-relational systems, and protocol translation middleware for data platforms.