Course Registrations
The course registration feature enables students to register for courses for the current semester. The feature ensures students have paid at least 50% of their semester fees before allowing them to register for courses. The system displays available courses for the student's program and facilitates a seamless registration process.
Features
- Session Management: Ensures the user is logged in and has a valid session.
- Payment Verification: Checks if the student has paid at least 50% of their semester fees.
- Course Display: Shows available courses for the student's program.
- Course Registration: Allows students to register for courses if they meet the payment criteria.
- Loading State: Displays a loading indicator during the registration process.
- Error Handling: Provides user-friendly error messages in case of issues.
Flow Diagram
+-------------------+
| User Logs In |
+-------------------+
|
v
+-------------------+
| Session Check |
+-------------------+
|
+-----+-----+
| |
v v
+--------+ +-----------------+
| Valid | | Invalid Session |
+--------+ +-----------------+
| |
| v
| +-----------------+
| | Show Error |
| | Message |
| +-----------------+
v
+------------------------+
| Fetch Student Data |
+------------------------+
|
v
+------------------------+
| Fetch Available Courses|
+------------------------+
|
v
+------------------------+
| Check Payment Status |
+------------------------+
|
+-----+-----+
| |
v v
+--------+ +-----------------+
|Payment | | Payment < 50% |
|>= 50% | +-----------------+
+--------+ |
| v
| +-----------------+
| | Show Payment |
| | Alert |
| +-----------------+
v
+------------------------+
| Display Courses |
+------------------------+
|
v
+------------------------+
| Course Selection |
+------------------------+
|
v
+------------------------+
| Register Courses |
+------------------------+
|
+-----+-----+
| |
v v
+--------+ +-----------------+
|Success | | Registration |
+--------+ | Fails |
| +-----------------+
| |
| v
| +-----------------+
| | Show Registra- |
| | tion Error |
| +-----------------+
v
+------------------------+
| Show Registration |
| Success |
+------------------------+
Architecture
Frontend
- React: Used for building the user interface.
- Next.js: Server-side rendering and API routes.
- Tailwind CSS: Styling framework.
- React Loader Spinner: Loading indicators.
- Sonner: Toast notifications for user feedback.
Backend
- Prisma: ORM for database interactions.
- PostgreSQL: Database to store user, course, and registration data.
Technical Implementation
Session Management
- User Authentication: The system checks if the user is logged in and has a valid session.
- Session Retrieval: If the session is valid, the system retrieves user information including user ID.
Fetch Student Data
- Fetch Student Information: The system fetches the student's data including their program and current semester.
- Fetch Available Courses: Based on the student's program, the system retrieves the available courses for the current semester.
Payment Verification
- Check Payment Status: The system checks if the student has paid at least 50% of their semester fees.
- Display Payment Alert: If the student has not paid enough, an alert is shown indicating the need to pay 50% of the fees.
Course Display
- Display Courses: If the student has paid enough, the system displays the available courses for the current semester.
- Course Selection: The student can select the courses they want to register for.
Course Registration
- Register Courses: Once the student selects the courses, the system registers the student for the selected courses.
- Loading Indicator: A loading indicator is shown during the registration process.
- Registration Success/Failure: Upon successful registration, a success message is shown. If registration fails, an error message is displayed.
Error Handling
- Session Errors: If the session is invalid, an error message is shown, prompting the user to log in again.
- Data Fetching Errors: If there are issues fetching student data or available courses, appropriate error messages are displayed.
- Payment Verification Errors: If there are issues verifying payment status, an error message is shown.
- Registration Errors: If course registration fails, an error message is displayed with the failure reason.