How shahriar-hossain-alvi/edutrack-frontend works
1. Project type and boundary
- This repository is the React frontend for Edutrack, a result management system.
- It does not contain the FastAPI/PostgreSQL backend; instead it consumes backend APIs for auth, user management, marks, courses, logs, and results.
2. Application shell
- The app boots from src/main.jsx, with global styling in src/index.css.
- Root-level concerns are provided by src/provider/AuthProvider.jsx and src/provider/ThemeProvider.jsx, which make authentication state and UI theme available across the tree.
3. Routing structure
- Routing is split by audience and access level:
- src/app/routes/Routes.jsx for the overall route composition
- AdminRoutes.jsx, TeacherRoutes.jsx, StudentRoutes.jsx for role-specific route sets
- Public pages include signin, error, and unauthorized screens.
- Private pages include authenticated views such as results and single-user details.
4. Access control and redirects
- src/components/RouteHandlers/PrivateRoutes.jsx protects authenticated routes.
- RoleBasedRedirects.jsx handles user-type redirection after login or when a role lands on an incompatible route.
- This makes authorization a routing concern in the frontend, mirroring the backend role model.
5. Layout hierarchy
- The UI uses separate shell layouts for different audiences:
- MainLayout.jsx
- AdminLayout.jsx
- TeacherLayout.jsx
- StudentLayout.jsx
- These layouts likely define shared chrome such as navigation, sidebars, and page framing, while the inner route content changes by role.
6. Authentication and API access
- src/hooks/useAuth.jsx exposes auth state and likely user profile/session details.
- src/utils/axios/axiosPublic.js and axiosSecure.js define two API clients:
- public requests for unauthenticated endpoints
- secure requests for authenticated endpoints
- useAxiosInterceptor.jsx is a key cross-cutting hook; it aligns frontend requests with the backend’s cookie-based JWT setup described in the README.
7. Feature areas by role
- Admin pages dominate the app:
- dashboard, users, departments/semesters, subjects, assigned courses, marks, audit logs, user creation
- Teacher pages focus on assigned courses and profile
- Student pages focus on offered courses, marks, and profile
- This suggests the frontend is organized around a role-based CRUD and read-only workflow model rather than a single generic dashboard.
8. Page composition pattern
- src/pages/* contains route-level screens.
- src/components/pageComponents/* contains the transactional or form-heavy UI used inside those pages.
- Examples:
- user creation tabs for students/teachers
- department and semester forms/tables
- mark insertion and mark update flows
- subject creation and course assignment flows
- This split keeps routing/page concerns separate from reusable domain UI.
9. Shared UI building blocks
- src/components/ui contains reusable presentation pieces:
- navbar, drawer sidebar, loading spinner, skeletons, charts, dashboard cards, recent audit logs, generic user forms
- These are used across multiple pages and layouts, acting as the frontend’s design system layer.
10. Hooks and client behavior
- useDebounce.jsx indicates request-throttled interactions, likely for search or filter inputs.
- useTheme.jsx centralizes theme switching.
- useAxiosSecure.jsx and useAxiosPublic.jsx encapsulate API client selection, keeping pages free from request plumbing.
11. Utilities and helpers
- src/utils/errorMessageParser/errorMessageParser.js normalizes backend/API errors into user-facing messages.
- src/utils/SectionHeader/SectionHeader.jsx is a small shared layout utility.
- This layer supports consistent UX around API failures and section presentation.
12. Data flow at a glance
- User signs in through the auth page.
- Auth state is stored in the provider and propagated through the app.
- Protected routes and role-based redirects determine which layout and pages are visible.
- Pages invoke secure/public axios clients to call the backend.
- Backend responses populate tables, dashboards, charts, and forms; errors are parsed into readable messages.
13. Deployment and runtime
- The frontend is built with Vite and deployed separately from the backend.
- Dockerfile and docker-compose.yml support containerized local development/builds.
- vercel.json indicates Vercel deployment support for the frontend.
- public/test_data.json suggests some local/mock data usage for development or UI testing.
14. Architecture summary
- Overall, this is a role-based single-page application with:
- auth/theme providers at the root
- route guards and role redirects
- separate layouts per user type
- page-level screens backed by reusable domain components
- centralized axios clients and hooks for API access
- The main architectural boundary is between this React client and the external FastAPI backend it consumes.
Main entry points: Routes.jsx Routes · useAxiosPublic.jsx API Hooks · Navbar.jsx Shared UI · AdminDashboard.jsx Admin Domain
Components 20
App Shell
Entry point and global providers
- Main · Vite React bootstrap
src/main.jsx - Auth Provider · Shares session and auth state
src/provider/AuthProvider.jsx - Theme Provider · Shares UI theme state
src/provider/ThemeProvider.jsx
Routing & Access
Route composition, guards, and role redirects
- Routes · Top-level route composition
src/app/routes/Routes.jsx - Private Routes · Protects authenticated screens
src/components/RouteHandlers/PrivateRoutes.jsx - Role Redirects · Sends users to role-appropriate screens
src/components/RouteHandlers/RoleBasedRedirects.jsx - Admin Layout · Admin chrome and framing
src/app/layout/AdminLayout.jsx - Teacher Layout · Teacher chrome and framing
src/app/layout/TeacherLayout.jsx - Student Layout · Student chrome and framing
src/app/layout/StudentLayout.jsx - Main Layout · Shared app framing
src/app/layout/MainLayout.jsx
Feature Areas
Role-based page sets and domain workflows
- Admin Domain · Dashboard, users, departments, semesters, subjects, marks, logs
src/pages/admin/AdminDashboard.jsx - Teacher Domain · Assigned courses and profile screens
src/pages/teacher/MyAssignedCourses.jsx - Student Domain · Offered courses, marks, and profile screens
src/pages/student/OfferedCourses.jsx - Auth & Public · Signin, error, and unauthorized pages
src/pages/auth/Signin.jsx
Shared Infrastructure
Reusable UI, hooks, and API plumbing
- API Hooks · Public/secure axios wrappers and interceptor
src/hooks/useAxiosPublic.jsx - Auth Hook · Reads auth/session state
src/hooks/useAuth.jsx - Theme Hook · Controls theme switching
src/hooks/useTheme.jsx - Debounce Hook · Throttles search and filter input
src/hooks/useDebounce.jsx - Shared UI · Navbar, sidebar, spinner, charts, cards, skeletons
src/components/ui/Navbar.jsx - Page Components · Forms, tables, and modals used inside pages
src/components/pageComponents/AddUserPage/CreateStudentTab.jsx
Connections 28
- Main → Auth Provider: wraps · Root providers mount around the app
- Main → Theme Provider: wraps · Root providers mount around the app
- Auth Provider → Routes: feeds state · Routes consume auth state
- Theme Provider → Main Layout: feeds state · Layouts and UI consume theme state
- Routes → Private Routes: uses · Authenticated branches are guarded
- Routes → Role Redirects: uses · Role-aware landing and fallback redirects
- Routes → Main Layout: renders · Shared public shell
- Routes → Admin Layout: renders · Admin route subtree
- Routes → Teacher Layout: renders · Teacher route subtree
- Routes → Student Layout: renders · Student route subtree
- Main Layout → Auth & Public: hosts · Public pages use the shared shell
- Admin Layout → Admin Domain: hosts · Admin screens render inside admin shell
- Teacher Layout → Teacher Domain: hosts · Teacher screens render inside teacher shell
- Student Layout → Student Domain: hosts · Student screens render inside student shell
- Auth & Public → Auth Hook: reads · Signin and public flow read auth state
- Admin Domain → API Hooks: calls · Admin workflows hit backend APIs
- Teacher Domain → API Hooks: calls · Teacher workflows hit backend APIs
- Student Domain → API Hooks: calls · Student workflows hit backend APIs
- Admin Domain → Page Components: composes · Page-level screens use transactional UI pieces
- Teacher Domain → Page Components: composes · Page-level screens use transactional UI pieces
- Student Domain → Page Components: composes · Page-level screens use transactional UI pieces
- Admin Domain → Shared UI: uses · Shared UI powers tables, cards, logs, and navigation
- Teacher Domain → Shared UI: uses · Shared UI powers layout and display
- Student Domain → Shared UI: uses · Shared UI powers layout and display
- API Hooks → Auth Hook: aligns with · Secure requests depend on auth/session state
- API Hooks → Debounce Hook: supports · Search and filter interactions can be throttled
- API Hooks → Shared UI: drives · Fetched data populates reusable UI
- Theme Hook → Shared UI: styles · Theme state affects shared presentation