# segciest/airbnb-project architecture

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

- Interactive diagram: https://gitdiagram.com/segciest/airbnb-project
- Repository: https://github.com/segciest/airbnb-project

## Overview

##### Main Components and Subsystems
- Frontend UI Layers:
- Pages: Located in the src/pages folder (e.g., HomePage, ChatPage, RoomDetail, etc.).
- Layouts: Found in src/layout (multiple layout components like Header, Footer, Messenger, etc.) that define the overall page structure.
- Templates: In src/templates, which are used by pages to render different views (AdminTemplate, ChatTemplate, HomeTemplate, etc.).
- Components: Reusable UI components in src/components (BackToTop, ChatAnimation, FormLogin, etc.), which encapsulate common functionality.

- Application Logic and Configuration:
- Service Layer: In src/services, with API calls and business logic related to authentication, room management, comment services, etc.
- Redux Store: Managed through src/redux with configuration in configStore.js and slices for various functionalities (e.g., listRoomSlice, userSlice, loadingSlice).

- Utility and Configuration Files:
- Routing: The src/routes folder includes custom routing logic.
- Utility functions: Found in src/utils for various helper tasks.
- Styling: SCSS files with components and layout styles; additional styles configured via PostCSS and Tailwind (tailwind.config.js is present).

##### Relationships and Interactions
- The highest level starts with src/main.jsx which bootstraps the React application, integrates Redux (via configStore.js), and sets up the routing (using useRouteCustom.jsx).
- The App.jsx component coordinates which Template or Layout to render based on the current route.
- Each page utilizes one of the available templates which then compose various layout and component pieces.
- The components folder includes reusable UI elements that get imported across pages and layouts.
- The services directory acts as an abstraction over API calls, providing a layer between the frontend and external data sources.
- Data flow is mainly managed by Redux; user actions dispatched in components update the state slices, and redux middleware might interact with service APIs.

##### Architectural Patterns and Design Principles
- Component-based Architecture: The project separates concerns using React components, pages, layouts, and templates.
- State Management Pattern: Use of Redux with well-defined slices ensures organized global state across the application.
- Separation of Concerns: Distinct directories for UI (components, layouts, pages), business logic (services), and state (redux) promote clarity and modularity.
- Service Abstraction: The services directory abstracts API calls and business rules, decoupling UI components from back-end logic.

##### Technologies and Frameworks
- React for the UI (components, JSX, templates).
- Redux for state management.
- Vite as the build tool.
- Sass/SCSS and Tailwind CSS for styling.
- Likely usage of React Router (or a custom routing solution in src/routes) to handle navigation.
- Dependencies as seen in package.json, along with configuration files like .eslintrc for linting and .prettierrc for formatting.

##### Elements
- Data flows from services to Redux slices.
- User actions in components trigger Redux state changes.
- Routing logic connects pages with relevant templates and layouts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry and Bootstrapping
    subgraph "Entry and Bootstrapping"
        EP("Entry Point (main.jsx)"):::entry
        APP("App Component (Router & Redux Integrator)"):::app
    end

    %% Frontend UI Layers
    subgraph "Frontend UI Layers"
        P("Pages"):::ui
        T("Templates"):::ui
        L("Layouts"):::ui
        C("Reusable Components"):::ui
        A("Assets (Images & Animations)"):::ui
    end

    %% Application Logic & State Management
    subgraph "Application Logic & State"
        S("Service Layer (API Calls & Business Logic)"):::service
        RS("Redux Store & State Slices"):::state
    end

    %% Utilities & Configuration
    subgraph "Utilities & Configuration"
        R("Routing (useRouteCustom)"):::util
        U("Utility Functions"):::util
    end

    %% Connections
    EP --> APP
    APP --> R
    APP --> RS
    APP --> S
    R --> P
    P --> T
    T --> L
    L --> C
    C --> A
    RS --> P
    RS --> C
    S --> RS
    %% Additional connection from Utilities for helpers
    R --> U

    %% Click Events
    click EP "https://github.com/segciest/airbnb-project/blob/main/src/main.jsx"
    click P "https://github.com/segciest/airbnb-project/tree/main/src/pages"
    click L "https://github.com/segciest/airbnb-project/tree/main/src/layout"
    click T "https://github.com/segciest/airbnb-project/tree/main/src/templates"
    click C "https://github.com/segciest/airbnb-project/tree/main/src/components"
    click A "https://github.com/segciest/airbnb-project/tree/main/src/assets"
    click S "https://github.com/segciest/airbnb-project/tree/main/src/services"
    click RS "https://github.com/segciest/airbnb-project/tree/main/src/redux"
    click R "https://github.com/segciest/airbnb-project/tree/main/src/routes"
    click U "https://github.com/segciest/airbnb-project/tree/main/src/utils"

    %% Styles
    classDef entry fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef app fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef ui fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef service fill:#f9d5d3,stroke:#c0392b,stroke-width:2px;
    classDef state fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef util fill:#fbeee6,stroke:#e67e22,stroke-width:2px;
```
