MongoDB Installation
Choose your MongoDB deployment
You can use either:
- MongoDB Atlas (cloud-hosted, recommended for production)
- Local MongoDB (self-hosted, good for development)
Install MongoDB (Local Option)
For local development, install MongoDB Community Edition:macOS:Linux (Ubuntu/Debian):Windows:
Download and install from MongoDB Download Center
Create Database (Local)
MongoDB will automatically create the database on first connection. The default name is based on your
MONGO_URI:Set up MongoDB Atlas (Cloud Option)
- Create a free account at MongoDB Atlas
- Create a new cluster
- Add a database user with read/write permissions
- Whitelist your IP address (or use 0.0.0.0/0 for development)
- Get your connection string from the “Connect” button
Database Connection
The application establishes a database connection using Mongoose insrc/config/database.js:
server.js before starting the Express server.
Database Schema
User Model
Stores user account information for authentication. Location:src/models/user.model.js
Schema Structure:
Unique username for the user account
- Must be unique across all users
- Error message: “username already taken”
User’s email address
- Must be unique across all users
- Used for login authentication
- Error message: “Account already exists with this email address”
Hashed password (bcrypt with 10 salt rounds)
- Never stored in plain text
- Hashed before saving to database
users
Example Document:
Interview Report Model
Stores AI-generated interview preparation reports for users. Location:src/models/interviewReport.model.js
Schema Structure:
Job title for which the interview report was generated
The job description provided by the user
Resume text content (optional if resume file was uploaded)
User’s self-description or cover letter
AI-calculated score (0-100) indicating job match quality
Array of technical interview questionsEach question contains:
question(string, required): The interview questionintention(string, required): Why the interviewer asks thisanswer(string, required): How to answer effectively
Array of behavioral interview questionsEach question contains:
question(string, required): The interview questionintention(string, required): Why the interviewer asks thisanswer(string, required): How to answer effectively
Identified gaps between user skills and job requirementsEach skill gap contains:
skill(string, required): The missing or weak skillseverity(enum, required): “low”, “medium”, or “high”
Day-by-day interview preparation planEach day contains:
day(number, required): Day number (starting from 1)focus(string, required): Main focus area for the daytasks(array of strings, required): Specific tasks to complete
Reference to the user who created this report
- References the
userscollection
Automatically managed timestamps
createdAt: When the report was generatedupdatedAt: When the report was last modified
interviewreports
Example Document:
Token Blacklist Model
Stores invalidated JWT tokens (e.g., after logout) to prevent reuse. Location:src/models/blacklist.model.js
Schema Structure:
The JWT token that has been invalidated
- Added when users log out
- Checked during authentication to reject blacklisted tokens
Automatically managed timestamps
createdAt: When the token was blacklistedupdatedAt: When the record was last modified
blacklisttokens
Example Document:
Database Relationships
Database Indexing
The application automatically creates indexes on:users.username(unique)users.email(unique)interviewreports.user(reference)
Troubleshooting
Connection timeout errors
Connection timeout errors
- Verify MongoDB is running:
sudo systemctl status mongod - Check firewall settings allow port 27017
- For Atlas, verify IP whitelist includes your current IP
- Test connection using MongoDB Compass
Duplicate key errors
Duplicate key errors
- Username or email already exists in database
- Clear test data if in development:
db.users.deleteMany({}) - Check for duplicate entries before insertion
Authentication failures
Authentication failures
- Ensure MongoDB user has
readWriterole - Verify credentials in connection string
- Check database name matches your configuration
Schema validation errors
Schema validation errors
- Review required fields in error messages
- Ensure data types match schema definitions
- Check enum values for
skillGaps.severity
Database Management
Using MongoDB Shell
Connect to your database:Using MongoDB Compass
MongoDB Compass provides a GUI for database management:- Download from MongoDB Compass
- Connect using your
MONGO_URI - Browse collections and documents visually
- Create indexes and run queries
Next Steps
Environment Variables
Configure all required environment variables
AI Setup
Set up Google Gemini API for AI features