Skip to content

Commit

Permalink
Adding MongoDB setup instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
ajosh0504 committed Feb 24, 2025
1 parent cc8b36b commit 70de8e4
Show file tree
Hide file tree
Showing 51 changed files with 205 additions and 49 deletions.
2 changes: 1 addition & 1 deletion docs/10-key-concepts/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Key Concepts",
"position": 1,
"position": 10,
"link": {
"type": "generated-index",
"description": "Learn the basics of AI agents"
Expand Down
17 changes: 0 additions & 17 deletions docs/20-getting-started/1-mongodb-setup.mdx

This file was deleted.

8 changes: 0 additions & 8 deletions docs/20-getting-started/_category_.json

This file was deleted.

67 changes: 67 additions & 0 deletions docs/20-mongodb-atlas/1-create-account.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import Link from "@site/src/components/Link";
import Screenshot from "@site/src/components/Screenshot";

# 👐 Create your account

:::caution
If you are doing this lab as part of a MongoDB GenAI Developer Day, at this point you should already have a free cluster, so you can skip this step and continue <a href="../dev-env/dev-env-setup">setting up the dev environment</a> for the lab.

If you don't have a cluster yet, follow the steps below to create one.
:::

In this lab, you will learn how to use MongoDB Atlas Vector Search.

To use MongoDB Atlas, you will need to start by creating an account.

<details>
<summary> 🦹‍♀️ If you already have an Atlas account, you can use it by creating a new project.</summary>

First, log into <Link to="https://account.mongodb.com/">MongoDB Atlas</Link> using your existing credentials.

<Screenshot url="https://account.mongodb.com" src={"img/screenshots/20-mongodb-atlas/1-create-account/3-login.png"} alt="Login form" />

## Create a new Atlas project

Once you're in Atlas, open the dropdown on the left-top corner of the page and select **New Project**.

<Screenshot url="https://cloud.mongodb.com" src={"img/screenshots/20-mongodb-atlas/1-create-account/4-new-project.png"} alt="Create new project" />

Enter a name for your project and click **Next**.

<Screenshot url="https://cloud.mongodb.com" src={"img/screenshots/20-mongodb-atlas/1-create-account/5-new-project-name.png"} alt="Create new project" />

On the next page, you can leave the current user as the project owner, and click **Create Project**.

Once the project is ready, continue the workshop from the <a href="./create-cluster">**Deploy a database cluster**</a> section.
</details>

## Sign up for MongoDB Atlas

:::caution
Some corporate email accounts have restrictions on their use with Atlas. Consider using your personal account instead.
:::


Go to the <Link to="http://mongodb.com/try">MongoDB website</Link> and create your account. You will be greeted by a form similar to the one below.

<Screenshot url="https://cloud.mongodb.com" src={"img/screenshots/20-mongodb-atlas/1-create-account/1-form.png"} alt="Account creation form" />

:::info
If you are doing this lab at an event, you should use the same email address you used to register for the event.
:::

Complete the form and click the "Create Your Atlas Account" button.

## Verify your email address

You will receive an email from MongoDB asking you to verify your email address. Click the link in the email to verify your email address.

<Screenshot url="https://cloud.mongodb.com" src={"img/screenshots/20-mongodb-atlas/1-create-account/2-verify-email.png"} alt="Verify your email address" />

:::caution
If you haven't received the email within two minutes, check your spam folder.
:::

## Finish the onboarding

You will be redirected to the MongoDB Atlas onboarding wizard. Fill in the form and click "Finish" to continue.
67 changes: 67 additions & 0 deletions docs/20-mongodb-atlas/2-create-cluster.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import Screenshot from "@site/src/components/Screenshot";

# 👐 Deploy a database cluster

Now that you have a MongoDB Atlas account, you can create your first cluster for free.

It won't expire, and you will have a 500 MB storage limit. This is enough to get started with MongoDB Atlas.

## Create a new cluster

From the overview page, click on **+ Create**.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/20-mongodb-atlas/2-create-cluster/1-overview.png" alt="Overview screenshot" />

:::note
If you just created your account, you will automatically be redirected to the cluster creation page and can skip this step.
:::

You will be redirected to the cluster creation page. Here you can choose the cloud provider and region where your data will be stored. You can also choose the type of cluster you want to create. For this tutorial, we will use the free tier.

1. For the cluster tier, pick **M0**, which is the free tier.
1. **Uncheck the _Automate security setup_ box.** You will set up security manually in the next steps.
1. **Uncheck the _Preload sample dataset_ box.** You will import a dataset later in this lab.
1. Select your favorite cloud provider and the region closest to you.
1. Finally, click on **Create Deployment**.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/20-mongodb-atlas/2-create-cluster/2-deploy-database.png" alt="Create cluster screenshot" />

## Security quickstart

By default, your MongoDB Atlas deployment is completely locked down. You need to configure the network settings and create a user to access your database.

While your deployment is being provisioned, you will see the security quickstart dialog.

### Network access

First, you need to **Allow Access from Anywhere**. You will see a field prepopulated with the IP address `0.0.0.0/0`. This means that you can connect to your database from any IP address, including the virtual environment you will use for this lab.

Click **Add IP Address** to add it to the network allowlist.

:::note
If you don't see a button to allow access from anywhere, you should close the dialog and go to the **Network Access** tab under the **Security** section in the left sidebar. Click on **Add IP Address**, add `0.0.0.0/0`, and click **Confirm**.
:::

:::caution
It is dangerous to expose your database to the entire world. Never do this in a real production environment.
:::

### Database user

Next, you need to create a database user. Pick any username and password you want. They will be used when you want to connect to your database. Click **Create Database User** to create the user.

Atlas might create the user automatically for you if you have just created your account. In this case, the username and password will match your Atlas account credentials.

:::tip
Make sure to remember your username and password. You will need them later.

For the sake of this workshop, it might be preferable to use a simple password that you'll remember over a more secure one.

<strong>Don't use any special characters in your password</strong>. Even though MongoDB allows some special characters, they might not work well with the tools you'll use later in this workshop.
:::

## That's all!

That's all! You now have a new database cluster. If everything goes well, you should see your newly created cluster on the **Overview** page.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/20-mongodb-atlas/2-create-cluster/3-database-deployment.png" alt="Create cluster screenshot" />
27 changes: 27 additions & 0 deletions docs/20-mongodb-atlas/3-connection-string.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Screenshot from "@site/src/components/Screenshot";

# 👐 Get your connection string

To connect to your cluster later on, you will need to get the connection string for your cluster.

In the Atlas UI, navigate to the **Overview** page. In the **Clusters section**, select your cluster and click **Connect**.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/20-mongodb-atlas/3-connection-string/1-connect-button.png" alt="Connect button" />

A modal will display several ways to connect to your database. Select **Drivers**.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/20-mongodb-atlas/3-connection-string/2-connect-modal.png" alt="Connect modal" />

Look for your connection string. It should look something like this:

```
mongodb+srv://<username>:<password>@<cluster-url>/?retryWrites=true&w=majority&appName=Cluster0
```

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/20-mongodb-atlas/3-connection-string/3-connection-string.png" alt="Get connection string" />

Click the copy button next to your connection string to copy it to your clipboard. Paste the connection string somewhere safe. You will need this connection string several times throughout this training.

:::tip
Don't forget to replace `<db_password>` with the password you set when you created the cluster.
:::
8 changes: 8 additions & 0 deletions docs/20-mongodb-atlas/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "MongoDB Atlas",
"position": 20,
"link": {
"type": "generated-index",
"description": "Create a MongoDB Atlas account and deploy a free cluster"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import Screenshot from "@site/src/components/Screenshot";

Navigate to [this](https://github.com/codespaces/new/mongodb-developer/genai-devday-notebooks?quickstart=1) link. Click the **Resume this codespace** button to resume the code space you created previously.

<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-getting-started/2-dev-env-setup/1-resume-codespace.png" alt="Resume codespace" />
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/1-resume-codespace.png" alt="Resume codespace" />

Give the codespace a few seconds to restart. When files appear under the Explorer, click the file named `ai-agents-lab.ipynb`. This is the Jupyter Notebook you will be using throughout this lab.

<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-getting-started/2-dev-env-setup/3-nav-notebook.png" alt="Navigate to the notebook" />
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/3-nav-notebook.png" alt="Navigate to the notebook" />
</details>

:::tip
In this lab, we will be using Jupyter Notebooks, which is an interactive Python environment. If you are new to Jupyter Notebooks, use [this](https://mongodb-developer.github.io/vector-search-lab/docs/getting-started/jupyter-notebooks) guide to familiarize yourself with the environment.
In this lab, we will be using Jupyter Notebooks, which is an interactive Python environment. If you are new to Jupyter Notebooks, use [this](https://mongodb-developer.github.io/vector-search-lab/docs/dev-env/jupyter-notebooks) guide to familiarize yourself with the environment.
:::

## Option 1: GitHub Codespaces
Expand All @@ -30,17 +30,17 @@ Let it run for a few seconds as it prepares your environment. It will clone the

In the left navigation bar of the IDE, click on the file named `ai-agents-lab.ipynb` to open the Jupyter Notebook for this lab.

<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-getting-started/2-dev-env-setup/3-nav-notebook.png" alt="Navigate to the notebook" />
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/3-nav-notebook.png" alt="Navigate to the notebook" />

Next, select the Python interpreter by clicking **Select Kernel** at the top right of the IDE.

<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-getting-started/2-dev-env-setup/4-select-kernel.png" alt="Select kernel" />
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/4-select-kernel.png" alt="Select kernel" />

In the modal that appears, click **Python environments...** and select the interpreter that is marked as **Recommended** or **Global Env**.

<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-getting-started/2-dev-env-setup/5-python-env-modal.png" alt="Select Python Environments" />
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/5-python-env-modal.png" alt="Select Python Environments" />

<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-getting-started/2-dev-env-setup/6-select-recommended.png" alt="Select recommended interpreter" />
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/6-select-recommended.png" alt="Select recommended interpreter" />

That's it! You're ready for the lab!

Expand Down Expand Up @@ -86,4 +86,4 @@ jupyter notebook

* In the browser tab that pops up, open the file named `ai-agents-lab.ipynb`.

<Screenshot url="localhost:8888/tree" src="img/screenshots/20-getting-started/2-dev-env-setup/7-jupyter-notebook.png" alt="Jupyter Notebook" />
<Screenshot url="localhost:8888/tree" src="img/screenshots/30-dev-env/1-dev-env-setup/7-jupyter-notebook.png" alt="Jupyter Notebook" />
File renamed without changes.
8 changes: 8 additions & 0 deletions docs/30-dev-env/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Dev Environment",
"position": 30,
"link": {
"type": "generated-index",
"description": "Setup the dev environment and prerequisites"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# 👐 Import data into MongoDB

:::caution
If you are doing this lab as part of a MongoDB GenAI Developer Day, at this point you should already have the data required for this lab in your MongoDB cluster, so you can skip this step.

If you haven't imported the data yet, follow the steps below to do so.
:::

The documentation agent has two tools- a vector search tool to retrieve information from documentation to answer questions, and another tool to get the content from specific documentation pages for summarization.

Let's import the data required by these tools into two MongoDB collections. This is as simple as making a `POST` request to a serverless function that we have created for you.
Expand All @@ -14,10 +8,12 @@ Run the cells under the **Step 2: Import data** section in the notebook to impor

To verify that the data has been imported into your MongoDB cluster, navigate to the **Overview** page in the Atlas UI. In the **Clusters section**, select your cluster and click **Browse collections**.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/30-agent-tools/2-import-data/1-browse-collections.png" alt="Browse collections" />
<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/40-import-data/1-import-data/1-browse-collections.png" alt="Browse collections" />

Ensure that you see a database called _mongodb_genai_devday_, and two collections namely _mongodb-docs_ and _mongodb-docs-embedded_ under it. Note the number and format of documents in both the collections.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/30-agent-tools/2-import-data/2-chunked-collection.png" alt="Chunked collection" />
The _mongodb-docs-embedded_ collection chunked versions of documents in the _mongodb-docs_ collection, and hence has a higher document count.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/40-import-data/1-import-data/2-full-collection.png" alt="Chunked collection" />

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/30-agent-tools/2-import-data/3-full-collection.png" alt="Full collection" />
<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/40-import-data/1-import-data/3-chunked-collection.png" alt="Full collection" />
8 changes: 8 additions & 0 deletions docs/40-import-data/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Import Data",
"position": 40,
"link": {
"type": "generated-index",
"description": "Import datasets into your MongoDB Atlas cluster"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ vs_collection.create_search_index(model=model)

To verify that the index was created, navigate to the **Overview** page in the Atlas UI. In the **Clusters section**, select your cluster and click **Browse collections**.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/30-agent-tools/3-create-vector-search-index/1-browse-collections.png" alt="Browse collections" />
<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/50-agent-tools/2-create-vector-search-index/1-browse-collections.png" alt="Browse collections" />

Navigate to **Search Indexes** for the _mongodb-docs-embedded_ collection in the _mongodb_genai_devday_ database.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/30-agent-tools/3-create-vector-search-index/2-nav-search-indexes.png" alt="Navigate to search indexes" />
<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/50-agent-tools/2-create-vector-search-index/2-nav-search-indexes.png" alt="Navigate to search indexes" />

The index is ready to use once the status changes from **PENDING** to **READY**.

<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/30-agent-tools/3-create-vector-search-index/3-index-ready.png" alt="Index ready to use" />
<Screenshot url="https://cloud.mongodb.com" src="img/screenshots/50-agent-tools/2-create-vector-search-index/3-index-ready.png" alt="Index ready to use" />
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Create Agent Tools",
"position": 6,
"position": 50,
"link": {
"type": "generated-index",
"description": "Create tools for the agent"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Create Agent",
"position": 7,
"position": 60,
"link": {
"type": "generated-index",
"description": "Orchestrate an AI agent using LangGraph"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Add Memory to the Agent",
"position": 8,
"position": 70,
"link": {
"type": "generated-index",
"description": "Add short-term memory to the agent"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 70de8e4

Please sign in to comment.