# ixgnoy/travelnow architecture

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

- Interactive diagram: https://gitdiagram.com/ixgnoy/travelnow
- Repository: https://github.com/ixgnoy/travelnow

## Overview

##### Project type and purpose
- This is a full‐stack e-commerce travel web application (“Travel.Now”) built with Spring Boot (MVC), Thymeleaf templates, static front-end assets (HTML/CSS/JS/Bootstrap), and an H2/MySQL database.
- It provides user/auth flows, admin CRUD for packages/bookings/users, user CRUD for bookings/payments, and persists data via Spring Data JPA.

##### High-level architectural components
a. Client Layer
- Browser (or HTTP client e.g. Postman) requesting HTML pages, REST endpoints, static assets.
- Static front-end: HTML/CSS/JS/Bootstrap in src/main/resources/static.
- Thymeleaf templates in src/main/resources/templates render dynamic pages.

b. Web/API Layer
- Controllers (package com.csc3402.lab.staff.controller):
– UserController, LoginController, HomeController, PackageController, BookingController, PaymentController.
- Spring Security intercepts requests for authentication/authorization.

c. Service Layer
- Business logic in services (com.csc3402.lab.staff.service):
– UserService/UserServiceImpl, PackageServiceImpl, BookingServiceImpl, PaymentServiceImpl.

d. Data Access Layer
- Repositories (Spring Data JPA) in com.csc3402.lab.staff.repository:
– UserRepository, PackageRepository, BookingRepository, PaymentRepository.
- JPA Entities/DTOs in com.csc3402.lab.staff.model: User, Package, Booking, Payment, UserDto.

e. Persistence
- Embedded H2 (and optional MySQL) configured in application.properties.
- travelnowdb.mv.db file under /data for H2.
- ERD: User 1-to-M Booking, Booking 1-to-1 Payment, Booking 1-to-1 Package.

f. Build & Deployment
- Maven (pom.xml), packaging into a Spring Boot fat jar.
- .vscode/.idea and target/ for IDE and build artifacts.

##### Relationships & interactions
- Browser → (HTTP GET/POST) → Spring Security filter → DispatcherServlet → Controller → Service → Repository → Database
- Data flows back up: DB → JPA → Service → Controller → Thymeleaf → Browser-rendered HTML.

##### Architectural patterns & principles
- Layered (Presentation → Controller → Service → Repository → Database).
- MVC: Thymeleaf views + Controller actions.
- Dependency Injection (Spring).
- RESTful endpoints are implied (controllers return views or JSON).
- Separation of concerns between user/admin modules by URL namespaces.

##### Diagramming main components
a. Frontend/UI
– Static assets (CSS/JS) served from /static.
– Thymeleaf templates under /templates.
b. Backend
– Service layer.
– Repository layer.
c. Database
– H2/MySQL.
d. Security
– Spring Security module intercepting at web layer.
e. External/Test
– Postman or any HTTP client for API testing.

- /static (CSS/JS), Thymeleaf templates (/templates).
- Security Filter Chain → DispatcherServlet → Controller components.
7. Optionally, show the file data/travelnowdb.mv.db as the physical database file.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Browser / HTTP Client"]:::client
        Static["Static Assets<br>(/static)"]:::frontend
        Templates["Thymeleaf Templates<br>(/templates)"]:::frontend
    end

    Browser -->|"HTTP"| Static
    Browser -->|"HTTP"| Templates

    click Static "https://github.com/ixgnoy/travelnow/tree/master/src/main/resources/static"
    click Templates "https://github.com/ixgnoy/travelnow/tree/master/src/main/resources/templates"

    %% Web/API Layer
    subgraph "Web/API Layer"
        SecurityFilter["Spring Security<br>Filter Chain"]:::security
        Dispatcher["DispatcherServlet"]:::web
        subgraph "Controllers"
            BookingController["BookingController"]:::web
            HomeController["HomeController"]:::web
            LoginController["LoginController"]:::web
            PackageController["PackageController"]:::web
            PaymentController["PaymentController"]:::web
            UserController["UserController"]:::web
        end
    end

    Static --> SecurityFilter
    Templates --> SecurityFilter
    SecurityFilter --> Dispatcher
    Dispatcher --> BookingController
    Dispatcher --> HomeController
    Dispatcher --> LoginController
    Dispatcher --> PackageController
    Dispatcher --> PaymentController
    Dispatcher --> UserController

    click BookingController "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/controller/BookingController.java"
    click HomeController "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/controller/HomeController.java"
    click LoginController "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/controller/LoginController.java"
    click PackageController "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/controller/PackageController.java"
    click PaymentController "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/controller/PaymentController.java"
    click UserController "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/controller/UserController.java"
    click applicationProperties "https://github.com/ixgnoy/travelnow/blob/master/src/main/resources/application.properties"

    %% Service Layer
    subgraph "Service Layer"
        BookingServiceI["BookingService<br>Interface"]:::services
        BookingServiceImpl["BookingServiceImpl"]:::services
        PackageServiceI["PackageService<br>Interface"]:::services
        PackageServiceImpl["PackageServiceImpl"]:::services
        PaymentServiceI["PaymentService<br>Interface"]:::services
        PaymentServiceImpl["PaymentServiceImpl"]:::services
        UserServiceI["UserService<br>Interface"]:::services
        UserServiceImpl["UserServiceImpl"]:::services
    end

    BookingController -->|"call"| BookingServiceI
    BookingController -->|"call"| BookingServiceImpl
    PackageController -->|"call"| PackageServiceI
    PackageController -->|"call"| PackageServiceImpl
    PaymentController -->|"call"| PaymentServiceI
    PaymentController -->|"call"| PaymentServiceImpl
    UserController -->|"call"| UserServiceI
    UserController -->|"call"| UserServiceImpl

    click BookingServiceI "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/service/BookingService.java"
    click BookingServiceImpl "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/service/BookingServiceImpl.java"
    click PackageServiceI "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/service/PackageService.java"
    click PackageServiceImpl "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/service/PackageServiceImpl.java"
    click PaymentServiceI "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/service/PaymentService.java"
    click PaymentServiceImpl "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/service/PaymentServiceImpl.java"
    click UserServiceI "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/service/UserService.java"
    click UserServiceImpl "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/service/UserServiceImpl.java"

    %% Data Access Layer
    subgraph "Data Access Layer"
        UserRepo["UserRepository"]:::repos
        PackageRepo["PackageRepository"]:::repos
        BookingRepo["BookingRepository"]:::repos
        PaymentRepo["PaymentRepository"]:::repos
    end

    BookingServiceImpl -->|"JPA"| BookingRepo
    PackageServiceImpl -->|"JPA"| PackageRepo
    PaymentServiceImpl -->|"JPA"| PaymentRepo
    UserServiceImpl -->|"JPA"| UserRepo

    click UserRepo "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/repository/UserRepository.java"
    click PackageRepo "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/repository/PackageRepository.java"
    click BookingRepo "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/repository/BookingRepository.java"
    click PaymentRepo "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/repository/PaymentRepository.java"

    %% Database
    subgraph "Database"
        DB["H2 / MySQL<br>Cylinder"]:::database
        File["travelnowdb.mv.db<br>(physical file)"]:::database
    end

    BookingRepo -->|"JDBC/SQL"| DB
    PackageRepo -->|"JDBC/SQL"| DB
    PaymentRepo -->|"JDBC/SQL"| DB
    UserRepo -->|"JDBC/SQL"| DB
    DB --> File

    click File "https://github.com/ixgnoy/travelnow/blob/master/data/travelnowdb.mv.db"

    %% Build & Deployment
    subgraph "Build & Deployment"
        POM["pom.xml"]:::web
        Entry["UserApplication.java"]:::web
        Target["target/"]:::web
    end

    click POM "https://github.com/ixgnoy/travelnow/blob/master/pom.xml"
    click Entry "https://github.com/ixgnoy/travelnow/blob/master/src/main/java/com/csc3402/lab/staff/UserApplication.java"
    click Target "https://github.com/ixgnoy/travelnow/tree/master/target/"

    %% Styles
    classDef client fill:#cce5ff,stroke:#333;
    classDef frontend fill:#e6f7ff,stroke:#333;
    classDef security fill:#ffe6cc,stroke:#333;
    classDef web fill:#d4edda,stroke:#333;
    classDef services fill:#e2e3e5,stroke:#333;
    classDef repos fill:#fff3cd,stroke:#333;
    classDef database fill:#f8d7da,stroke:#333;
```
