A full-stack web application for managing student results, built with React, Node.js, Express, and MySQL.
- View results by roll number and class
- Comprehensive result cards with subject-wise marks
- Overall performance statistics
- Secure login system
- Add/Update student results
- Class and subject-specific access control
- Register new teachers
- Assign classes and subjects to teachers
- React with Vite
- TailwindCSS for styling
- Lucide React for icons
- Node.js & Express
- MySQL database
- JWT for authentication
- Bcrypt for password hashing
student-result-management/
├── backend/
│ ├── server.js # Express server setup
│ ├── hash-password.js # Password hashing utility
│ ├── package.json # Backend dependencies
│ └── .env # Backend environment variables
├── Frontend/
│ ├── src/
│ │ ├── App.jsx # Main React component
│ │ └── main.jsx # React entry point
│ ├── package.json # Frontend dependencies
│ └── index.html # HTML template
└── database_schema.sql # MySQL database schema
Before starting, ensure you have the following installed on your system:
- Node.js (v16 or higher) - Download here
- MySQL (v8.0 or higher) - Download here
- MySQL Workbench (for database management) - Download here
- Git (optional, for cloning) - Download here
Option A: Using Git
git clone https://github.com/yourusername/student-result-management.git
cd student-result-managementOption B: Download ZIP
- Download the project ZIP file
- Extract it to your desired location
- Open terminal/command prompt in the extracted folder
Windows:
- Open MySQL Workbench
- Click on your local MySQL connection
- Enter your root password
macOS/Linux:
# Start MySQL service
sudo systemctl start mysql
# OR
sudo service mysql startMethod 1: Using Workbench GUI
- Open MySQL Workbench
- Connect to your local MySQL instance
- Click on "File" → "Open SQL Script"
- Navigate to your project folder and select
database_schema.sql - Click the lightning bolt icon (⚡) or press
Ctrl+Shift+Enterto execute - Verify the database was created by expanding the "Schemas" panel
Method 2: Using Command Line
# Navigate to project directory
cd /path/to/student-result-management
# Login to MySQL
mysql -u root -p
# Enter your MySQL password when prompted
# Then run these commands:-- In MySQL prompt
source database_schema.sql;
-- Verify database creation
SHOW DATABASES;
-- Use the database
USE student_result_mgmt;
-- Verify tables
SHOW TABLES;
-- Exit MySQL
exit;Example Output:
mysql> source database_schema.sql;
Query OK, 1 row affected (0.02 sec)
Database changed
Query OK, 0 rows affected (0.15 sec)
...
mysql> SHOW TABLES;
+--------------------------------+
| Tables_in_student_result_mgmt |
+--------------------------------+
| classes |
| results |
| students |
| subjects |
| teachers |
+--------------------------------+
5 rows in set (0.00 sec)
cd backendnpm installExpected Output:
added 245 packages, and audited 246 packages in 15s
42 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Create a file named .env in the backend directory:
# Windows (Command Prompt)
type nul > .env
# Windows (PowerShell)
New-Item .env -ItemType File
# macOS/Linux
touch .envOpen backend/.env in your text editor and add:
# Database Configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=student_result_mgmt
# Server Configuration
PORT=5000
# JWT Secret (generate a random string)
JWT_SECRET=your_super_secret_jwt_key_change_this_in_productionyour_mysql_password with your actual MySQL root password
Example:
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=MySecurePass123!
DB_NAME=student_result_mgmt
PORT=5000
JWT_SECRET=a8f5h2k9j3m7n4p1q6r8s2t5v9w3x7y1z4Ensure backend/hash-password.js exists with this content:
const bcrypt = require('bcryptjs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter password to hash: ', (password) => {
const salt = bcrypt.genSaltSync(10);
const hash = bcrypt.hashSync(password, salt);
console.log('\nHashed Password:');
console.log(hash);
console.log('\nUse this hash when inserting teacher records into the database.');
rl.close();
});# Make sure you're in the backend directory
node hash-password.jsExample Interaction:
Enter password to hash: admin123
Hashed Password:
$2a$10$rK8qL9mP3nF7sJ4xT6vY8.eH2dW5pQ1rA3sC7tE9uB4vF6wN8zM0k
Use this hash when inserting teacher records into the database.
Save this hash! You'll need it in the next step.
Open MySQL Workbench or terminal and connect to MySQL:
mysql -u root -pUSE student_result_mgmt;
-- Insert a sample teacher/admin account
INSERT INTO teachers (name, email, password, phone, address)
VALUES (
'Admin User',
'admin@school.com',
'$2a$10$rK8qL9mP3nF7sJ4xT6vY8.eH2dW5pQ1rA3sC7tE9uB4vF6wN8zM0k',
'9876543210',
'123 School Street'
);
-- Verify the insertion
SELECT teacher_id, name, email FROM teachers;Example Output:
+------------+------------+-------------------+
| teacher_id | name | email |
+------------+------------+-------------------+
| 1 | Admin User | admin@school.com |
+------------+------------+-------------------+
1 row in set (0.00 sec)
Login Credentials to Remember:
- Email:
admin@school.com - Password:
admin123(or whatever you used to generate the hash)
# Make sure you're in the backend directory
npm run devExpected Output:
> backend@1.0.0 dev
> nodemon server.js
[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
Server is running on port 5000
MySQL Connected: localhost
Keep this terminal window open!
Open a new terminal window/tab (keep the backend running in the first one)
# From project root
cd Frontendnpm installExpected Output:
added 328 packages, and audited 329 packages in 22s
89 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm run devExpected Output:
> frontend@0.0.0 dev
> vite
VITE v5.0.8 ready in 523 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
Open your web browser and navigate to:
Frontend: http://localhost:5173/
Backend API: http://localhost:5000/api/
- Go to http://localhost:5173/
- Navigate to "View Results"
- Try searching with any roll number (no results expected initially)
- Click on "Teacher Login"
- Use credentials:
- Email:
admin@school.com - Password:
admin123
- Email:
- You should be redirected to the teacher dashboard
In MySQL Workbench, add sample data:
USE student_result_mgmt;
-- Add a class
INSERT INTO classes (class_name, section) VALUES ('Class 10', 'A');
-- Add a subject
INSERT INTO subjects (subject_name, class_id) VALUES ('Mathematics', 1);
-- Add a student
INSERT INTO students (name, roll_no, class_id, dob, email, phone)
VALUES ('John Doe', 'S001', 1, '2008-05-15', 'john@example.com', '9876543210');
-- Add a result
INSERT INTO results (student_id, subject_id, exam_type, marks, max_marks, exam_date, teacher_id)
VALUES (1, 1, 'Midterm', 85, 100, '2025-10-01', 1);Now test the Student Portal with roll number S001.
Error: connect ECONNREFUSED 127.0.0.1:3306
Solution:
- Verify MySQL is running:
sudo systemctl status mysql(Linux) or check Services (Windows) - Check your
.envcredentials match your MySQL setup
Error: listen EADDRINUSE: address already in use :::5000
Solution:
- Change
PORTinbackend/.envto another port (e.g., 5001) - Update frontend API calls to use the new port
Error: Cannot find module 'express'
Solution:
- Run
npm installagain in the respective directory - Delete
node_modulesandpackage-lock.json, then runnpm install
ERROR 1146: Table 'student_result_mgmt.teachers' doesn't exist
Solution:
- Re-run the database schema:
source database_schema.sql;in MySQL - Verify you're using the correct database:
USE student_result_mgmt;
- Frontend: http://localhost:5173/
- Backend API: http://localhost:5000/api/
- MySQL Workbench: Connect to
localhost:3306
- Stop Frontend: Press
Ctrl + Cin the frontend terminal - Stop Backend: Press
Ctrl + Cin the backend terminal - Stop MySQL:
sudo systemctl stop mysql # Linux # OR close MySQL Workbench and stop service in Windows
- Add more sample data to test all features
- Customize the application according to your needs
- Set up additional teachers with different class/subject access
- Configure production environment for deployment
- Change the default
JWT_SECRETto a strong, random string - Never commit
.envfile to version control - Use strong passwords for teacher accounts
- Enable MySQL security features in production
- Implement rate limiting for API endpoints
For issues or questions:
- Check the "Common Issues" section above
- Review MySQL and Node.js logs for error details
- Open an issue in the GitHub repository
Note: This setup is configured for development. For production deployment, additional security measures and optimizations are required.