Firebase & MongoDB Atlas: A Powerful Combo for Rapid App Development

Venkatesh Shanbhag, Zi Wang, and Iman Rahmati

Firebase and MongoDB Atlas are powerful tools developers can use together to build robust and scalable applications. Firebase offers build and runtime solutions for AI-powered experiences, while MongoDB Atlas provides a fully managed cloud database service optimized for generative AI applications.

We’re pleased to announce the release of the Firebase extension MongoDB Atlas, a direct MongoDB connector for Firebase that further streamlines the development process by enabling seamless integration between the two platforms. This extension enables developers to directly interact with MongoDB collections and documents from within their Firebase projects, simplifying data operations and reducing development time.

A direct MongoDB connector, built as a Firebase extension, facilitates real-time data synchronization between Firebase and MongoDB Atlas. This enables data consistency across both platforms, empowering developers to build efficient, data-driven applications using the strengths of Firebase and MongoDB.

MongoDB as a backend database for Firebase applications

Firebase offers a streamlined backend for rapid application development, providing offerings like authentication, hosting, and real-time databases. However, applications requiring complex data modeling, high data volumes, or sophisticated querying often work well with MongoDB’s document store. Integrating MongoDB as the primary data store alongside Firebase addresses these challenges. MongoDB provides a robust document database with a rich query language (MongoDB Query Language), powerful indexing (including compound, geospatial, and text indexes), and horizontal scalability for handling massive datasets. This architecture enables developers to use Firebase’s convenient backend services while benefiting from MongoDB’s powerful data management capabilities. Developers commonly use Firebase Authentication for user management, then store core application data, including complex relationships and large volumes of information, in MongoDB. This hybrid approach combines Firebase’s ease of use with MongoDB’s data-handling prowess.

Furthermore, the integration of MongoDB Atlas Vector Search significantly expands the capabilities of this hybrid architecture. Modern applications increasingly rely on semantic search and AI-driven features, which require efficient handling of vector embeddings. MongoDB Atlas Vector Search enables developers to perform similarity searches on vector data, unlocking powerful use cases

Quick-start guide for Firebase’s MongoDB Atlas extension

With the initial release of the MongoDB Atlas extension in Firebase, we are targeting the extension to perform operations such as findOne, insertOne, and vectorSearch on MongoDB. This blog will not cover how to create a Firebase application but will walk you through creating a MongoDB backend for connecting to MongoDB using our Firebase extension. To learn more about how to integrate the deployed backend into a Firebase application, see the official Firebase documentation.

  1. Install the MongoDB Atlas extension in Firebase.
  • Open the Firebase Extensions Hub.

  • Find and select the MongoDB Atlas extension.

  1. Or use the search bar to find “MongoDB Atlas.”
  • Click on the extension card.

  • Click the “Install” button. You will be redirected to the Firebase console.

  1. On the Firebase console, choose the Firebase project where you want to install the extension.
Image 1. Image of the MongoDB Atlas extension’s installation page.
Screenshot showing the MongoDB Atlas extension's installation page. The page is titled Install and authorize extension.
  1. On the installation page:
  • Review “Billing and Usage.”

  • Review “API Endpoints.”

  • Review the permissions granted to the function that will be created.

  • Configure the extension: Provide the following configuration details:

    • MongoDB URI: The connection string for your MongoDB Atlas cluster

      • Database Name: The name of the database you want to use

      • Collection Name: The name of the collection you want to use

      • Vertex AI Embedding to use: The type of embedding model from Vertex AI

      • Vertex AI LLM model name: The name of the large language model (LLM) model from Vertex AI

      • MongoDB Index Name: The name of the index in MongoDB

      • MongoDB Index Field: The field that the index is created upon

      • MongoDB Embedding Field: The field that contains the embedding vectors

      • LLM Prompt: The prompt that will be sent to the LLM

  1. Click on “Install Extension.”
Image 2. Image of the MongoDB Atlas extension created from Firebase extension hub.
Screenshot of the MongoDB Atlas extension being created from Firebase extension hub.

Once the extension is created, you can interact with it through the associated Cloud Function.

Image 3. Firebase extension created cloud run function
Screenshot of the Firebase extension having created a cloud run function.

In conclusion, the synergy between Firebase extensions and MongoDB Atlas opens up exciting possibilities for developers seeking to build efficient, scalable, AI-powered applications. By using Firebase’s streamlined backend services alongside MongoDB’s robust data management and vector search capabilities, developers can create applications that handle complex data and sophisticated AI functionalities with ease.

The newly introduced Firebase extension for MongoDB Atlas, specifically targeting operations like findOne, insertOne, and vectorSearch, marks a significant step toward simplifying this integration. While this initial release provides a solid foundation, the potential for further enhancements, such as direct connectors and real-time synchronization, promises to further empower developers. As demonstrated through the quick-start guide, setting up this powerful combination is straightforward, enabling developers to quickly harness the combined strength of these platforms.

Ultimately, this integration fosters a more flexible and powerful development environment, enabling the creation of innovative, data-driven applications that meet the demands of modern users.