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 documentation

File 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:

  • GradeForge class: The main application class
  • run() 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:

  • Student class: The base class for all student types
  • HighSchoolStudent class: Represents a high school student
  • CollegeStudent class: Represents a college student
  • GRADE_POINTS dictionary: Maps letter grades to grade points for college students
  • VALID_LETTER_GRADES list: 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:

  • Subject class: 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:

  • Grade class: 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
    }
}
Do not modify the 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 Student subclasses demonstrates this
  • Liskov Substitution Principle (LSP): Instances of HighSchoolStudent and CollegeStudent can be used where Student is expected
  • Interface Segregation Principle (ISP): Classes have focused roles
  • Dependency Inversion Principle (DIP): The GradeForge class manages objects directly