Setting Up the DevTinder Backend Repository Clone, Install, and Configure
Learn how to set up the DevTinder backend repository from scratch cloning, installing dependencies, configuring environment variables, and running the Express server locally.
Setting Up the DevTinder Backend Repository
Setting up the DevTinder backend is the first step to running the project locally. This guide walks through cloning the repository, installing dependencies, configuring environment variables, and starting the Express server.
Step 1: Clone the Repository
git clone https://github.com/yourusername/devtinder-backend.git cd devtinder-backend
If you are forked from the original repo, replace the URL with your fork URL.
Step 2: Install Dependencies
npm install
This installs Express, Mongoose, JWT, bcrypt, Socket.io, and all other dependencies listed in package.json.
Step 3: Configure Environment Variables
Create a .env file in the root directory:
cp .env.example .env
Fill in the values:
PORT=3000 MONGODB_URI=mongodb://localhost:27017/devtinder JWT_SECRET=your_super_secret_key_here NODE_ENV=development CLIENT_URL=http://localhost:5173
Never commit the .env file. It should be in .gitignore.
Step 4: Set Up MongoDB
You can use either a local MongoDB instance or MongoDB Atlas:
Local MongoDB:
# Install MongoDB Community Edition # Start the MongoDB service mongod --dbpath /data/db
MongoDB Atlas (cloud):
- Create a free cluster at mongodb.com/atlas
- Create a database user
- Whitelist your IP (or 0.0.0.0/0 for development)
- Get the connection string and put it in MONGODB_URI
Step 5: Run the Server
# Development mode with nodemon npm run dev # Production mode npm start
The server should start on http://localhost:3000. You should see:
Server running on port 3000
MongoDB connected
Step 6: Test the API
Open a new terminal and test the signup endpoint:
curl -X POST http://localhost:3000/api/signup \ -H "Content-Type: application/json" \ -d '{"firstName":"John","lastName":"Doe","email":"[email protected]","password":"John@1234"}'
You should get a 201 response with the user data and a Set-Cookie header.
Step 7: Explore the Project Structure
devtinder-backend/
├── src/
│ ├── models/ # Mongoose schemas
│ ├── routes/ # Express route handlers
│ ├── middlewares/ # Auth, error handling
│ ├── utils/ # Helper functions
│ ├── app.js # Express app setup
│ └── server.js # HTTP server entry point
├── package.json
├── .env.example
└── .gitignore
Common Setup Issues
MongoDB connection error:
- Check that MongoDB is running
- Verify the MONGODB_URI in .env
- For Atlas, check IP whitelist and credentials
Port already in use:
- Change the PORT in .env
- Or kill the process using the port:
lsof -i :3000thenkill -9 <PID>
JWT_SECRET missing:
- Make sure .env file exists and has JWT_SECRET
- Restart the server after adding it
The Takeaway
Setting up the DevTinder backend involves cloning the repo, installing npm dependencies, configuring environment variables (especially MongoDB URI and JWT secret), and running the Express server. Once running, test the API with curl or Postman to verify it works.
Clone the repository with git clone, run npm install to install dependencies, copy .env.example to .env and fill in MongoDB URI and JWT secret, then run npm run dev to start the Express server.
PORT (e.g., 3000), MONGODB_URI (connection string for MongoDB), JWT_SECRET (for signing JWT tokens), NODE_ENV (development or production), and CLIENT_URL (for CORS configuration with the frontend).
Either works. Local MongoDB is faster and doesn't require internet. MongoDB Atlas is easier to set up (no local install) and is free for small projects. Use Atlas if you want a managed cloud database.
After starting the server, use curl or Postman to hit POST /api/signup with a JSON body containing firstName, lastName, email, and password. A 201 response with user data and a Set-Cookie header confirms it works.
Check that MongoDB is running (mongod process for local, or Atlas cluster status for cloud). Verify the MONGODB_URI in .env. For Atlas, ensure your IP is whitelisted and credentials are correct.
Ready to master Node.js completely?
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.
Master Node.js
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

