A simple Student Management System built using:
- HTML
- CSS
- JavaScript
- Node.js
- Express.js
- MongoDB Atlas
This project allows users to:
- Add student details
- View student details
- Edit student details
- Delete student details
Hi Students is a simple full-stack web application for managing student information.
The application has three main parts:
The frontend is the part you see in your browser.
It is built using:
- HTML
- CSS
- JavaScript
The backend handles the application's logic and communication.
It is built using:
- Node.js
- Express.js
The database stores the student information.
This project uses:
- MongoDB Atlas
The basic flow is:
You
↓
Web Browser
↓
Frontend
↓
Node.js + Express.js
↓
MongoDB Atlas
↓
Database
For example, when you add a student:
You enter student details
↓
Frontend collects the details
↓
Frontend sends the details to the backend
↓
Backend receives the details
↓
Backend sends the data to MongoDB Atlas
↓
MongoDB stores the student
↓
Backend sends a response
↓
Frontend displays the updated information
The application supports CRUD operations.
CRUD means:
| Operation | Meaning |
|---|---|
| Create | Add a new student |
| Read | View students |
| Update | Edit student information |
| Delete | Remove a student |
The backend provides these API endpoints:
| Operation | Method | Endpoint |
|---|---|---|
| Create | POST | /students |
| Read | GET | /students |
| Update | PUT | /students/:id |
| Delete | DELETE | /students/:id |
The project looks like this:
hi_students/
│
├── public/
│ ├── index.html
│ ├── script.js
│ └── style.css
│
├── .env
├── .env.example
├── .gitignore
├── package.json
├── package-lock.json
├── README.md
└── server.js
Contains the structure of the website.
Contains the design and styling of the website.
Contains the frontend JavaScript logic.
It communicates with the backend.
This is the main backend file.
It:
- Starts the server
- Connects to MongoDB
- Handles API requests
- Adds students
- Gets students
- Updates students
- Deletes students
- Serves the frontend
Contains information about the project and the Node.js packages required by the project.
Keeps the exact dependency information used by npm.
Tells Git which files should not be uploaded to GitHub.
For example:
node_modules/
.env
Contains private environment variables such as the MongoDB connection string.
This file should never be uploaded to GitHub.
Shows which environment variables are required.
It does not contain the real database credentials.
This file contains the instructions for setting up and running the project.
Before starting, make sure you have:
- VS Code
- Node.js
- A MongoDB Atlas account
- Internet connection
You already know how to clone this GitHub repository and open it in VS Code.
You do not need:
- MongoDB Server installed locally
- MongoDB Compass
- Any paid software
MongoDB Atlas is used as the cloud database.
Node.js is required to run the backend of this project.
Go to the official Node.js website:
Download the LTS version and install it using the normal installation options.
After installation, restart VS Code if it was already open.
Open the project in VS Code.
Then open the VS Code terminal.
You can open the terminal using:
Terminal → New Terminal
Run:
node -vYou should see a version number.
For example:
v22.x.x
Then run:
npm -vYou should also see a version number.
For example:
10.x.x
If both commands show version numbers, Node.js is installed correctly.
The project requires several Node.js packages.
You do not need to install them one by one.
In the VS Code terminal, make sure you are inside the project folder.
Then run:
npm installThis reads the project's package.json file and installs the required packages.
After it finishes, a folder called:
node_modules
will be created.
You do not need to upload or commit the node_modules folder to GitHub.
It is already ignored by .gitignore.
This project needs a database to store student information.
We use MongoDB Atlas for this.
MongoDB Atlas is a cloud-based MongoDB database.
That means your database is stored online instead of only on your computer.
Create an account here:
You can create a free account.
After creating your MongoDB Atlas account:
- Log in to MongoDB Atlas.
- Create a project.
- Create a database deployment.
- Select the free option if available.
- Give your deployment a name.
You can use any name you want.
For example:
hi_students
or:
Cluster0
The exact deployment name does not matter for this project.
Wait for the deployment to finish creating.
MongoDB Atlas needs a username and password to allow your application to connect to the database.
In MongoDB Atlas:
- Open your project.
- Go to the database security section.
- Find Database Access.
- Create a new database user.
For example:
Username:
my_student_user
Password:
your_password
You can choose your own username and password.
Remember the username and password.
You will need them when creating the MongoDB connection string.
Do not share your database password publicly.
MongoDB Atlas blocks unknown connections by default.
You need to allow your computer's IP address.
In MongoDB Atlas:
- Open your project.
- Go to Network Access.
- Add your current IP address.
- Save the change.
MongoDB Atlas may automatically detect your current IP address.
Choose the option to add your current IP address if available.
Your application is running on your computer.
MongoDB Atlas needs permission to accept a connection from your computer.
Now we need the connection string.
The connection string tells your application:
"Which MongoDB database should I connect to, and how should I connect to it?"
In MongoDB Atlas:
- Open your database deployment.
- Click Connect.
- Choose Drivers.
- Select Node.js as the driver if required.
- Copy the connection string.
It will look similar to:
mongodb+srv://username:password@cluster.mongodb.net/
Your actual connection string will be different.
Go back to your project in VS Code.
You should already see:
.env.example
Create a new file in the main project folder.
Name it exactly:
.env
Your project should now contain:
.env
.env.example
Open the .env file.
Add:
MONGODB_URI=your_mongodb_connection_string_hereReplace:
your_mongodb_connection_string_here
with the MongoDB Atlas connection string you copied earlier.
For example:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/studentDB?retryWrites=true&w=majorityDo not put spaces around =.
Correct:
MONGODB_URI=mongodb+srv://...Wrong:
MONGODB_URI = mongodb+srv://...Your .env file contains private information.
For example:
MONGODB_URI=mongodb+srv://username:password@...This may contain your database username and password.
Do not:
- Post it online
- Send it to strangers
- Put it in screenshots
- Commit it to Git
- Share your database password
The project already contains a .gitignore file that ignores .env.
You may see:
.env.example
This file is safe to share.
It contains something like:
MONGODB_URI=your_mongodb_connection_string_hereIt tells another developer:
"This project needs a variable called MONGODB_URI."
It does not contain the real database password.
The developer must create their own .env file and add their own MongoDB Atlas connection string.
Now everything should be ready.
Open the VS Code terminal.
Run:
npm startThe application should start.
You should see something similar to:
MongoDB connected successfully!
Website running at http://localhost:3000
If you see the MongoDB connection success message, the application has successfully connected to your MongoDB Atlas database.
Open your web browser.
Go to:
http://localhost:3000
The Hi Students application should now open.
You can use the application to:
- Add students
- View students
- Edit students
- Delete students
When you add a student through the website, the data is not stored inside the HTML file.
The data is sent to the backend.
The backend sends it to MongoDB Atlas.
The database contains:
Database:
studentDB
Collection:
students
The exact database and collection names are created/used by the application.
Here is the complete flow:
USER
│
▼
WEB BROWSER
│
▼
┌─────────────────┐
│ FRONTEND │
│ HTML/CSS/JS │
└─────────────────┘
│
│ HTTP Request
▼
┌─────────────────┐
│ BACKEND │
│ Node.js/Express │
└─────────────────┘
│
│ MongoDB Request
▼
┌─────────────────┐
│ MONGODB ATLAS │
│ DATABASE │
└─────────────────┘
server.js is the main backend file.
When you run:
npm startthe following happens:
npm start
↓
node server.js
↓
Express server starts
↓
MongoDB connection is created
↓
Application waits for requests
When you use the website, the backend handles the requests.
The backend provides these endpoints:
POST /students
Used to add a new student.
GET /students
Used to retrieve student information.
PUT /students/:id
Used to update an existing student.
DELETE /students/:id
Used to delete a student.
CRUD is a common term in software development.
It means:
C → Create
R → Read
U → Update
D → Delete
In this project:
Create → Add Student
Read → View Students
Update → Edit Student
Delete → Remove Student
MongoDB Compass is not required to run this project.
However, you can install MongoDB Compass if you want a graphical interface to view your MongoDB database.
You can connect Compass to your MongoDB Atlas database using your Atlas connection string.
This allows you to view the student data stored in:
studentDB
↓
students
Again:
MongoDB Compass is optional.
The website can work without Compass.
Example:
npm is not recognized...
Node.js may not be installed correctly.
Install Node.js from:
Then restart VS Code.
Check:
node -v
npm -vYou may see an error related to:
MONGODB_URI
- Make sure
.envexists. - Make sure
.envis in the main project folder. - Make sure the variable is exactly:
MONGODB_URI=your_connection_string- Make sure you saved the
.envfile. - Restart the application.
If MongoDB does not connect, check:
Make sure your Atlas deployment is available.
Check your MongoDB Atlas database user.
Make sure the password in the connection string is correct.
Go to MongoDB Atlas:
Network Access
Make sure your current IP address is allowed.
Make sure the MongoDB connection string was copied correctly.
If you run:
npm startand the terminal shows:
Website running at http://localhost:3000
open:
http://localhost:3000
Do not open index.html directly from your computer.
For example, do not use:
file:///C:/hi_students/public/index.html
The application needs the Node.js server to run correctly.
If another application is already using the required port, the server may not start correctly.
Close the other application using the port and try again.
Then run:
npm startWhen the application is running in the terminal, press:
Ctrl + C
This stops the Node.js server.
To start it again:
npm startPlease follow these rules when using or modifying this project.
.env
- MongoDB passwords
- Database credentials
- API keys
- Secret tokens
.env.example
because it does not contain real credentials.
The GitHub repository contains the application code.
MongoDB Atlas contains the database.
They are separate.
GitHub
↓
Application Code
MongoDB Atlas
↓
Student Data
The GitHub repository does not need to contain the actual database password.
If you are another person using this project, you should create and use your own MongoDB Atlas account and database credentials.
Do not ask the project author for their .env file.
Create your own:
.env
and put your own:
MONGODB_URI=...inside it.
This keeps database credentials private and allows you to run your own copy of the project.
If you already understand the detailed instructions above, the basic setup is:
git clone https://github.com/shefrinx/hi_students.gitnpm installCreate a free database deployment and database user.
Add your current IP address in MongoDB Atlas Network Access.
MongoDB Atlas → Connect → Drivers
MONGODB_URI=your_mongodb_connection_stringnpm starthttp://localhost:3000
That's it.
Used to create the structure of the web page.
Used to design and style the web page.
Used to add functionality and communicate with the backend.
Used to run JavaScript on the server.
Used to create the backend server and API endpoints.
Used as the database.
Provides MongoDB as a cloud database.
Used for version control.
Used to store and share the project source code.
This project is useful for learning the basics of full-stack web development.
You can learn:
- Frontend development
- Backend development
- REST APIs
- CRUD operations
- Node.js
- Express.js
- MongoDB
- MongoDB Atlas
- Environment variables
.envfiles- Git
- GitHub
- Client-server communication
- Database operations
Shefrin Xavier A
Instagram:
https://www.instagram.com/shefrin.a/
B.E. Electronics and Communication Engineering
GitHub:
This project is available for learning and educational purposes.