File Structure
This page provides an overview of the file structure of the GradeForge project. Understanding the organization of the files will help you navigate the codebase more effectively.
Project Files
The GradeForge project consists of the following Python files:
gradeforge/
├── gradeforge.py # Main application file with GradeForge class
├── student.py # Student class definitions
├── subject.py # Subject class definition
├── grade.py # Grade class definition
├── gradeforge_data.json # Data storage file (created when saving data)
└── README.md # Project documentationFile Descriptions
gradeforge.py
This is the main application file that contains the GradeForge class. This class orchestrates the entire application, handling user interactions via the command-line interface, managing data persistence, and coordinating operations between students, subjects, and grades.
Key components:
GradeForgeclass: The main application classrun()method: The entry point for the CLI- Methods for each menu option (e.g.,
add_student(),assign_subject_to_student()) - Data persistence methods (
save_data(),load_data())
student.py
This file defines the base Student class and its specialized subclassesHighSchoolStudent and CollegeStudent. These classes represent different types of students with their specific attributes and behaviors.
Key components:
Studentclass: The base class for all student typesHighSchoolStudentclass: Represents a high school studentCollegeStudentclass: Represents a college studentGRADE_POINTSdictionary: Maps letter grades to grade points for college studentsVALID_LETTER_GRADESlist: Valid letter grades for college students
subject.py
This file defines the Subject class, which represents courses that students can enroll in. Each Student object holds its own instances of Subjectfor courses they are enrolled in.
Key components:
Subjectclass: Represents an academic subject or course- Methods for adding grades and calculating average grades
grade.py
This file defines the Grade class, which represents individual grade entries for components of a subject.
Key components:
Gradeclass: Represents a single grade entry- Attributes for description, score, and letter grade
gradeforge_data.json
This is the data storage file that is created when saving data. It stores all the student, subject, and grade data in JSON format.
The file structure is as follows:
{
"students": {
"STUDENT_ID_1": {
"name": "Student Name 1",
"student_id": "STUDENT_ID_1",
"type": "CollegeStudent", // or HighSchoolStudent, Student
"major": "Computer Science", // Only for CollegeStudent
"enrolled_subjects": {
"SUBJ_CODE_A": {
"name": "Subject A Name",
"code": "SUBJ_CODE_A",
"credit_hours": 3,
"grades": [
{
"description": "Midterm",
"score": 3.7, // Grade point for College, numeric for HS
"letter_grade": "A-" // Null for HS
}
// ... more grades for this subject for this student
]
}
// ... more subjects for this student
}
}
// ... more students
},
"available_subjects": { // These are subject templates
"SUBJ_CODE_X": {
"name": "Template Subject X Name",
"code": "SUBJ_CODE_X",
"credit_hours": 0 // Or a default, as set when template created
}
// ... more available subject templates
}
}gradeforge_data.json file manually unless you are familiar with its structure. Incorrect modifications can lead to data corruption and application errors.Class Hierarchy
The following diagram illustrates the class hierarchy in the GradeForge project:
Student (from student.py)
├── HighSchoolStudent (from student.py)
└── CollegeStudent (from student.py)
Subject (from subject.py)
Grade (from grade.py)
GradeForge (from gradeforge.py - Orchestrator/Application Class)Object-Oriented Design
The GradeForge project follows object-oriented design principles:
- Single Responsibility Principle (SRP): Each class has one primary responsibility
- Open/Closed Principle (OCP): The use of
Studentsubclasses demonstrates this - Liskov Substitution Principle (LSP): Instances of
HighSchoolStudentandCollegeStudentcan be used whereStudentis expected - Interface Segregation Principle (ISP): Classes have focused roles
- Dependency Inversion Principle (DIP): The
GradeForgeclass manages objects directly