# MongoDB Atlas

## Overview

This section outlines how to spin up [MongoDB](https://www.mongodb.com/) Cloud Databases and connect them with Neurelo. While we mention certain cloud providers here, it's important to note that Neurelo is designed to work seamlessly with supported MongoDB databases across any Cloud, Hybrid, On-Prem or Local deployments

{% hint style="info" %}
Reference - [Neurelo Supported Databases and Versions](https://docs.neurelo.com/references/supported-databases)
{% endhint %}

## Get Started with MongoDB Atlas

MongoDB Atlas (<https://www.mongodb.com/atlas/database>) is a managed multi-cloud database service. You can use Atlas free clusters for a small-scale development environment to host your data. Free clusters never expire, and provide access to a [subset](https://www.mongodb.com/docs/atlas/reference/free-shared-limitations/#std-label-atlas-free-tier) of Atlas features

{% hint style="info" %}
MongoDB Atlas offers both a user interface (UI) and a command-line interface (CLI) for accessing its services. Be sure to click on the "Atlas UI" option when using the MongoDB documentation website.
{% endhint %}

* **Sign up:** If you don't already have an account, you can [get started for free with Atlas](https://www.mongodb.com/cloud/atlas/register).
* **MongoDB Atlas Database Service:** Instructions to [create MongoDB Atlas free cluster service](https://www.mongodb.com/docs/atlas/tutorial/deploy-free-tier-cluster/). You must complete following steps:
  * Create an [organization with a project](https://www.mongodb.com/docs/atlas/tutorial/create-atlas-account/#create-an-service-organization-and-project)
  * Create an [active database cluster in your account](https://www.mongodb.com/docs/atlas/tutorial/deploy-free-tier-cluster/#deploy-a-free-cluster)
  * Configure a[ database user in your cluster](https://www.mongodb.com/docs/atlas/tutorial/create-mongodb-user-for-cluster/#manage-the-database-users-for-your-cluster)

## Connection String Formats for Neurelo&#x20;

Neurelo will accept the connection string in either of these formats&#x20;

1. mongodb+srv://<mark style="color:red;">username:password</mark>@cluster0.<mark style="color:red;">cluster</mark>.mongodb.net/<mark style="color:red;">database\_name</mark>&#x20;
2. mongodb://<mark style="color:red;">username</mark>:<mark style="color:red;">password</mark>@<mark style="color:red;">host</mark>:<mark style="color:red;">port</mark>/<mark style="color:red;">database\_name</mark>

You need to replace the **username**, **password**, **host, port, cluster**, and **database\_name** in the above strings as appropriate

## Collect MongoDB connection details from the Atlas UI

To enable communication between Neurelo and your MongoDB database, configure your MongoDB instance on Atlas in your Neurelo project. You will need following information from Atlas Cloud:

* [Log in to Atlas](https://account.mongodb.com/account/login?_ga=2.74544657.2039135292.1706673522-835773854.1705298079).
* Go to the Overview page for your project. If your desired project is not active in the UI, choose the appropriate project from the Projects menu in the top-left navigation panel.
* Select "Databases" from the options in the left navigation panel.
* On the "Database Deployments" page, locate the database deployment (cluster) you wish to connect to, then click on the "Connect" button associated with that deployment.

<figure><img src="https://3406482452-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvzFLT4zSSU6J1uzbt5OF%2Fuploads%2FnSfDEZes8W0csKaVj1KA%2FCleanShot%202024-01-30%20at%2018.23.38%402x.png?alt=media&#x26;token=f2964caf-2002-4a17-a1b5-ff796c47467e" alt=""><figcaption><p>MongoDB Atlas Cloud - Database Deployment View</p></figcaption></figure>

* From the Connect page, select "**Compass**". Copy the connection string from the Compass view as shown (you can use the Copy icon on the right of the string)

<figure><img src="https://3406482452-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvzFLT4zSSU6J1uzbt5OF%2Fuploads%2FZtWE4WmSvDHtcynPuN2M%2FCleanShot%202024-01-30%20at%2018.42.14%402x.png?alt=media&#x26;token=93a59768-163e-4911-9758-84610c63105a" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="danger" %}
Neurelo requires database\_name to be present in the connection string. Atlas Cloud UI does not display the \<database\_name> in the connection string -- you will need to append it to the string.&#x20;
{% endhint %}

## Getting MongoDB database\_name from the Atlas UI

* To find and add the <mark style="color:red;">\<database\_name></mark> in your connection string, go to the "Database Deployments" page in the Atlas UI, and locate the deployment (cluster) you wish to connect to, then click on the "Browse Collections" button associated with that deployment.
* In the Collection view, you will find the list of databases. Copy the database name you wish to connect with Neurelo and append it to your connection string
* In the below screenshot, there is a database called "**nyc\_civil\_service**" on "Cluster0". Use this database name in your connection string.&#x20;
* Your connection string would be -> mongodb+srv://<mark style="color:red;">\<username>:\<password></mark>@cluster0.<mark style="color:red;">\<cluster></mark>.mongodb.net/<mark style="color:red;">nyc\_civil\_service</mark>

<figure><img src="https://3406482452-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvzFLT4zSSU6J1uzbt5OF%2Fuploads%2FKlwFk9pPdhmqUqnXVyBb%2Fdbname.jpeg?alt=media&#x26;token=dc3d562d-64dc-4643-8775-03f5cf5e4217" alt=""><figcaption><p>Atlas Database Deployment page with the list of databases</p></figcaption></figure>

{% hint style="info" %}
**MongoDB Compass:** You can also get the connection string and database name using the MongoDB Compass client -- details [here](https://www.mongodb.com/docs/compass/current/).
{% endhint %}

## Add MongoDB as a Data Source in a Neurelo Project

For each new project in Neurelo, you can utilize the Quick Start feature, a guided wizard for step-by-step onboarding, including [adding a new Data Source](https://docs.neurelo.com/getting-started/starting-your-neurelo-project/step-1-add-a-data-source) like MongoDB Atlas. Additionally, you can create new Data Sources anytime within your project from the left-navigation panel.

### Connecting MongoDB Atlas with a Connection String

1. Login to your Neurelo Dashboard
2. Choose the project where you want to add a new data source or create a new project for this purpose.
3. For new projects, follow the Quick Start Guide and click on "Connect Data Source" button. For existing projects, navigate to "Data Sources" from the left navigation bar in the project and click on the "New" button
4. Access the New Data Source dialog box. Enter the connection string obtained earlier from the MongoDB Atlas UI (and make sure it has *\<database\_name>* added).&#x20;
5. Add Neurelo IP addresses to your [Atlas IP access list](https://www.mongodb.com/docs/atlas/security/add-ip-address-to-list/#manage-the-ip-access-list). The Neurelo IP addresses to use for your project will be displayed in this dialog box.&#x20;

   <div data-gb-custom-block data-tag="hint" data-style="danger" class="hint hint-danger"><p><strong>Allowed inbound IP addresses:</strong> The default setting for Atlas Cloud services does not allow access from all IP ranges. You must add Neurelo's IPs to your allowed list on Atlas Cloud</p></div>
6. After entering the connection details, click on "Test Connection" to verify that Neurelo can successfully connect to MongoDB Atlas. Once the test is successful, click Submit to save the configuration in Neurelo. Please refer to [this page](https://docs.neurelo.com/data-sources/mongodb) for additional information.

<figure><img src="https://3406482452-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvzFLT4zSSU6J1uzbt5OF%2Fuploads%2FhDDKA4Tlt1DDihXzG3sI%2FCleanShot%202024-01-30%20at%2019.14.42%402x.png?alt=media&#x26;token=673187eb-3671-4e0b-82f1-666af04428f1" alt="" width="563"><figcaption><p>New MongoDB Data Source with Connection String in Neurelo</p></figcaption></figure>
