This feature integrates the frontend Admin Dashboard with the backend Admin Controller REST API to enable persistent storage of student records. Currently, the Admin Dashboard manages student data using local React state, which is lost when the page refreshes. This integration connects the frontend to the Spring Boot backend, allowing student data to be stored in the database and accessed across sessions.
Frontend Component: frontend/src/pages/Admin_View/AdminDashboard.jsx
Backend Controller: Backend/backend/src/main/java/com/university/backend/controllers/AdminController.java
API Base URL: http://localhost:8081/api/admin
This integration adds the following capabilities to the Admin Dashboard:
- ✅ Create Student - POST request to persist new student records to the database
- ✅ Retrieve Student - GET request to fetch individual student details from the backend
- ✅ Delete Student - DELETE request to remove student records from the database
- ✅ Generate Transcript - GET request to generate formatted transcripts for students
- ✅ Loading Indicators - Visual feedback during API operations
- ✅ Error Handling - User-friendly error messages for network failures and API errors
- ✅ Authentication - JWT token-based authentication for all API requests
- ✅ Data Persistence - Student records survive page refreshes and are accessible across sessions
The integration uses the following existing backend endpoints:
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /api/admin/students |
Create a new student record |
| GET | /api/admin/students/{studentId} |
Retrieve a specific student |
| DELETE | /api/admin/students/{studentId} |
Delete a student record |
| GET | /api/admin/students/{studentId}/transcript |
Generate student transcript |
The frontend and backend use slightly different field names. The integration includes transformation functions to handle these differences:
| Frontend Field | Backend Field | Type |
|---|---|---|
code |
studentId |
String |
cgpa |
gpa |
Number |
academicHistory |
completedCourses |
Array |
name |
name |
String |
email |
email |
String |
phone |
phone |
String |
status |
status |
String |
┌─────────────────────────────────────┐
│ Admin Dashboard Component │
│ (React Frontend) │
│ │
│ • Student List View │
│ • Student Detail View │
│ • Create/Edit Forms │
│ • API Helper Functions │
└─────────────────────────────────────┘
│
│ HTTP/JSON (fetch API)
│ JWT Authentication
▼
┌─────────────────────────────────────┐
│ Admin Controller │
│ (Spring Boot Backend) │
│ │
│ • Request Validation │
│ • Business Logic │
│ • Database Operations │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Database (JPA Repository) │
└─────────────────────────────────────┘
- ✅ Requirements document
- ✅ Design document
- ✅ Implementation task list
- ⏳ API helper functions (createStudent, getStudent, deleteStudent, getTranscript)
- ⏳ Data transformation functions (toBackendFormat, toFrontendFormat)
- ⏳ Loading state management
- ⏳ Error handling and display
- ⏳ Form submission integration
- ⏳ Student selection integration
- ⏳ Transcript generation UI
- ⏳ Initial data loading from backend
- Backend Running: Ensure the Spring Boot backend is running on
http://localhost:8081 - Database: Verify the database is accessible and properly configured
- Authentication: Ensure you can log in and obtain a valid JWT token
- CORS: Backend must allow requests from the frontend origin
API functions are defined within AdminDashboard.jsx rather than a separate module, following the existing pattern in frontend/src/auth/login.js.
Transformation functions handle field name differences between frontend and backend, providing clean separation and making future changes easier.
Uses try-catch blocks with user-friendly error messages, maintaining UI stability during errors and providing clear feedback.
Local state is updated only after successful backend operations to ensure data consistency and avoid rollback complexity.
The implementation does not use optimistic updates due to potential backend validation failures. UI updates occur after backend confirmation.
The integration handles the following error scenarios:
| Error Type | HTTP Status | User Message |
|---|---|---|
| Network Failure | N/A | "Connection failed. Please check your network." |
| Not Found | 404 | "Student not found." |
| Validation Error | 400 | Backend error message displayed |
| Server Error | 500 | "Server error occurred. Please try again." |
| Duplicate Student | 400 | "Student with this ID already exists." |
All API requests include JWT authentication:
const token = localStorage.getItem('token');
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}The token is obtained during login and stored in localStorage. If the token is missing or invalid, API requests will fail with a 401 Unauthorized error.
-
No Edit Endpoint: The backend Admin Controller does not have a PUT endpoint for updating students. Edit functionality remains local-only until the backend is updated.
-
No Bulk Operations: The current implementation handles one student at a time. Bulk operations are not supported.
-
No Pagination: All students are loaded at once. For large datasets, pagination should be implemented in the future.
-
No Real-time Updates: Changes made by other users are not reflected until the page is refreshed.
- Update Student Endpoint: Add PUT endpoint to backend for updating student records
- Bulk Operations: Support creating, updating, or deleting multiple students at once
- Pagination: Implement server-side pagination for better performance with large datasets
- Search on Backend: Move search and filtering to backend for improved performance
- Caching: Implement client-side caching to reduce API calls
- Optimistic Updates: Update UI immediately and rollback on failure
- Real-time Sync: Use WebSockets for live data synchronization
- Offline Support: Cache data for offline access
- Verify backend is running on
http://localhost:8081 - Check CORS configuration in backend
- Verify network connectivity
- Ensure you're logged in
- Check that JWT token exists in localStorage
- Verify token hasn't expired
- Verify student ID is correct
- Check that student exists in database
- Ensure database connection is working
- Verify backend is saving to database
- Check database connection settings
- Review backend logs for errors
- Backend Controller:
Backend/backend/src/main/java/com/university/backend/controllers/AdminController.java - Frontend Component:
frontend/src/pages/Admin_View/AdminDashboard.jsx
For questions or issues:
- Review the design document for technical details
- Check the requirements document for expected behavior
- Consult the backend AdminController source code
- Review the existing authentication pattern in
frontend/src/auth/login.js
When implementing this feature:
- Follow the task list in sequential order
- Test each feature before moving to the next
- Maintain the existing UI and user experience
- Use the existing code patterns (especially from login.js)
- Add comments explaining complex logic
- Handle all error cases gracefully
This is part of the University Management System project.