FerretDB is an open-source proxy that enables applications using MongoDB drivers to work with PostgreSQL as a backend, without requiring code changes. It was created in response to MongoDB’s shift away from open-source licensing with the SSPL, leaving many developers without a viable, truly open document database. FerretDB implements the MongoDB 5.0+ wire protocol and translates BSON queries into SQL via PostgreSQL’s DocumentDB extension, making it a drop-in replacement for MongoDB in many use cases. This solution is ideal for teams seeking to avoid vendor lock-in, reduce licensing costs, or maintain compliance with open-source principles while retaining MongoDB’s familiar API and tooling.
What You Get
- MongoDB protocol compatibility - Supports MongoDB 5.0+ wire protocol, allowing existing MongoDB drivers and clients (including mongosh, Compass, and ORMs) to connect without modification.
- PostgreSQL backend with DocumentDB extension - Uses PostgreSQL as the underlying database engine enhanced with a DocumentDB extension to handle JSON/BSON document storage and queries natively.
- Drop-in replacement capability - Functions as a direct substitute for MongoDB in development and many production environments, requiring no changes to application code.
- Docker-based quickstart - Provides pre-packaged Docker images with PostgreSQL and DocumentDB extension, enabling immediate testing via a single docker run command.
- Go library embedding - Offers a Go package (github.com/FerretDB/FerretDB/v2/ferretdb) to embed FerretDB directly into Go applications for custom deployments.
- Managed cloud offerings - Available as a managed service on Civo, Tembo, Elestio, Cozystack, and FerretDB Cloud for production deployments without infrastructure overhead.
Common Use Cases
- Building a MongoDB-backed SaaS app with open-source compliance - A startup developing a customer portal using Mongoose and Node.js can switch from MongoDB to FerretDB to avoid SSPL licensing restrictions while keeping all existing drivers and queries intact.
- Migrating legacy MongoDB applications without rewrite - An enterprise with a decade-old MongoDB application can replace the database layer with FerretDB to reduce licensing costs and gain full control over data storage, without rewriting application logic.
- Developing on MongoDB but needing PostgreSQL reliability - A team wants the flexibility of document storage but requires PostgreSQL’s ACID guarantees, point-in-time recovery, and robust tooling — FerretDB delivers both without sacrificing developer experience.
- DevOps teams managing multi-cloud deployments - Organizations using FerretDB can deploy the same database interface across AWS, GCP, or on-premises while leveraging PostgreSQL’s ecosystem for backups, monitoring, and scaling.
Under The Hood
FerretDB is a database proxy that emulates the MongoDB wire protocol while transparently storing data in PostgreSQL or YugabyteDB, enabling organizations to use familiar MongoDB APIs with a robust relational backend. It is built with a monolithic yet modular architecture that emphasizes clear separation of concerns and extensibility.
Architecture
FerretDB adopts a structured monolithic design with well-defined layers and components for handling client connections, protocol translation, and database interactions.
- Strong emphasis on modularity and separation of concerns across core modules
- Middleware-based request processing enables flexible and extensible handling of operations
- Configuration-driven setup supports environment-specific customizations and plugin integrations
- Clear layering between protocol handling, query translation, and storage abstraction
Tech Stack
Built entirely in Go, FerretDB leverages modern tooling and testing practices to maintain compatibility and performance.
- Developed in Go with a focus on concurrency, database abstraction, and protocol handling
- Relies heavily on PostgreSQL driver and MongoDB wire protocol implementations for core functionality
- Uses Taskfile, Docker, and CI/CD pipelines to support automation and deployment workflows
- Comprehensive test suite includes unit, integration, and compatibility tests for MongoDB operations
Code Quality
Code quality in FerretDB is well-maintained with a strong emphasis on testing, consistency, and error handling.
- Extensive test coverage across multiple layers ensures reliability and correctness
- Standard Go error handling patterns with error wrapping and contextual logging practices
- Consistent code style and linting support maintainability and readability
- Some technical debt indicators suggest opportunities for improved modularity and documentation clarity
What Makes It Unique
FerretDB introduces a novel approach to database interoperability by bridging MongoDB APIs with PostgreSQL storage.
- Offers seamless translation of MongoDB operations to PostgreSQL without requiring application changes
- Provides a unique solution for organizations seeking MongoDB-like APIs with relational database benefits
- Supports extensibility through environment-specific configurations and plugin architecture
- Enables migration paths for MongoDB users to adopt PostgreSQL without extensive refactoring