Database
Below is a restructured overview on connecting a database to enable features such as Chat Link Sharing within your application. This guide offers two main database options—Serverless Postgres (the default) and MongoDB Atlas—along with the relevant setup steps.
Selecting a Database
1. Serverless Postgres (Default Option)
Where to Host: Compatible with platforms like Vercel, Neon, etc.
Why Use It: Suitable if you require a simple, managed SQL environment.
Connection String Example:
postgres://USER:[email protected]/SOMEDB?pgbouncer=true&connect_timeout=15
2. MongoDB Atlas (Alternative Option)
Recommended for: Developers who need a fully managed service with advanced capabilities (scalability, security, analytics).
What Sets It Apart:
Integrated vector storage and search.
Developer-friendly tooling through Atlas App Services, Atlas Search, Charts, and Data Federation.
Connection String Example:
mongodb://USER:[email protected]/DATABASE-NAME?retryWrites=true&w=majority
Environment Variables
Make sure to define your chosen database credentials through environment variables. The names for each are listed below:
Postgres
POSTGRES_PRISMA_URL
postgres://USER:[email protected]/SOMEDB?pgbouncer=true&connect_timeout=15
POSTGRES_URL_NON_POOLING (optional)
A non-pooling Postgres URL for special use cases
MongoDB
MDB_URI
mongodb://USER:[email protected]/DATABASE-NAME?retryWrites=true&w=majority
MongoDB Atlas + Prisma
If you choose MongoDB Atlas, you will need to update the Prisma schema (src/server/prisma/schema.prisma) so that the datasource points to MongoDB:
Initial Setup
After setting the environment variables and modifying the schema file (if using MongoDB), run:
This command creates or updates the database schema.
Helpful Links
Prisma Docs: https://www.prisma.io/docs/
MongoDB Atlas: https://www.mongodb.com/atlas/database
Atlas App Services: https://www.mongodb.com/docs/atlas/app-services/
Atlas Vector Search: https://www.mongodb.com/products/platform/atlas-vector-search/
Atlas Data Federation: https://www.mongodb.com/products/platform/atlas-data-federation