A Command Line Interface (CLI) application for managing students, courses, enrollments, and grades.
Built with Python following best practices in clean architecture and modular design.
- Add students and courses
- Enroll students in courses
- Add and validate grades (0-100)
- Calculate course averages and student GPA
- Persistent storage using JSON file
- Input validation with user friendly error messages
- Structured logging
- Unit tests with mocking
- Sample data seeding
python -m venv venv
venv\Scripts\activate
source venv/bin/activate
python scripts/seed.py
- 3 sample students
- 2 sample courses
- Several enrollments with grades
# Add a new student
python main.py add-student "Milot Hyseni"
# Add a new course
python main.py add-course CS101 "Introduction to Programming"
# Enroll a student in a course
python main.py enroll 1 CS101
# Add a grade to a student's course
python main.py add-grade 1 CS101 92
# List all data
python main.py list-students
python main.py list-courses
python main.py list-enrollments
# View averages
python main.py avg 1 CS101
python main.py gpa 1
Example Outputs
Student created: Milot Hyseni with ID: 1
Grade 92 added successfully for student 1 in CS101
Average for student 1 in CS101: 89.50
GPA for student 1: 87.25
python main.py add-student "Student Name"
python main.py add-course CODE "Course Title"
python main.py enroll STUDENT_ID COURSE_CODE
python main.py add-grade STUDENT_ID COURSE_CODE GRADE
python main.py list-students
python main.py list-courses
python main.py list-enrollments
python main.py avg STUDENT_ID COURSE_CODE
python main.py gpa STUDENT_ID
python -m unittest tests.test_service -v
textlogs/app.log
- Layered Architecture: Clear separation between Models, Storage, Business Logic (Service), Utils, and CLI layers for better maintainability and testability.
- Relative Imports: Demonstrated inside the package as required.
- Input Validation: Handled at multiple levels (models, utils, and argparse) with clear error messages.
- Testing Strategy: Unit tests focus on the service layer using mocking to isolate business logic from file I/O.
- Logging: Centralized using Python’s logging module for better debugging.
- Uses simple JSON file storage (not suitable for concurrent access or large scale use).
- No support for deleting or updating students/courses/grades.
- GPA calculation is a simple average of course averages (no credit hour weighting).
- Single user application only.
- No advanced reporting or export features.
Project Structure
textGradebook_CLI/
├── main.py
├── README.md
├── gradebook/
│ ├── __init__.py
│ ├── models.py
│ ├── service.py
│ ├── storage.py
│ └── utils.py
├── scripts/
│ └── seed.py
├── tests/
│ └── test_service.py
├── data/ # Auto created (gradebook.json)
└── logs/ # Auto created (app.log)
- Python 3 Standard Library only (argparse, json, logging, unittest, os)
No external dependencies required.