MongoDB Database Setup
Why MongoDB for LogoAIpro?
MongoDB is the perfect database choice for LogoAIpro because:
- Flexible Schema: Perfect for storing varied logo data, user preferences, and generation history
- Scalability: Handles growing user bases and large logo collections
- JSON-like Documents: Natural fit for JavaScript/Node.js applications
- Cloud-Ready: MongoDB Atlas provides managed hosting
- Performance: Fast queries for logo history, credit tracking, and user analytics
Option 1: MongoDB Atlas (Recommended)
MongoDB Atlas is the easiest way to get started with MongoDB. It provides a free tier perfect for development and small applications.
Step 1: Create MongoDB Atlas Account
- Go to MongoDB Atlas
- Click "Try Free" to create a new account
- Fill in your details and verify your email
- Choose the "Free" tier (M0 Sandbox)
MongoDB Atlas homepage - Click "Try Free" to get started
Create your MongoDB Atlas account with your details
Step 2: Create a Cluster
- After logging in, click "Build a Database"
- Select "M0 Sandbox" (Free tier)
- Choose a cloud provider and region (closest to your users)
- Give your cluster a name (e.g., "logoai-pro-cluster")
- Click "Create Cluster"
MongoDB Atlas dashboard - Click "Build a Cluster" to get started
Select the Free tier (M0 Sandbox) for development
Configure your cluster name and settings, then click "Create Deployment"
Step 3: Create Database User
- In the Atlas dashboard, go to "Database Access"
- Click "Add New Database User"
- Choose "Password" authentication
- Create a username and strong password
- Set privileges to "Read and write to any database"
- Click "Add User"
Choose your connection method - Select "Compass" for GUI access
Step 4: Configure Network Access
- Go to "Network Access" in the Atlas dashboard
- Click "Add IP Address"
- For development: Click "Allow Access from Anywhere" (0.0.0.0/0)
- For production: Add your server's IP address
- Click "Confirm"
Configure network access - Click "Allow Access from Anywhere" for development
Step 5: Get Connection String
- Go to "Clusters" and click "Connect" on your cluster
- Choose "Connect your application"
- Select "Node.js" as the driver
- Copy the connection string
- Replace
<password>with your database user password - Replace
<dbname>with your database name (e.g., "logoai-pro")
Download MongoDB Compass and copy the connection string
mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/logoai-pro?retryWrites=true&w=majorityOption 2: Using MongoDB Compass (Recommended for Development)
MongoDB Compass is the official GUI for MongoDB, making it easy to visualize and manage your LogoAIpro database.
Step 1: Download MongoDB Compass
- Go to MongoDB Compass
- Download the version for your operating system
- Install MongoDB Compass following the setup wizard
- Launch the application
Step 2: Connect to Your MongoDB Atlas Cluster
- Open MongoDB Compass
- Click "New Connection"
- Paste your MongoDB Atlas connection string:
mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/ - Click "Connect"
Your MongoDB Atlas cluster is ready - Click "Connect" to get connection details
Step 3: View Your Data
Once connected, you can browse your LogoAIpro collections:
- users - View user accounts and credit balances
- logos - Browse generated logos and their metadata
- transactions - Track credit purchases and usage
Connection String Configuration
Add your MongoDB connection string to your environment variables:
Environment Variable
Add this to your .env.local file:
# MongoDB Atlas (Cloud)
MONGO_URI=mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/logoai-pro?retryWrites=true&w=majority
# Self-hosted MongoDB
MONGO_URI=mongodb://username:password@localhost:27017/logoai-proDatabase Schema
LogoAIpro automatically creates the following collections:
Database Collections
👥 users
Stores user account information, credit balances, and preferences.
_id
email
credits
createdAt
logos
Stores generated logos with metadata, styles, and settings.
userId
logoUrl
style
createdAt
�� transactions
Tracks credit purchases, usage, and payment history.
userId
type
amount
createdAt
Database Access management - Add and manage database users
Test Database Connection
Verify your MongoDB connection is working:
Test Connection
Start your development server and check the console for connection messages:
npm run dev
# or
pnpm devLook for messages like:
Connected to MongoDB
Database connection establishedTroubleshooting
Common Issues
Connection Timeout
Check your network access settings in MongoDB Atlas and ensure your IP is whitelisted.
Authentication Failed
Verify your username and password are correct in the connection string.
Database Not Found
Ensure the database name in your connection string matches your intended database.
🚫 Permission Denied
Check that your database user has read/write permissions for the database.
Next Steps
After setting up MongoDB: