A complete Student Management System built in Python — featuring both a Command-Line Interface (CLI) version and a fully interactive Streamlit Web App.
This system allows you to add, update, view, delete, search, filter, import, export, and manage student records stored securely in a JSON database.
This project provides two versions of the system:
A terminal-based system with menu-driven options:
- Add a student
- Update student details
- View one student
- View all students
- Remove a student
- Automatically generate a unique Student ID
- Store all data in
students.json
A modern, interactive UI with:
- Dashboard view
- Search by name, email, or ID
- Filter by age
- Filter by course
- View & inspect full student details
- Add, update, delete students
- Import/Export student records (JSON download / upload)
- Course-based filtering
- Dataset preview
- Defined a
Studentclass to encapsulate all student-related data and behavior. - Used class attributes (
data,database) shared across all instances to hold the in-memory dataset and file path. - Used instance methods (
addstudent,updatestudent,viewstudent,removestudent,viewall) for CRUD operations.
class Student:
database = 'students.json'
data = []@staticmethod— used for__generatestudentid()because it doesn't need access to the class or any instance.@classmethod— used for__update()because it needs the class reference (cls) to open the correct database file.
@staticmethod
def __generatestudentid():
...
@classmethod
def __update(cls):
with open(cls.database, 'w') as fs:
fs.write(json.dumps(Student.data))Learned how to generate a human-readable unique student ID by combining:
random.choices(string.ascii_letters, k=7)— 7 random lettersrandom.choices(string.digits, k=4)— 4 random digitsrandom.choices("!@#$%&", k=1)— 1 special characterrandom.shuffle()— shuffle all parts together.capitalize()— make the first character uppercase
alpha = random.choices(string.ascii_letters, k=7)
num = random.choices(string.digits, k=4)
spchr = random.choices("!@#$%&", k=1)
id = alpha + num + spchr
random.shuffle(id)
return "".join(id).capitalize()- Learned to read a JSON file on startup with
json.loads()and write back withjson.dumps(). - Used
pathlib.Path.exists()to safely check if the database file exists before opening it, and create it if it doesn't.
if Path(database).exists():
with open(database) as fs:
data = json.loads(fs.read())
else:
with open(database, 'w') as fs:
fs.write('[]')| Operation | Method | Description |
|---|---|---|
| Create | addstudent() |
Collects input, validates age, saves |
| Read | viewstudent() |
Finds one student by ID |
| Read All | viewall() |
Displays all students in the dataset |
| Update | updatestudent() |
Looks up by ID, allows partial updates |
| Delete | removestudent() |
Confirms with user before deleting |
Used list comprehensions to filter the in-memory list by student ID:
studdata = [i for i in Student.data if i['studentid'] == stuid]- Validated that a student's age is 8 or above before creating a record.
- Allowed users to skip fields during an update (press Enter to keep the old value).
- Wrapped file I/O and user input in
try/exceptblocks to handle errors gracefully.
try:
resp = int(input("Enter your response: "))
except Exception as err:
print(f"An error occured as {err}")Built an interactive console loop that keeps running until the user presses 6 to exit.
while True:
print("Press '1' to add student.")
...
if resp == 6:
breakExtended the project into a web UI, learning:
- Forms (
st.form) for grouped input with a single submit action - Session state (
st.session_state) to persist data between re-renders - Sidebar navigation (
st.sidebar.radio) for page routing - Dataframes (
st.dataframe) to display tabular student data - File upload/download (
st.file_uploader,st.download_button) for JSON import/export - Atomic file writes (write to
.tmpthen rename) to avoid data corruption
| Technology | Purpose |
|---|---|
| Python | Core language |
json |
Persistent data storage |
pathlib |
Safe file path handling |
random & string |
Unique ID generation |
datetime |
Timestamps on records |
| Streamlit | Interactive web UI |
- Clone the repo:
git clone <repo-url>
cd StudentManagementProject- Run the CLI program:
python studentmagnmt.py- Install dependencies:
pip install streamlit- Run the app:
streamlit run app.pyYour browser will open the app automatically.
- ✅ Add a student with auto-generated ID
- ✅ Update name, email, and courses
- ✅ View a single student by ID
- ✅ View all students
- ✅ Remove a student with confirmation
- ✅ Dashboard — search by keyword, filter by age & course
- ✅ Add Student form with validation and auto ID
- ✅ Update or delete any student
- ✅ Import/Export full dataset as JSON
- ✅ Dataset preview (first 10 rows)