# jjems/awesomebros-travel architecture

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

- Interactive diagram: https://gitdiagram.com/jjems/awesomebros-travel
- Repository: https://github.com/jjems/awesomebros-travel

## Overview

##### Project type and purpose
- This is a Spring Boot–based monolithic backend service (“awesomebros-travel”) exposing RESTful endpoints for Posts and Users.
- It uses Spring Security for auth, MyBatis for persistence mapping, and a layered architecture (Controller → Service → Mapper → Database).

##### File structure
- Top-level build files (build.gradle, settings.gradle, gradle wrapper, GitHub Actions workflow) indicate a Gradle-powered Java CI/CD pipeline.
- src/main/java/com/trip_gg:
- config: Spring Security configuration
- controller: REST controllers (PostController, UserController)
- service: business logic (PostService, UserService)
- mapper: MyBatis interfaces mapping domain to SQL (plus XML files in resources/mapper)
- domain: entity classes (Post, User)
- dto: request/response payload definitions
- src/main/resources/application.yml: application config (DB connection, security, etc.)
- src/test: unit/integration tests

##### Main components and their interactions
a. Client(s)
- Could be a web/mobile front end or external service invoking the REST API.
b. API Layer (Controller)
- Receives HTTP requests → delegates to Service.
c. Service Layer
- Contains business rules; orchestrates calls to mappers.
d. Persistence Layer (MyBatis Mappers + XML)
- Executes SQL against the relational database.
e. Database
- Relational store (e.g., MySQL, PostgreSQL) for User and Post tables.
f. Security Layer
- Spring Security filters intercept incoming requests, enforce auth/roles before Controller.
g. CI/CD Pipeline
- GitHub Actions workflow (sync-to-team.yml) triggers build/tests on push.

##### Architectural patterns and design principles
- Layered (n-tier) architecture: clear separation of concerns.
- DTO pattern: decoupling internal domain model from external API contract.
- Mapper pattern (MyBatis): SQL and object mapping externalized in XML.
- Spring’s Dependency Injection: loose coupling between layers.

##### How to represent relationships and data flow
- Client → API Gateway/Controllers (HTTP request)
- Controllers → Services (method calls)
- Services → Mappers (MyBatis interface calls)
- Mappers → Database (SQL execution)
- Database → Mappers → Services → Controller → Client (response flow)

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["Client"]:::external

    subgraph "API Server"
        Security["Spring Security\nFilter Chain"]:::security
        subgraph "API Layer (Controllers)"
            PostController["PostController"]:::controller
            UserController["UserController"]:::controller
        end
        subgraph "Service Layer"
            PostService["PostService"]:::service
            UserService["UserService"]:::service
        end
        subgraph "Persistence Layer"
            PostMapperI["PostMapper\n(interface)"]:::persistence
            UserMapperI["UserMapper\n(interface)"]:::persistence
            PostMapperXML["PostMapper.xml"]:::persistence
            UserMapperXML["UserMapper.xml"]:::persistence
        end
        subgraph "Domain & DTO"
            PostEntity["Post"]:::domain
            UserEntity["User"]:::domain
            PostReqDto["PostRequestDto"]:::dto
            PostResDto["PostResponseDto"]:::dto
            UserResDto["UserResponseDto"]:::dto
        end
        Config["SecurityConfig"]:::config
        Entry["DemoApplication"]:::config
        AppYml["application.yml"]:::config
    end

    DB["Relational Database"]:::database

    CICD["GitHub Actions\n(sync-to-team.yml)"]:::external
    Tests["DemoApplicationTests"]:::external
    Build["build.gradle"]:::external
    Settings["settings.gradle"]:::external

    Client -->|HTTP JSON| Security
    Security -->|Authenticated request| PostController
    Security -->|Authenticated request| UserController
    PostController -->|calls| PostService
    UserController -->|calls| UserService
    PostService -->|calls| PostMapperI
    UserService -->|calls| UserMapperI
    PostMapperI -->|executes SQL| DB
    UserMapperI -->|executes SQL| DB
    DB -->|results| PostMapperI
    DB -->|results| UserMapperI

    Entry -.->|launches| Security
    Entry -.->|launches| PostController
    AppYml -.->|configures| Entry

    CICD -->|triggers build/test| Entry
    Tests -->|tests| Entry
    Build -->|build config| Entry
    Settings -->|build config| Entry

    click PostController "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/controller/PostController.java"
    click UserController "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/controller/UserController.java"
    click PostService "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/service/PostService.java"
    click UserService "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/service/UserService.java"
    click PostMapperI "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/mapper/PostMapper.java"
    click UserMapperI "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/mapper/UserMapper.java"
    click PostMapperXML "https://github.com/jjems/awesomebros-travel/blob/main/src/main/resources/mapper/PostMapper.xml"
    click UserMapperXML "https://github.com/jjems/awesomebros-travel/blob/main/src/main/resources/mapper/UserMapper.xml"
    click PostEntity "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/domain/Post.java"
    click UserEntity "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/domain/User.java"
    click PostReqDto "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/dto/PostRequestDto.java"
    click PostResDto "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/dto/PostResponseDto.java"
    click UserResDto "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/dto/UserResponseDto.java"
    click Config "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/config/SecurityConfig.java"
    click Entry "https://github.com/jjems/awesomebros-travel/blob/main/src/main/java/com/trip_gg/DemoApplication.java"
    click AppYml "https://github.com/jjems/awesomebros-travel/blob/main/src/main/resources/application.yml"
    click CICD "https://github.com/jjems/awesomebros-travel/blob/main/.github/workflows/sync-to-team.yml"
    click Tests "https://github.com/jjems/awesomebros-travel/blob/main/src/test/java/com/trip_gg/DemoApplicationTests.java"
    click Build "https://github.com/jjems/awesomebros-travel/blob/main/build.gradle"
    click Settings "https://github.com/jjems/awesomebros-travel/blob/main/settings.gradle"

    classDef external fill:#D3D3D3,stroke:#333;
    classDef security fill:#F8D7DA,stroke:#C82333;
    classDef controller fill:#CCE5FF,stroke:#004085;
    classDef service fill:#B8DAFF,stroke:#004085;
    classDef persistence fill:#D4EDDA,stroke:#155724;
    classDef domain fill:#E2E3E5,stroke:#6C757D;
    classDef dto fill:#FFF3CD,stroke:#856404;
    classDef config fill:#D1ECF1,stroke:#0C5460;
    classDef database fill:#D6D8DB,stroke:#1B1E21;
```
