Tech Lead & Backend Architect
You are the technical leader of this project. Your responsibilities include backend development, database architecture, team coordination, and ensuring overall code quality.
- Set up JWT authentication
- Implement user registration endpoint
- Implement login endpoint
- Create password hashing with bcrypt
- Implement Google OAuth integration
- Create protected route middleware
- Add session management
Files to work on:
server/routes/auth.jsserver/middleware/auth.js
Key Functions to Implement:
// In auth.js - POST /api/auth/register - POST /api/auth/login - GET /api/auth/me - PUT /api/auth/profile - POST /api/auth/google (Google OAuth)
- Design User schema with validations
- Design Product schema with reviews
- Design Order schema with relationships
- Add database indexes for performance
- Create schema relationships (User -> Orders, Products -> Reviews)
Files to work on:
server/models/User.jsserver/models/Product.jsserver/models/Order.js
User Schema Fields:
- name, email, password (hashed)
- role (user/admin)
- avatar, phone
- address (shipping)
- wishlist (array of product IDs)
- createdAt, updatedAt
Product Schema Fields:
- name, description, price
- images (array)
- category, brand
- stock, ratings
- reviews (embedded)
- featured (boolean)
Order Schema Fields:
- user (reference)
- orderItems (array)
- shippingAddress
- paymentMethod, paymentResult
- totalPrice, taxPrice, shippingPrice
- isPaid, paidAt
- isDelivered, deliveredAt
- Create dashboard statistics endpoint
- Get all users endpoint
- Update user role endpoint
- Delete user endpoint
- Sales analytics endpoint
- Recent orders endpoint
File to work on:
server/routes/admin.js
Endpoints to create:
GET /api/admin/stats // Dashboard statistics GET /api/admin/users // All users PUT /api/admin/users/:id/role // Update role DELETE /api/admin/users/:id // Delete user GET /api/admin/analytics // Sales data
- Set up Express server
- Configure middleware (cors, body-parser, etc.)
- Set up MongoDB connection
- Configure environment variables
- Add error handling middleware
- Set up security (helmet, rate limiting)
File to work on:
server/index.js
Setup checklist:
- Express app initialization - Middleware: cors, express.json, cookie-parser - MongoDB connection with error handling - Route mounting (/api/auth, /api/products, etc.) - Error handling middleware - 404 handler - Server listening on PORT
- Conduct daily standup meetings (15 min)
- Review pull requests from team members
- Unblock team members when stuck
- Answer technical questions
- Make architectural decisions
- Review code quality across the project
- Update project documentation
- Plan next week's tasks
- Integration testing
- Performance optimization
When reviewing team member's code:
- ✅ Code follows project conventions
- ✅ No security vulnerabilities
- ✅ Error handling is present
- ✅ Code is well-commented
- ✅ No console.logs in production code
- ✅ Functions are small and focused
- ✅ Variable names are descriptive
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication tokens
- bcryptjs - Password hashing
- passport - Google OAuth
- dotenv - Environment variables
- Create
server/.envfile with all environment variables - Set up Express server in
server/index.js - Configure MongoDB connection
- Test server is running on http://localhost:5001
- Create User model with all fields
- Create Product model with reviews
- Create Order model with relationships
- Test models by creating sample documents
- Set up JWT utilities (sign, verify)
- Create user registration endpoint
- Create login endpoint
- Test with Postman/Thunder Client
- Create auth middleware for protected routes
- Implement get current user endpoint
- Create update profile endpoint
- Add Google OAuth (optional)
- Create admin middleware (check if user.role === 'admin')
- Implement dashboard statistics
- Create user management endpoints
- Create analytics endpoints
- Review all backend code from Harsh
- Review admin backend from Tushar
- Ensure consistency across all routes
- Test frontend-backend integration with Sneha
- Fix any API issues
- Ensure all endpoints work correctly
- Add database indexes
- Optimize queries
- Add request validation
- Add helmet.js for security headers
- Implement rate limiting
- Add input sanitization
- Review for SQL injection, XSS vulnerabilities
- Test all authentication flows
- Test admin operations
- Load testing
- Bug fixes
- Set up MongoDB Atlas (cloud database)
- Deploy backend to Railway/Render
- Configure environment variables in production
- Test production APIs
- Monitor and fix issues
// server/models/User.js const mongoose = require('mongoose'); const bcrypt = require('bcryptjs'); const userSchema = new mongoose.Schema({ name: { type: String, required: [true, 'Please provide a name'], trim: true }, email: { type: String, required: [true, 'Please provide an email'], unique: true, lowercase: true }, password: { type: String, required: [true, 'Please provide a password'], minlength: 6, select: false }, role: { type: String, enum: ['user', 'admin'], default: 'user' }, wishlist: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Product' }] }, { timestamps: true }); // Hash password before saving userSchema.pre('save', async function(next) { if (!this.isModified('password')) return next(); this.password = await bcrypt.hash(this.password, 12); next(); }); // Compare password method userSchema.methods.comparePassword = async function(candidatePassword) { return await bcrypt.compare(candidatePassword, this.password); }; module.exports = mongoose.model('User', userSchema);
// server/routes/auth.js const express = require('express'); const jwt = require('jsonwebtoken'); const User = require('../models/User'); const { protect } = require('../middleware/auth'); const router = express.Router(); // Register router.post('/register', async (req, res) => { try { const { name, email, password } = req.body; // Check if user exists const userExists = await User.findOne({ email }); if (userExists) { return res.status(400).json({ message: 'User already exists' }); } // Create user const user = await User.create({ name, email, password }); // Create token const token = jwt.sign({ id: user._id }, process.env.JWT_SECRET, { expiresIn: process.env.JWT_EXPIRE }); res.status(201).json({ success: true, token, user: { id: user._id, name: user.name, email: user.email, role: user.role } }); } catch (error) { res.status(500).json({ message: error.message }); } }); // Login router.post('/login', async (req, res) => { try { const { email, password } = req.body; // Check if email and password provided if (!email || !password) { return res.status(400).json({ message: 'Please provide email and password' }); } // Get user with password const user = await User.findOne({ email }).select('+password'); if (!user || !(await user.comparePassword(password))) { return res.status(401).json({ message: 'Invalid credentials' }); } // Create token const token = jwt.sign({ id: user._id }, process.env.JWT_SECRET, { expiresIn: process.env.JWT_EXPIRE }); res.json({ success: true, token, user: { id: user._id, name: user.name, email: user.email, role: user.role } }); } catch (error) { res.status(500).json({ message: error.message }); } }); // Get current user router.get('/me', protect, async (req, res) => { const user = await User.findById(req.user.id); res.json({ success: true, user }); }); module.exports = router;
// server/middleware/auth.js const jwt = require('jsonwebtoken'); const User = require('../models/User'); exports.protect = async (req, res, next) => { try { let token; // Get token from header if (req.headers.authorization && req.headers.authorization.startsWith('Bearer')) { token = req.headers.authorization.split(' ')[1]; } if (!token) { return res.status(401).json({ message: 'Not authorized to access this route' }); } // Verify token const decoded = jwt.verify(token, process.env.JWT_SECRET); // Get user from token req.user = await User.findById(decoded.id); if (!req.user) { return res.status(401).json({ message: 'User not found' }); } next(); } catch (error) { return res.status(401).json({ message: 'Not authorized' }); } }; exports.admin = (req, res, next) => { if (req.user && req.user.role === 'admin') { next(); } else { res.status(403).json({ message: 'Access denied. Admin only.' }); } };
# Register a new user POST http://localhost:5001/api/auth/register { "name": "Test User", "email": "[email protected]", "password": "password123" } # Login POST http://localhost:5001/api/auth/login { "email": "[email protected]", "password": "password123" } # Get current user (use token from login) GET http://localhost:5001/api/auth/me Headers: Authorization: Bearer YOUR_TOKEN
- Coordinate on API response formats
- Ensure frontend can consume your APIs
- Help with CORS issues
- Provide API documentation
- Review his order routes
- Help with database queries
- Guide on error handling
- Coordinate order model design
- Review admin APIs he'll use
- Help with product routes
- Guide on image upload
- Coordinate on cart logic
You're doing great when:
- All authentication works smoothly
- Database models are well-designed
- Admin APIs provide accurate data
- Team members get quick responses to questions
- Code reviews are done within 24 hours
- No major bugs in backend
- APIs are well-documented
- Production deployment is successful
- MongoDB Connection Error: Check MONGODB_URI
- JWT Error: Verify JWT_SECRET is set
- CORS Error: Add frontend URL to CORS config
- Port in use: Change PORT in .env
Remember: You're the Tech Lead! Your team looks up to you. Be helpful, be patient, and lead by example! 🚀
Your success = Team's success!