Prep 3: Context and MongoDB
Due Date: Thursday, October 9th at 10:00am
Overview
In recitation on 10/9, we’ll cover the Context tool and MongoDB. We will also walk you through the repository that will serve as the basis for the backend of your project.
Fork the 61040-fa25/concept_backend
repo, making sure to rename it to your desired project name, and giving it an appropriate description.
Follow just the setup section of the README, and you’re done! For your reference, here are the same setup instructions:
Setup (Prep)
0. Fork this repository
First, fork this repository, and rename it to your desired project name, and give a description of your project.
1. Install Deno
Deno is a successor to Node.js (by the same creator, Ryan Dahl) that greatly simplifies tooling, is more secure by default, and is backwards-compatible with the larger ecosystem. Check out Deno’s extensive documentation for various helpful guides on a wide variety of common application needs and integrations.
Note: when importing from npm
packages, prefix with npm:
as in:
import { MongoClient } from "npm:mongo"
For VSCode users, consider also installing the Deno extension and referring to the docs if you’d like to configure behavior.
2. Compile Context
To create a convenient binary, run the following command from the root of the directory:
deno compile -A --output ctx .ctx/context.ts
3. Setup Gemini
Copy or change .env.template
to the environment file: .env
and insert your Gemini API key:
GEMINI_API_KEY=YOUR_KEY_HERE
GEMINI_MODEL=gemini-2.5-flash
You can choose any models using GEMINI_MODEL
, such as gemini-2.5-flash-lite
for faster responses, or gemini-2.5-pro
for higher quality.
You may also edit the ./geminiConfig.json
file to change the parameters according to any of the GenerationConfig options, including turning on/off thinking, limiting tokens, etc.
4. Setup your MongoDB Atlas Cluster (free)
For this project, we’ll be using MongoDB as the database. To get started, use either the slides or the instructions:
Slides
Instructions
- Create your MongoDB Atlas account.
- When selecting a template, choose the free option, M0.
- At the Security Quickstart page, select how you want to authenticate your connection and keep the rest of the defaults. Make sure to allow access to all IPs as shown in this slide.
- Once created, click the CONNECT button, select driver, and copy the srv connection string. If using username and password, the url should look something like this:
mongodb+srv://<username>:<password>@cluster0.p82ijqd.mongodb.net/?retryWrites=true&w=majority
. Make sure to replace username and password with your actual values. - Add your connection url (without
<
and>
) toMONGODB_URL=<connection url>
to your.env
file. - Give your database a name under
DB_NAME=<your database name>
.
5. Install Obsidian
Obsidian is an open-source Markdown editor and personal knowledge management solution. The Context tool does not require use of Obsidian, and you may use any preferred editor, but we highly recommend using Obsidian to navigate your assignment and the generated context to write, view, and structure your prompts and design documents.