This is a console-based Student Management System written in C++ that allows you to manage a list of students with functionalities to add, remove, update, and search student information. Student data is persisted in a JSON file.
- Description
- Source Code Structure
- Design Patterns
- Dependencies
- Installation
- Compilation (Windows)
- Usage
- Screenshots
- Contributing
- License
The Student Management System provides the following functionalities:
- Add New Student: Allows adding a new student to the system with details such as ID, name, date of birth, gender, faculty, course, program, address, email, phone number, and status.
- Delete Student: Removes a student from the system based on their Student ID.
- Update Student Information: Updates the information of an existing student based on their Student ID.
- Search Student: Searches for students by name or Student ID.
- Data storage: Using JSON for storing directly to local files.
- Advanced Search: Allow students searching by Faculty filter.
- Import/export records: Allow user to import records as CSV/JSON and vice versa.
- Logging mechanism: System automatically logs any meaningful operations or errors for troubleshooting issues.
- Development build information: Display build version and build date at the top of the console application, all information is stored in
version_info.json
file. - Dynamic attributes: Such attributes like Faculty, Program, Status is allowed to be added or audited by administrator. The system will provide 5 Faculty entities, 4 Status entities and 3 Program entities by default.
All student data is stored in a JSON file (students.json
) for persistence. The system performs data validation on email, phone number, faculty, and student status.
-
Unique Student ID: Ensures that each Student ID (MSSV) is unique. When adding or updating student records, duplicate Student IDs are not allowed.
-
Configurable Email Domain: The system enforces email validation based on a specific domain, which can be configured dynamically. Example: Only accepts emails ending with @student.university.edu.vn.
-
Phone Number Validation by Country: Validates phone numbers based on country-specific formats, which are configurable. Example: Vietnam phone numbers must start with +84 or 0[3|5|7|8|9]xxxxxxxx.
-
Restricted Student Status Transitions: Student status can only be changed following predefined rules, which are configurable. Example: "Đang học" → "Bảo lưu", "Tốt nghiệp", "Đình chỉ" (valid transitions). "Đã tốt nghiệp" cannot be reverted to "Đang học".
All these enhancements ensure data integrity and improve system configurability while maintaining the JSON-based storage approach.
The source code is structured as follows:
main.cpp
: Contains the main function and the program's user interface.Student
class: Represents a student with attributes like ID, name, date of birth, etc., and methods for displaying information and serializing/deserializing to/from JSON.StudentValidator
class: An interface for validating student data.ConcreteStudentValidator
class: Implements theStudentValidator
interface and provides concrete validation rules for email, phone number, faculty, and status.StudentRepository
class: A Singleton class responsible for managing the list of students, including adding, removing, searching, and updating student information. It also handles loading and saving data to thestudents.json
file.nlohmann/json.hpp
: A header-only library for JSON manipulation, located in thenlohmann
folder.Logger.hpp
: Provides a Logger class following the Singleton pattern to log system events into thestudent_management.log
file.ConfigManager.hpp
: Manages system configuration, including valid email suffixes and phone number regex patterns. The configuration is stored and loaded from theconfig.json
file.RecordIO.hpp
: Provides functions for exporting and importing data in CSV and JSON formats, enabling easy storage and retrieval of student information from files.StatusRulesManager.hpp
: Manages student status transition rules, such as from "Active" to "Graduated." These rules are stored and loaded from thestatus_rules.json
file.
The application enforces the following validation rules:
- Email: Checks for a valid email format (e.g., using a regular expression).
- Phone Number: Validates that the phone number matches a specific format (e.g., using a regular expression or length check).
- Faculty: Ensures that the entered faculty matches one of the allowed values:
- Faculty of Law (FL)
- Faculty of Business English (FBE)
- Faculty of Japanese (FJPN)
- Faculty of French (FFR)
- Student Status: Validates that the entered status matches one of the allowed values:
- Active
- Graduated
- Leave
- Absent
This project utilizes the following design patterns to improve its structure, maintainability, and extensibility:
-
Singleton: The
StudentRepository
class is implemented as a Singleton. This ensures that only one instance of the repository exists throughout the application's lifetime. This is beneficial for managing the student data in a centralized and controlled manner, preventing inconsistencies that might arise from multiple instances modifying the data.- Purpose: Ensures a class has only one instance and provides a global point of access to it.
- Implementation: A private constructor prevents direct instantiation. A static method (
getInstance()
) provides access to the single instance, creating it if it doesn't already exist.
-
Strategy: The
StudentValidator
interface and its concrete implementation (ConcreteStudentValidator
) demonstrate the Strategy pattern. This pattern allows you to define a family of algorithms (in this case, validation rules) and make them interchangeable at runtime.- Purpose: Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
- Implementation: The
StudentValidator
interface defines theisValid()
method.ConcreteStudentValidator
implements this method with specific validation logic. TheStudentRepository
uses theStudentValidator
interface, allowing it to easily switch between different validation strategies (e.g., a more strict validator, a validator that checks for data consistency with external systems, etc.) without modifying theStudentRepository
class itself. This makes the validation process more flexible and extensible.
- C++ Compiler: A C++11 compatible compiler (e.g., MinGW with g++, Microsoft Visual C++).
- nlohmann/json library: A header-only JSON library for C++, located in the
nlohmann
folder within the project directory. Thejson.hpp
file should be present in thenlohmann
folder.
No explicit installation is required. Simply clone or download the source code and ensure you have the necessary dependencies. Specifically, make sure the nlohmann
folder containing json.hpp
is in the same directory as main.cpp
.
Here's how to compile the program using either CodeBlocks or Visual Studio on Windows:
- Open CodeBlocks.
- Create a New Project:
- Go to
File -> New -> Project...
- Select
Console application
and clickGo
. - Click
Next
. - Select
C++
as the language. - Give your project a name (e.g.,
StudentManager
) and choose a location. ClickNext
. - Ensure that the compiler is set to
GNU GCC Compiler
. ClickFinish
.
- Go to
- Add Source File:
- In the
Project
pane (usually on the left), right-click onSources
and selectAdd files...
- Navigate to the location of your
main.cpp
file and select it. ClickOpen
.
- In the
- Include Directory:
- Right-click on your project's name in the
Projects
pane and selectBuild options...
- Select the compiler (e.g.,
GNU GCC Compiler
). - Go to the
Search directories
tab. - Under the
Compiler
tab, clickAdd
. - Browse to the
nlohmann
folder (the one containingjson.hpp
) and select it. ClickOK
. - Click
OK
to close theProject build options
window.
- Right-click on your project's name in the
- Enable C++11:
- Right-click on your project's name in the
Projects
pane and selectBuild options...
- Select the compiler (e.g.,
GNU GCC Compiler
). - Go to the "Compiler settings" tab
- Check the box "Have g++ follow the C++11 ISO standard"
- Click OK
- Right-click on your project's name in the
- Build the Project:
- Go to
Build -> Build
(or pressCtrl+F9
).
- Go to
- Run the Program:
- Go to
Build -> Run
(or pressCtrl+F10
).
- Go to
- Open Visual Studio.
- Create a New Project:
- Go to
File -> New -> Project...
- Select
Console App
(orConsole Application
). - Give your project a name (e.g.,
StudentManager
) and choose a location. ClickCreate
.
- Go to
- Add Source File:
- In the
Solution Explorer
pane (usually on the right), right-click onSource Files
and selectAdd -> Existing Item...
- Navigate to the location of your
main.cpp
file and select it. ClickAdd
.
- In the
- Include Directory:
- In the
Solution Explorer
pane, right-click on your project's name and selectProperties
. - In the
Property Pages
window, selectC/C++ -> General
. - In the
Additional Include Directories
field, add the path to thenlohmann
folder (the one containingjson.hpp
). For example:$(SolutionDir)nlohmann
. - Click
Apply
and thenOK
.
- In the
- Enable C++11 (or later):
- In the
Property Pages
window, selectC/C++ -> Language
. - Set
C++ Language Standard
toISO C++11 Standard
(or a later standard like C++14 or C++17). - Click
Apply
and thenOK
.
- In the
- Build the Solution:
- Go to
Build -> Build Solution
(or pressCtrl+Shift+B
).
- Go to
- Run the Program:
- Go to
Debug -> Start Without Debugging
(or pressCtrl+F5
).
- Go to
To run the compiled program:
-
Navigate to the directory containing the executable (if not running from the IDE): The executable will typically be located in a
Debug
orRelease
folder within your project directory. -
Execute the program:
- From the command prompt or file explorer, run the executable file (e.g.,
StudentManager.exe
). - If running from the IDE, the program will usually start automatically after building.
- From the command prompt or file explorer, run the executable file (e.g.,
-
Follow the on-screen menu to interact with the program:
The program will present a menu with options to add, delete, update, and search students. Student data will be saved in the
students.json
file in the same directory as the executable.
The coding style is followed to the C++ coding standards. Use meaningful variable names, provide comments where necessary, and ensure the code is well-formatted.
This project is licensed under the MIT License.