# khangphamchuchi/swp391-sp25 architecture

> Architecture diagram of the GitHub repository khangphamchuchi/swp391-sp25, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khangphamchuchi/swp391-sp25
- Repository: https://github.com/khangphamchuchi/swp391-sp25

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Application Subgraph
    subgraph "Client Application"
        Entry("index.html"):::client
        Main("src/main.tsx"):::client
        App("src/App.tsx"):::client
        Entry -->|"loads"| Main
        Main -->|"bootstraps"| App
    end

    %% Feature Modules Subgraph
    subgraph "Feature Modules"
        AuthModule("Authentication Module"):::feature
        BlogModule("Blog Module"):::feature
        BookingModule("Booking Module"):::feature
        DashboardModule("Dashboard Module"):::feature
        QuizModule("Quiz Module"):::feature
        ScheduleModule("Schedule Module"):::feature
        ServicesModule("Services Module"):::feature
        SkinTherapistModule("Skin Therapist Module"):::feature
        SkinTypeModule("Skin Type Module"):::feature
        UserModule("User Module"):::feature
    end

    %% Shared Infrastructure Subgraph
    subgraph "Shared Infrastructure"
        SharedComponents("Components & Assets"):::shared
        AuthContext("AuthGuard Context"):::shared
        AxiosConfig("Axios Configuration"):::external
        FirebaseService("Firebase Service"):::external
    end

    %% Connections from App to Feature Modules
    App -->|"routes"| AuthModule
    App -->|"routes"| BlogModule
    App -->|"routes"| BookingModule
    App -->|"routes"| DashboardModule
    App -->|"routes"| QuizModule
    App -->|"routes"| ScheduleModule
    App -->|"routes"| ServicesModule
    App -->|"routes"| SkinTherapistModule
    App -->|"routes"| SkinTypeModule
    App -->|"routes"| UserModule

    %% Connections from App to Shared Infrastructure
    App -->|"includes"| SharedComponents
    App -->|"uses"| AuthContext
    App -->|"calls"| AxiosConfig
    App -->|"integrates"| FirebaseService

    %% Class Definitions for Styling
    classDef client fill:#ccf,stroke:#333,stroke-width:2px;
    classDef feature fill:#cfc,stroke:#333,stroke-width:2px;
    classDef shared fill:#ffc,stroke:#333,stroke-width:2px;
    classDef external fill:#fdd,stroke:#333,stroke-width:2px;

    %% Click Events for Client Application
    click Entry "https://github.com/khangphamchuchi/swp391-sp25/blob/main/index.html"
    click Main "https://github.com/khangphamchuchi/swp391-sp25/blob/main/src/main.tsx"
    click App "https://github.com/khangphamchuchi/swp391-sp25/blob/main/src/App.tsx"

    %% Click Events for Feature Modules
    click AuthModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/authentication"
    click BlogModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/blog"
    click BookingModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/booking"
    click DashboardModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/dashboard"
    click QuizModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/quiz"
    click ScheduleModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/schedule"
    click ServicesModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/services"
    click SkinTherapistModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/skin_therapist"
    click SkinTypeModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/skin_type"
    click UserModule "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/features/user"

    %% Click Events for Shared Infrastructure
    click SharedComponents "https://github.com/khangphamchuchi/swp391-sp25/tree/main/src/components and src/assets"
    click AuthContext "https://github.com/khangphamchuchi/swp391-sp25/blob/main/src/contexts/AuthGuardContext.tsx"
    click AxiosConfig "https://github.com/khangphamchuchi/swp391-sp25/blob/main/src/axios.ts"
    click FirebaseService "https://github.com/khangphamchuchi/swp391-sp25/blob/main/src/firebase/firebase.ts"
```
