-
Install Node.js
- Download from https://nodejs.org/ (LTS version recommended)
- Verify installation:
node --version npm --version
-
Install MongoDB
Option A: Local Installation
- Download from https://www.mongodb.com/try/download/community
- Follow installation wizard for your OS
- Start MongoDB service
Option B: MongoDB Atlas (Cloud)
- Go to https://www.mongodb.com/cloud/atlas
- Create a free account
- Create a cluster
- Get connection string
cd employee-management-system# Navigate to backend directory
cd backend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Edit .env file with your MongoDB URI
# For local MongoDB:
# MONGODB_URI=mongodb://localhost:27017/employee-management
#
# For MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/employee-managementStart the backend:
npm run devExpected output:
MongoDB connected successfully
Server is running on http://localhost:5000
In a new terminal:
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm run devExpected output:
VITE v5.0.0 ready in 123 ms
➜ Local: http://localhost:3000/
➜ press h to show help
-
Open Browser
- Frontend: http://localhost:3000
- Backend Health Check: http://localhost:5000/api/health
-
Test Login
- Email: admin@example.com
- Password: password
-
Check Network Tab in Browser DevTools
- Verify API calls reach http://localhost:5000/api
Solution:
- For local: Ensure
mongodis running - For Atlas: Check connection string in
.env - Verify firewall/VPN settings
Solution (Windows):
netstat -ano | findstr :3000
taskkill /PID <PID> /FSolution (Mac/Linux):
lsof -i :3000
kill -9 <PID>Solution:
rm -rf node_modules
npm installSolution:
- Ensure backend is running on port 5000
- Update proxy in
frontend/vite.config.jsif using different port
cd backend
npm run devcd frontend
npm run devmongodTo add sample data to MongoDB:
# Connect to MongoDB
mongosh
# Use the database
use employee-management
# Insert sample employee
db.employees.insertOne({
name: "John Doe",
email: "john@example.com",
phone: "9876543210",
department: "Engineering",
role: "Senior Developer",
salary: 120000,
joiningDate: new Date("2020-01-15"),
address: "123 Main Street",
status: "active"
})cd frontend
npm run build
# Output in: frontend/dist/- Upload
frontend/dist/to hosting service (Netlify, Vercel, AWS S3, etc.)
- Use services like Heroku, AWS EC2, DigitalOcean, Railway.app, etc.
- Ensure MongoDB Atlas or managed database is accessible
- Set environment variables on hosting platform
# Install Heroku CLI
heroku login
# Create Heroku app
heroku create your-app-name
# Set environment variables
heroku config:set MONGODB_URI=your-mongo-uri
heroku config:set PORT=5000
# Deploy
git push heroku mainPORT=5000
MONGODB_URI=mongodb://localhost:27017/employee-management
NODE_ENV=development
VITE_API_URL=http://localhost:5000/api
- Download from https://www.postman.com/downloads/
- Import API collection (create manually or use Postman's tests)
- Test endpoints:
# Get all employees
curl http://localhost:5000/api/employees
# Create employee
curl -X POST http://localhost:5000/api/employees \
-H "Content-Type: application/json" \
-d '{"name":"Jane Doe","email":"jane@example.com","phone":"9876543211","department":"Sales","role":"Sales Manager","salary":100000,"joiningDate":"2021-03-20","address":"456 Oak Avenue"}'| Command | Directory | Purpose |
|---|---|---|
npm install |
backend/ or frontend/ | Install dependencies |
npm run dev |
backend/ | Start backend (dev mode) |
npm start |
backend/ | Start backend (production) |
npm run dev |
frontend/ | Start frontend (dev mode) |
npm run build |
frontend/ | Build for production |
npm run preview |
frontend/ | Preview production build |
employee-management-system/
│
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API integration
│ │ ├── App.jsx
│ │ ├── main.jsx
│ │ └── index.css
│ ├── package.json
│ ├── vite.config.js
│ └── tailwind.config.js
│
├── backend/
│ ├── models/ # Mongoose schemas
│ ├── routes/ # Express routes
│ ├── server.js # Express server
│ ├── package.json
│ └── .env
│
└── README.md
-
Integrate Frontend with Backend
- Replace mock data with API calls in components
- Use
/frontend/src/services/api.jsfor API calls - Add authentication if needed
-
Add Features
- Email notifications
- Report generation
- Data export (CSV/PDF)
- Advanced filtering and sorting
-
Optimize
- Add caching strategies
- Implement pagination
- Database indexing
- Code splitting
-
Security
- JWT authentication
- Input validation
- CORS configuration
- Secure headers
-
Testing
- Unit tests (Jest)
- Integration tests
- E2E tests (Cypress/Playwright)
- API testing
- React Docs: https://react.dev
- Express.js: https://expressjs.com
- MongoDB: https://docs.mongodb.com
- Tailwind CSS: https://tailwindcss.com
- Vite: https://vitejs.dev
For detailed component documentation, check:
- Frontend:
/frontend/README.md - Backend:
/backend/README.md
Happy Coding! 🚀