# untolders/my_airbnb architecture

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

- Interactive diagram: https://gitdiagram.com/untolders/my_airbnb
- Repository: https://github.com/untolders/my_airbnb

## Overview

##### Project type and purpose
- This is a full-stack web application—an Airbnb clone—built with a ReactJS single-page application (SPA) front end and a Spring Boot back end.
- Purpose: allow Guests to search and book listings, Hosts to create and manage listings and messages, and Admins to oversee users, listings, reviews, and extract application data.

##### File structure
- Top-level split:
- api-hits/ – sample API payloads
- back-end/AirBnB/ – Spring Boot project (controllers, services, repositories, models, security, converters, util/recommender)
- front-end/airbnb/ – React app (components organized by user role and feature, services, routes, helpers, context)
- Backend layering:
- Controllers (REST endpoints)
- Converters (DTO ↔ entity)
- Services (business logic + recommendation engine)
- Repositories (Spring Data JPA)
- Util (JWT, Helpers, Recommender algorithms)
- Frontend structure:
- Pages & components by role (Admin, Host, Guest, general listings)
- _services for API calls
- _helpers for auth headers & history
- Routes define protected routes per role
- Context for auth state

##### README for additional insights
- Build/run instructions for back end (Gradle) and front end (npm).
- Screenshots reveal core UI flows: home, login/register, profile, search, role-based dashboards.

##### Detail without over-splitting
- Every major layer and sub-module essential to understanding data flow and security.
- Avoid drilling into every single Java package; group similar components (all controllers together, all repositories together).
- Document the JWT authentication flow and role-based routing on the front end.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Swimlanes
    subgraph "Client (React SPA)"
        direction TB
        UI["React SPA"]:::client
        AuthContext["Auth Context"]:::client
        AuthHeader["Auth Header Helper"]:::client
        History["History Helper"]:::client
        AuthService["Authentication Service"]:::client
        UserService["User Service"]:::client
        Routes["Role-based Routes"]:::client
        Protected["Protected Route Components"]:::client
        Pages["Pages & Components"]:::client
        MapComp["OpenStreetMap Component"]:::external
    end

    subgraph "Server (Spring Boot API)"
        direction TB
        Filter["AuthTokenFilter"]:::server
        Controllers["REST Controllers"]:::server
        Converters["DTO ↔ Entity Converters"]:::server
        Services["Business Services"]:::business
        Recommender["Recommendation Engine"]:::business
        Repositories["Repositories"]:::server
        Utils["Security Utilities & Helpers"]:::server
        DB[(Database)]:::database
    end

    ExternalEmail["Email/SMS Service"]:::external

    %% Connections
    UI -->|"uses context"| AuthContext
    UI -->|"includes header"| AuthHeader
    UI -->|"updates history"| History
    UI -->|"calls"| AuthService
    UI -->|"calls"| UserService
    UI -->|"routes via"| Routes
    Routes --> Protected
    UI -->|"renders"| Pages
    UI -->|"fetches tiles"| MapComp

    UI -->|HTTP/HTTPS| Filter
    Filter --> Controllers
    Controllers --> Converters
    Converters --> Services
    Services --> Recommender
    Services --> Repositories
    Repositories --> DB
    Services --> Utils
    Controllers -->|"sends email"| ExternalEmail

    %% Click Events
    click UI "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/App.js"
    click MapComp "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/components/Map/OpenStreetMap.js"
    click AuthContext "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/context/auth.js"
    click AuthHeader "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/_helpers/auth-header.js"
    click History "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/_helpers/history.js"
    click AuthService "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/_services/authentication.service.js"
    click UserService "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/_services/user.service.js"
    click Routes "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/routes/allRoutes.js"
    click Protected "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/routes/AdminRoute.js"
    click Protected "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/routes/HostRoute.js"
    click Protected "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/routes/GuestRoute.js"
    click Protected "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/routes/PrivateRoute.js"
    click UI "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/pages/home/Home.js"
    click UI "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/pages/login/Login.js"
    click UI "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/pages/register/Register.js"
    click UI "https://github.com/untolders/my_airbnb/blob/main/front-end/airbnb/src/pages/profile/Profile.js"

    click Filter "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/security/AuthTokenFilter.java"
    click Controllers "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/controller/AdminController.java"
    click Controllers "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/controller/HostController.java"
    click Controllers "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/controller/GuestController.java"
    click Controllers "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/controller/UniversalController.java"
    click Services "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/service/BookingService.java"
    click Services "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/service/ListingService.java"
    click Services "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/service/MessageService.java"
    click Services "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/service/ReviewService.java"
    click Services "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/service/UserService.java"
    click Services "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/service/SuperService.java"
    click Repositories "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/repository/BookingRepository.java"
    click Repositories "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/repository/ListingRepository.java"
    click Repositories "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/repository/MessageRepository.java"
    click Repositories "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/repository/ReviewRepository.java"
    click Repositories "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/repository/UserRepository.java"
    click Converters "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/converter/ListingConverter.java"
    click Converters "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/converter/BookingConverter.java"
    click Converters "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/converter/MessageConverter.java"
    click Converters "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/converter/ReviewConverter.java"
    click Converters "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/converter/UserConverter.java"
    click Utils "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/util/JwtUtils.java"
    click Utils "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/util/Helpers.java"
    click Recommender "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/util/Recommender/MatrixFactorization.java"
    click Recommender "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/util/Recommender/SingularValueDecomposition.java"
    click Recommender "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/java/com/uoa/AirBnB/util/Recommender/UserBehaviorTransformer.java"
    click DB "https://github.com/untolders/my_airbnb/blob/main/back-end/AirBnB/src/main/resources/data.sql"

    %% Styles
    classDef client fill:#CFE2F3,stroke:#0366D6,color:#0366D6;
    classDef server fill:#D9EAD3,stroke:#6AA84F,color:#6AA84F;
    classDef business fill:#E2EFDA,stroke:#38761D,color:#38761D;
    classDef database fill:#FCE5CD,stroke:#E69138,color:#E69138;
    classDef external fill:#EAD1DC,stroke:#A64D79,color:#A64D79;
```
