In this video series, you'll build a complete real-time order tracking backend with:
- ✅ REST API with Express
- ✅ Real-time updates with Socket.IO
- ✅ MongoDB database integration
- ✅ Order management system
- ✅ Admin dashboard backend
- Node.js installed (v18 or higher) - Download
- Basic JavaScript knowledge
- Text editor (VS Code recommended)
- MongoDB Atlas account (free tier)
# Check Node.js version
node --version
# Should show v14 or higher
# Check npm version
npm --versioncd backend
npm installThis will install:
express- Web serversocket.io- Real-time communicationmongodb- Database drivercors- Cross-origin requestsdotenv- Environment variablesnodemon- Auto-restart server (dev only)
Create Free Account:
- Go to mongodb.com/cloud/atlas
- Click "Try Free"
- Sign up with Google or email
Create Cluster:
- Choose FREE tier (M0 Sandbox)
- Select cloud provider: AWS
- Select region: Closest to you
- Click "Create Cluster" (wait 3-5 minutes)
Create Database User:
- Go to "Database Access"
- Click "Add New Database User"
- Username:
ordertracking_user - Password: Click "Autogenerate" (SAVE THIS!)
- Privileges: "Read and write to any database"
- Click "Add User"
Setup Network Access:
- Go to "Network Access"
- Click "Add IP Address"
- Click "Allow Access from Anywhere" (0.0.0.0/0)
- Click "Confirm"
Get Connection String:
- Go to "Database" (Clusters)
- Click "Connect"
- Choose "Connect your application"
- Driver: Node.js
- Copy the connection string
Example:
mongodb+srv://ordertracking_user:<password>@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority
-
Copy
.env.exampleto.env:cp .env.example .env
-
Edit
.envfile:PORT=5000 MONGODB_URI=mongodb+srv://ordertracking_user:YOUR_PASSWORD@cluster0.xxxxx.mongodb.net/order_tracking_db?retryWrites=true&w=majority ADMIN_PASSWORD=admin123 CLIENT_URL=http://localhost:5173 NODE_ENV=development
-
Replace:
YOUR_PASSWORDwith your actual MongoDB passwordcluster0.xxxxx.mongodb.netwith your cluster URL
.env file to Git!
backend/
├── config/
│ └── database.js # MongoDB connection (Video 4)
├── utils/
│ └── helpers.js # Helper functions (Video 5)
├── socket/
│ └── orderHandlers.js # Socket.IO events (Videos 6-7)
├── server.js # Main server file (Video 4)
├── .env # Your secrets (DON'T commit!)
├── .env.example # Template (safe to commit)
├── .gitignore # What to ignore in Git
└── package.json # Dependencies
We'll create each file together in the videos!
- See the final demo
- Understand what we're building
- Learn HTTP vs WebSocket
- Understand Socket.IO
Before Video 2:
- Node.js installed
- Dependencies installed (
npm install) - MongoDB Atlas cluster created
- Database user created
- Network access configured (0.0.0.0/0)
- Connection string copied
-
.envfile created and configured
Common Issues:
"Cannot find module"
npm install"MongoServerError: bad auth"
- Check your password in
.env - Make sure you replaced
<password>with actual password
"Connection timeout"
- Check network access is set to 0.0.0.0/0
- Check your internet connection
"Port 5000 already in use"
- Change PORT in
.envto 5001
Let's build something amazing together!