A full-stack web application for managing employee records with a modern, responsive UI built with React, Node.js, Express, and MySQL.
- Complete CRUD Operations: Create, Read, Update, and Delete employee records
- Search Functionality: Search employees by name, email, department, position, or employee ID
- Modern UI: Beautiful, responsive design with gradient themes and smooth animations
- Real-time Updates: Instant feedback on all operations
- Status Management: Track active/inactive employee status
- Comprehensive Employee Data: Store and manage detailed employee information including:
- Personal information (name, email, phone)
- Employment details (employee ID, department, position)
- Financial information (salary)
- Employment dates and status
Before running this application, make sure you have the following installed:
employee-management-system/
├── backend/ # Node.js/Express backend
│ ├── config/ # Database configuration
│ ├── controllers/ # Route controllers
│ ├── database/ # Database schema
│ ├── routes/ # API routes
│ ├── package.json # Backend dependencies
│ └── server.js # Server entry point
│
├── frontend/ # React frontend
│ ├── public/ # Public assets
│ ├── src/ # Source files
│ │ ├── components/ # React components
│ │ ├── App.js # Main App component
│ │ ├── App.css # App styles
│ │ ├── index.js # React entry point
│ │ └── index.css # Global styles
│ └── package.json # Frontend dependencies
│
└── README.md # This file
git clone <repository-url>
cd e- Open MySQL command line or MySQL Workbench
- Create the database and tables by running the schema file:
mysql -u root -p < backend/database/schema.sqlOr manually execute the SQL commands:
CREATE DATABASE IF NOT EXISTS employee_management;
USE employee_management;
-- Copy and paste the contents of backend/database/schema.sql- Update database credentials in
backend/.env(create if it doesn't exist):
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=employee_management
DB_PORT=3306
PORT=5000# Navigate to backend directory
cd backend
# Install dependencies
npm install
# Start the backend server
npm start
# For development with auto-restart
npm run devThe backend server will start on http://localhost:5000
Open a new terminal window/tab:
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start the React development server
npm startThe frontend application will automatically open in your browser at http://localhost:3000
- Click the "Add Employee" button in the header
- Fill in the required fields (Employee ID, First Name, Last Name, Email)
- Optionally add phone, department, position, salary, and hire date
- Click "Add Employee" to save
- Find the employee card you want to edit
- Click the "Edit" button
- Modify the desired fields
- Click "Update Employee" to save changes
- Find the employee card you want to delete
- Click the "Delete" button
- Confirm the deletion in the popup dialog
- Use the search bar at the top of the employee list
- Type any part of:
- Employee name
- Email address
- Department
- Position
- Employee ID
- Results filter automatically as you type
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/employees |
Get all employees |
| GET | /api/employees/:id |
Get employee by ID |
| GET | /api/employees/search?query= |
Search employees |
| POST | /api/employees |
Create new employee |
| PUT | /api/employees/:id |
Update employee |
| DELETE | /api/employees/:id |
Delete employee |
// Get all employees
fetch('http://localhost:5000/api/employees')
.then(response => response.json())
.then(data => console.log(data));
// Create new employee
fetch('http://localhost:5000/api/employees', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
employee_id: 'EMP006',
first_name: 'John',
last_name: 'Doe',
email: 'john@example.com',
phone: '555-0123',
department: 'IT',
position: 'Developer',
salary: 70000,
hire_date: '2024-01-15',
status: 'active'
})
})
.then(response => response.json())
.then(data => console.log(data));- React 18.2.0 - UI library
- Axios - HTTP client
- React Icons - Icon library
- CSS3 - Styling with modern animations
- Node.js - Runtime environment
- Express 4.18.2 - Web framework
- MySQL2 - Database driver
- CORS - Cross-origin resource sharing
- dotenv - Environment variable management
- MySQL - Relational database
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=employee_management
DB_PORT=3306
PORT=5000Create .env file in frontend directory if backend is hosted elsewhere:
REACT_APP_API_URL=http://localhost:5000/apiProblem: Database connection error
- Solution: Check if MySQL is running and credentials in
.envare correct
Problem: Port 5000 already in use
- Solution: Change PORT in
.envfile and update frontend proxy infrontend/package.json
Problem: API calls failing
- Solution: Ensure backend server is running on the correct port
Problem: CORS errors
- Solution: Backend has CORS enabled by default; check if backend is accessible
Problem: Schema not created
- Solution: Run the SQL file manually in MySQL Workbench or command line
employees (
id INT PRIMARY KEY AUTO_INCREMENT,
employee_id VARCHAR(50) UNIQUE NOT NULL,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
email VARCHAR(150) UNIQUE NOT NULL,
phone VARCHAR(20),
department VARCHAR(100),
position VARCHAR(100),
salary DECIMAL(10, 2),
hire_date DATE,
status ENUM('active', 'inactive'),
created_at TIMESTAMP,
updated_at TIMESTAMP
)- Set up a Node.js hosting service (Heroku, AWS, DigitalOcean, etc.)
- Configure environment variables
- Set up MySQL database (or use managed service like AWS RDS)
- Deploy backend code
- Build the production version:
cd frontend
npm run build-
Deploy the
buildfolder to:- Netlify: Drag and drop build folder
- Vercel: Connect GitHub repository
- AWS S3: Upload to S3 bucket with static hosting
- Any static hosting service
-
Update API URL in frontend environment variables
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
For any questions or issues, please open an issue in the repository.
Built with ❤️ using React, Node.js, and MySQL