# toru2004/hairsalonbooking architecture

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

- Interactive diagram: https://gitdiagram.com/toru2004/hairsalonbooking
- Repository: https://github.com/toru2004/hairsalonbooking

## Overview

##### Project Type and Purpose
- This is a monolithic, full-stack Spring Boot web application (MVC) that allows customers to browse services, view stylists, and book appointments.
- It uses Thymeleaf templates, static assets (CSS/JS/images), and a MySQL database.

##### File Structure
- src/main/java/com/admin:
- controller/…Controller.java (HTTP endpoints)
- service/…Service.java (business logic)
- repository/…Repository.java (data access)
- model/*.java (domain entities)
- exception/*.java (error handling)
- config/AppConfig.java (Spring configuration)
- utils/TimePeriodHelper.java (helper logic)
- src/main/resources:
- static/ (CSS, JS, images, videos) – client-side assets
- templates/ (Thymeleaf views for admin, manager, stylist, public)
- application.properties (app & DB config)
- web/WEB-INF/web.xml & index.jsp (legacy servlet config)

##### README
- Confirms Spring Boot + Thymeleaf UI + MySQL
- Core features: booking, service listings, stylist info

##### Main Components
a. Client Browser (Web UI)
- Static assets: CSS, JS, images/videos
- Thymeleaf-rendered HTML pages
b. Spring Boot Application (Monolith)
1. Presentation Layer (Controllers)
2. Service Layer (business rules)
3. Data Layer (Repositories using Spring Data JPA)
c. MySQL Database
d. External Systems (e.g., SMTP for emails if any – not present but leave extensibility)

##### Relationships & Data Flows
- Browser → HTTP (GET/POST) → Controllers
- Controllers ↔ Services (method calls)
- Services ↔ Repositories (JPA queries)
- Repositories → JDBC → MySQL
- Controllers → Thymeleaf → HTML → Browser
- Static assets served from /static directory

##### Architectural Patterns & Principles
- MVC: clear separation of concerns
- Layered Architecture: Presentation → Business → Data
- Dependency Injection (Spring)
- Exception Handling via @ControllerAdvice or custom exceptions

##### Relevant Technologies & Roles
- Spring Boot (embedded Tomcat, auto-configuration)
- Spring MVC (DispatcherServlet, @Controller)
- Spring Data JPA (Repositories, Entities)
- Thymeleaf (View templates)
- MySQL (persistent storage)
- Maven (build)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Browser" 
        direction TB
        Browser["Client Browser\n(Web UI)"]:::frontend
        StaticAssets["Static Assets\n(CSS, JS, images)"]:::frontend
        Templates["Thymeleaf Templates\n(HTML Views)"]:::frontend
    end

    %% Server Layer
    subgraph "Spring Boot Application" 
        direction TB

        subgraph "Presentation Layer"
            Controllers["Controllers\n(Spring MVC)"]:::backend
        end

        subgraph "Service Layer"
            Services["Services\n(Business Logic)"]:::backend
        end

        subgraph "Data Layer"
            Repositories["Repositories\n(Spring Data JPA)"]:::data
        end

        subgraph "Support Components"
            Models["Domain Models\n(Entities)"]:::data
            Exceptions["Exception Handling"]:::data
            Config["AppConfig\n(Application Config)"]:::backend
            EntryPoint["MyWebAppApplication\n(Application Entry)"]:::backend
            Utils["TimePeriodHelper\n(Utilities)"]:::backend
            AppProps["application.properties\n(DB Config)"]:::backend
            WebXML["web.xml\n(Servl.et Config)"]:::backend
            IndexJSP["index.jsp"]:::frontend
        end
    end

    %% Database
    Database[(MySQL Database)]:::db

    %% Relationships
    Browser -->|HTTP Request/Response| Controllers
    StaticAssets -->|served from| Browser
    Templates -->|rendered by| Controllers
    Controllers -->|method call| Services
    Services -->|JPA query| Repositories
    Repositories -->|JDBC| Database

    %% Click Events
    click StaticAssets "https://github.com/toru2004/hairsalonbooking/tree/main/src/main/resources/static"
    click Templates "https://github.com/toru2004/hairsalonbooking/tree/main/src/main/resources/templates"
    click Controllers "https://github.com/toru2004/hairsalonbooking/tree/main/src/main/java/com/admin/controller"
    click Services "https://github.com/toru2004/hairsalonbooking/tree/main/src/main/java/com/admin/service"
    click Repositories "https://github.com/toru2004/hairsalonbooking/tree/main/src/main/java/com/admin/repository"
    click Models "https://github.com/toru2004/hairsalonbooking/tree/main/src/main/java/com/admin/model"
    click Exceptions "https://github.com/toru2004/hairsalonbooking/tree/main/src/main/java/com/admin/exception"
    click Config "https://github.com/toru2004/hairsalonbooking/blob/main/src/main/java/com/admin/config/AppConfig.java"
    click EntryPoint "https://github.com/toru2004/hairsalonbooking/blob/main/src/main/java/com/admin/MyWebAppApplication.java"
    click Utils "https://github.com/toru2004/hairsalonbooking/blob/main/src/main/java/com/admin/utils/TimePeriodHelper.java"
    click AppProps "https://github.com/toru2004/hairsalonbooking/blob/main/src/main/resources/application.properties"
    click WebXML "https://github.com/toru2004/hairsalonbooking/blob/main/src/main/webapp/WEB-INF/web.xml"
    click IndexJSP "https://github.com/toru2004/hairsalonbooking/blob/main/src/main/webapp/index.jsp"

    %% Styles
    classDef frontend fill:#d5f5e3,stroke:#27ae60,stroke-width:1px;
    classDef backend fill:#aed6f1,stroke:#2980b9,stroke-width:1px;
    classDef data fill:#f9e79f,stroke:#d68910,stroke-width:1px;
    classDef db fill:#d7dbdd,stroke:#566573,stroke-width:1px;
```
