Dyeink uses MongoDB as its primary database for storing blog posts, user data, and platform metadata. This guide covers setting up MongoDB Atlas and configuring the connection.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/subratomandal/dyeink/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A MongoDB Atlas account (sign up at mongodb.com/cloud/atlas)
- Basic understanding of database concepts
Create MongoDB Atlas Cluster
Create a new cluster
- Log in to MongoDB Atlas
- Click Create to create a new cluster
- Choose your deployment option:
- Shared (Free tier - M0) for development
- Dedicated for production workloads
- Select your cloud provider and region
- Choose a region close to your application servers
- AWS, Google Cloud, or Azure are all supported
- Name your cluster (e.g., “dyeink-production”)
- Click Create Cluster
Configure network access
- Navigate to Network Access in the sidebar
- Click Add IP Address
- For development:
- Click Allow Access from Anywhere (0.0.0.0/0)
- For production:
- Add your server’s specific IP addresses
- Add your deployment platform’s IP ranges (Vercel, Cloudflare Workers, etc.)
Create database user
- Navigate to Database Access
- Click Add New Database User
- Choose Password authentication method
- Set a strong username and password
- Under Database User Privileges, select:
- Read and write to any database for application access
- Or create custom roles for fine-grained control
- Click Add User
Save the username and password securely. You’ll need them for your connection string.
Get connection string
- Navigate to Database and click Connect on your cluster
- Choose Connect your application
- Select Node.js as the driver and appropriate version
- Copy the connection string:
- Replace
<username>and<password>with your database user credentials - Optionally, add the database name after the host:
Enable Data API (Optional)
The MongoDB Data API allows HTTP-based access to your database, useful for serverless deployments.Enable Data API
- In Atlas, navigate to App Services
- Click Create a New App
- Name your app (e.g., “DyeinkAPI”)
- Link it to your cluster
- Click Create
Configure Data API
- In your App Services application, go to HTTPS Endpoints
- Click Data API
- Enable the Data API
- Copy the Data API URL and API Key
- Configure authentication and permissions as needed
Configure Database Indexes
Indexes improve query performance for your blogging platform.Access the Collections
- Navigate to Database > Browse Collections
- Select your database (create one named
dyeinkif it doesn’t exist)
Create recommended indexes
For optimal performance, create these indexes:Posts collection:Users collection:To create indexes via the Atlas UI:
- Select a collection
- Click the Indexes tab
- Click Create Index
- Enter the index definition
- Click Review and Confirm
Environment Configuration
Backend (backend/.env)
Root (.env)
Connection String Parameters
Understand the key parameters in your MongoDB connection string:| Parameter | Description | Recommended Value |
|---|---|---|
retryWrites | Automatically retry failed write operations | true |
w | Write concern (acknowledgment level) | majority |
maxPoolSize | Maximum number of connections in the connection pool | 10 (default) |
minPoolSize | Minimum number of connections to maintain | 0 (default) |
serverSelectionTimeoutMS | Timeout for server selection | 30000 (30s) |
Verification
Monitor in Atlas
- Navigate to Database > Cluster
- Click Metrics to view real-time connection and performance data
- Verify you see active connections from your application
Performance Optimization
Example: Optimized Query
Backup and Recovery
Enable automated backups
- Navigate to Backup in your cluster settings
- For shared clusters (M0), backups are not available (export manually)
- For dedicated clusters (M10+), enable Continuous Cloud Backup
- Configure retention policies and snapshot schedules
Troubleshooting
Connection timeout errors
Connection timeout errors
- Verify your IP address is whitelisted in Network Access
- Check that your database user has correct permissions
- Ensure your connection string is correctly formatted
- Try connecting from a different network to rule out firewall issues
Authentication failed
Authentication failed
- Verify username and password are correct
- Check for special characters in password (they must be URL-encoded)
- Ensure the database user has been created and has appropriate privileges
- Try creating a new database user with a simple password to test
Slow queries
Slow queries
- Check the Performance Advisor for index recommendations
- Review query patterns and add appropriate indexes
- Use
explain()to analyze query execution plans - Consider upgrading to a larger cluster tier
Connection pool exhausted
Connection pool exhausted
- Increase
maxPoolSizein your connection string - Ensure connections are properly closed after use
- Check for connection leaks in your application code
- Monitor connection metrics in Atlas
Security Best Practices
Next Steps
Storage Setup
Configure Cloudflare R2 for image and media storage
Deployment
Deploy your Dyeink platform to production

