How khangphamchuchi/swp391-sp25 works
Main Components
• Client Application: This encompasses the overall React application starting from index.html and bootstrapped by src/main.tsx.
• Core App Component: Represented by src/App.tsx that acts as the wrapper for routing and overall UI layouts.
• Feature Modules: Each domain (authentication, blog, booking, dashboard, quiz, schedule, services, skin_therapist, skin_type, user) is organized under the src/features directory. Treat each feature as a distinct module with its own components, hooks, DTOs, and possibly page-level components.
• Global Contexts: For example, AuthGuardContext in src/contexts is used for managing authentication state and route protection.
• External Services & Utilities:
– Axios configuration (src/axios.ts) for API calls.
– Firebase integration (under src/firebase) for backend or real-time services.
Understand the Relationships and Interactions
• The Root of the App (loaded via index.html and main.tsx) initiates the App component which then sets up routing between various pages such as HomePage, CustomerProfilePage, NotFoundPage, etc.
• The Feature Modules interact with the global state through React Contexts (e.g., AuthGuardContext) and with external systems/services by using API calling hooks (axios utilities and Firebase for specific functions).
• The separation of concerns is achieved as the UI components (present in each feature’s components folder) are further decoupled with hooks managing data fetching, state updates, and invoking API endpoints with well-defined DTOs.
Architectural Patterns and Design Principles
• Modular Design: Each feature is isolated in its own folder containing components, hooks, DTOs, and pages, which align with principles of separation and reusability.
• Component-Based UI: The application makes extensive use of React components for building UI sections (e.g., NavBarMenu, SidebarMenu, modals, tables).
• Layered Architecture:
– Presentation Layer: UI components and pages.
– Business Logic/Data Fetching Layer: Custom hooks and utilities under each feature (e.g., useCreateBooking, useGetProfile).
– Service/Integration Layer: Axios configuration and Firebase integration handle external communication.
• Consistent State Management: Use of React Context for authentication coupled with a store-like structure in custom hooks for local state management.
Technologies, Frameworks, and Tools to Emphasize
• React and TypeScript for building robust components.
• Vite as the build tool and development server with hot module replacement.
• ESLint (with recommended configurations) for enforcing code quality, especially with type-aware linting.
• Firebase for external backend services.
• Axios for API calls to external REST services.
• Tailwind CSS (configured via tailwind.config.js) and plain CSS files governing styling and layout.