How se2-9/frontend works
Main Components
• Frontend UI Layer:
• This includes all the UI components located in the "src/components" folder. They encompass specialized components for authentication (login form, registration forms), user profile management, payment processing, posts, requests, reviews, and other reusable UI pieces (e.g., buttons, dialogs, forms).
• Generic UI components under "src/components/ui" that form the building blocks of the application interface.
• Page Routing and Layout:
• "src/app" directory. This folder contains the Next.js page components for various routes such as authentication (login, registration, verify-code), profiles, payment, student and tutor related pages, and error handling (not-found.tsx).
• Layout components (global layout, globals.css, navigation bars) that define the overall structure.
• Data Management and Business Logic:
• The "src/lib" folder groups API service functionalities (in subdirectories like "api" and "validations"). These modules encapsulate communication with back-end endpoints, authentication, payment, post management, and more.
• Similarly, include "src/dtos" and "src/types" which define data structures and contracts, ensuring type safety and consistency.
• State Management and Hooks:
• "src/store" directory (e.g., auth-store, post-store) and custom hooks in "src/hooks" that manage global state and side effects like fetching data from APIs.
• Providers and Integration Points:
• Components in "src/providers" (e.g., auth-providers, query-providers) integrate the state management and API data into the component hierarchies via React contexts or other provider patterns.
• Utility Functions:
• "src/utils" and mapping functions under "src/utils/mapper" that transform data and encapsulate shared helper functions.
• Configuration & Deployment:
• Don’t forget the configuration artifacts such as "next.config.ts", "Dockerfile", "docker-compose.yml", and various linting/formatting configurations. These are key to understanding how the application is built, linted, and deployed.
Out Relationships and Interactions
• The View Layer (UI Components and Pages)
• The Data/Business Logic Layer (API Services, Validations, DTOs)
• The State Management Layer (Stores and Hooks)
• Integration Providers that tie components with state and data APIs
• From the UI (pages and components) to the API layer (lib/api) where server communication occurs.
• From API calls to state updates in the stores and hooks.
• From providers wrapping the UI components to the context in which they receive state and API data.
• If applicable, note external services (e.g., payment services like Omise) that are used via API calls documented in the "src/lib/api/payment.ts" and corresponding DTOs.
Important Architectural Patterns and Design Principles
• Modular Design – The project adheres to separation-of-concerns by breaking down UI, business logic, and state management into distinct directories.
• Next.js Routing – The “src/app” structure indicates the use of Next.js app directory routing, where each folder (and nested groupings like (auth), student, tutor) denotes a specific route and view.
• Reusability – Many reusable UI components are centralized under "src/components/ui", and business logic is abstracted into logical API layers.
• Integration of third-party services – Notice the presence of third-party payment handling (Omise) and validations, which suggests integration considerations on the API layer.