How sp25se148/fucapstone_fe works
Main Components
a. Next.js Frontend (Presentation Layer):
• Pages under src/app – grouped by roles (login, admin, manager, student, supervisor, superadmin).
• Layouts and common components (found under src/components/layout, src/components/ui) that are reused on many pages.
• Dynamic routing that drives the UI experience.
b. API Routes (Backend Layer within Next.js):
• API endpoints under src/app/api (e.g., authentication routes for login and logout) which handle server-side logic.
• Server middleware (e.g., middleware.ts) processing requests.
c. State and Business Logic:
• Multiple context providers under src/contexts for handling global states related to each domain (admin, manager, student, supervisor, superadmin).
• Custom hooks under src/hooks for API calls and responsiveness.
d. Utility and Shared Modules:
• Libraries under src/lib and src/utils – containing utility functions and services like "signalRService" for real-time communications.
• Configuration and theming elements under src/components/theme.
e. External Integrations:
• Next/font integration and any optimization services provided by Next.js.
• Deployment configuration shown by Next.js deployment instructions and setup (for instance Vercel).
Relationships and Data Flow
• The presentation layer (pages/components) interacts with the state management layer (contexts and hooks) to fetch and manage data.
• On user actions (for example, form submissions on the login page or admin dashboard interactions), the UI components make API calls to the Next.js API routes.
• Middleware and server-side routes ensure proper authentication and configuration.
• Shared UI components (buttons, tables, modals, etc.) are used across different domain areas, ensuring a cohesive user experience.
• The various contexts (found in src/contexts) encapsulate business logic for different roles and share data among components.
• SignalR (or similar real-time utility) integrates closely with the state management and API response cycle to deliver live updates.
Architectural Patterns and Design Principles
• Modular Structure: Clear separation by role and functionality helps in maintaining and scaling.
• Layered Architecture: Distinct separation between presentation (pages and components), business logic (contexts and hooks), and server-side processing (API routes and middleware).
• Reusability and DRY: Use of shared components (in src/components/ui) and global contexts to avoid duplicate code.
• Role-Based Segmentation: Different directories for admin, manager, student, etc., indicate a role-based access and navigation flow.
Relevant Technologies
• Next.js – for both server- and client-side rendering.
• React – core library for building user interfaces.
• Context API & Custom Hooks – for state management.
• Tailwind CSS – as indicated by tailwind.config.ts.
• ESLint & TypeScript – for code quality and type safety.
• Possibly SignalR integration for real-time communications (as suggested by src/contexts/signalR-context.tsx and src/utils/signalRService.ts).