How luongxuannhat/e_learning_fe works
Main Components of the System
• Frontend Application: Built with Next.js, it is composed of multiple route groups (pages) and specialized directories. Examples include pages for “educations”, “students”, “teachers”, “dang-ky-hoc-phan” (course registration), “quan-ly-*” (management modules for classes, courses, faculties, etc.), and more.
• Components & UI Elements: Under the “src/app/components” directory, you see reusable UI components (Alert, Navbar, Login Card, etc.) and other domain-specific widgets (video player, editor, paging).
• Middleware: The “src/middleware” directory contains authentication and authorization modules (Authen.tsx and Author.tsx) which enforce access controls.
• Models: Under “src/models”, there are definitions for key domain entities such as Attendance, Classes, ChatRoom, Document, Enrollment, Feedback, etc. These provide the data structures for the application’s business logic.
• Services: In “src/services”, you have business logic wrappers such as authService.ts and a general service module for backend interactions.
Relationships and Interactions
• The Entry Point (Next.js Routes): The “src/app” directory houses various routes (grouped by URL path, e.g., “(head-education)”, “quan-ly-hoc-phan”, “lop-hoc”, “tai-khoan”). Each of these components represents a distinct functional area (education management, course registration, account settings, etc.).
• UI and Reusable Components: Pages rely on components like the Navbar, Login Card, and sidebar built under “src/app/components” to keep the UI consistent and modular.
• Middleware Integration: As an access control layer, middleware (from “src/middleware”) intercepts page requests, checking authentication and authorization before requests hit the page components.
• Data Models and Services: The UI components and pages interact with the services layer (business logic) which in turn uses data models. This layer can be thought of as the “backend” logic even though it resides within the same Next.js project (typical for server-side rendering and API routes in Next.js).
Architectural Patterns and Design Principles
• Modular Routing: The extensive use of route folders under “src/app” suggests a deep modular approach where different user roles (secretaries, teachers, students, etc.) have dedicated pages and layouts.
• Separation of Concerns: UI components, middleware, data models, and services are clearly separated into different directories.
• Reusability: The design promotes reusable components (e.g., shared elements like login cards, alerts, navigation bars) which reduce duplication and improve maintainability.
• Next.js Specific Features: Leveraging Next.js’s file-based routing, dynamic routing (e.g., “[id]” folders), and middleware support.