Configure

Learn how to set up the MongoDB database for local development.

Set Up MongoDB

Create a MongoDB instance

Create a free cluster on MongoDB Atlas:

  1. Sign up or sign in.
  2. Create a free shared cluster.
  3. Under Database Access, create a database user.
  4. Under Network Access, add your IP address (or 0.0.0.0/0 for development).
  5. Click ConnectDrivers and copy the connection string.

Run a local MongoDB instance with Docker:

docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:latest

Your connection string is:

mongodb://localhost:27017/aiboilerplate

Update the environment variables

Paste your connection string beside DATABASE_URL in the .env file:

.env
DATABASE_URL=mongodb+srv://username:password@cluster.mongodb.net/dbname
Do not use a production database for local development.

Sync the database

Run the following command to sync the database schema:

pnpm db:push

Test the integration

Open Prisma Studio to confirm everything is connected:

pnpm dev --filter @package/db

Prisma Studio can be accessed at http://localhost:5555.