# hilalinabil/spring_prjt architecture

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

- Interactive diagram: https://gitdiagram.com/hilalinabil/spring_prjt
- Repository: https://github.com/hilalinabil/spring_prjt

## Overview

##### Project type and purpose
- This is a single-module Spring Boot backend service exposing REST APIs for managing Task and TaskList entities.
- There is no frontend in this repo; clients will call the API (e.g., via Postman or a separate UI).

##### High-level layers
- Presentation layer: package `controllers`
- Service layer: package `services` + `services.impl`
- Data-access layer: package `repositories`
- Mapping layer: package `mappers` + `mappers.impl`
- Domain/model: package `domain` (entities & DTOs)
- Infrastructure: application.properties + external database (Docker Postgres/MySQL) + H2 for tests

##### Main components
a. External Client
- Represents any HTTP consumer (Postman, frontend app).
b. API Gateway / Controllers
- TaskController, TaskListController
- GlobalExceptionHandler for error responses.
c. DTO / Mapper Layer
- TaskDto, TaskListDto, ErrorResponse
- TaskMapper/TaskListMapper and their Impl classes.
d. Service Layer
- TaskService & TaskServiceImpl
- TaskListService & TaskListServiceImpl
e. Repository Layer
- TaskRepository, TaskListRepository (Spring Data JPA interfaces)
f. Database
- Primary DB (e.g., Postgres/MySQL in Docker)
- Test DB (H2 in-memory for unit tests)

##### Relationships and data flow
- Controllers → Service Layer (calls business methods)
- Service Layer → Repositories (CRUD operations)
- Repository Layer ↔ Database (SQL queries)
- Controllers ↔ GlobalExceptionHandler (error flow)
- Service/Controller ↔ Mapper Layer (entity ⇄ DTO conversions)

##### Architectural patterns
- Layered (aka “Onion” or “Hexagonal” without strict ports/adapters)
- Dependency Injection (Spring-managed beans)
- Use of DTOs and Mappers decouples domain entities from API contracts
- Repository pattern via Spring Data JPA

##### Deployment context
- Spring Boot jar running in an application server or container.
- External DB container.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["External Client"]:::external

    %% Application Container
    subgraph "Spring Boot Application"
        direction TB

        %% Controllers Layer
        subgraph "Controllers Layer"
            direction TB
            TaskController["TaskController"]:::controllers
            TaskListController["TaskListController"]:::controllers
            GlobalExceptionHandler["GlobalExceptionHandler"]:::controllers
        end

        %% DTO & Mapping Layer
        subgraph "DTO & Mapping Layer"
            direction TB
            TaskDto["TaskDto"]:::dto
            TaskListDto["TaskListDto"]:::dto
            ErrorResponse["ErrorResponse"]:::dto

            TaskMapper["TaskMapper"]:::mapper
            TaskMapperImpl["TaskMapperImpl"]:::mapper
            TaskListMapper["TaskListMapper"]:::mapper
            TaskListMapperImpl["TaskListMapperImpl"]:::mapper
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            TaskServiceImpl["TaskServiceImpl"]:::service
            TaskListServiceImpl["TaskListServiceImpl"]:::service
        end

        %% Repository Layer
        subgraph "Repository Layer"
            direction TB
            TaskRepository["TaskRepository"]:::repo
            TaskListRepository["TaskListRepository"]:::repo
        end

        %% Persistence
        subgraph "Database"
            direction TB
            Postgres["Postgres/MySQL (Docker)"]:::db
            H2["H2 In-Memory (Tests)"]:::db
        end

        %% Configuration & Entry
        subgraph "Infrastructure & Entry"
            direction TB
            Application["TestAppApplication"]:::app
            Config["application.properties"]:::config
        end

    end

    %% Testing
    subgraph "Test Context"
        direction TB
        TestAppTests["TestAppApplicationTests"]:::test
    end

    %% Relationships
    Client -->|HTTP Request| TaskController
    Client -->|HTTP Request| TaskListController
    TaskController -->|uses| TaskServiceImpl
    TaskListController -->|uses| TaskListServiceImpl

    TaskController -->|error handling| GlobalExceptionHandler
    TaskListController -->|error handling| GlobalExceptionHandler
    GlobalExceptionHandler -->|ErrorResponse| Client

    TaskController -->|map dto↔entity| TaskMapper
    TaskController -->|map dto↔entity| TaskListMapper
    TaskListController -->|map dto↔entity| TaskMapper
    TaskListController -->|map dto↔entity| TaskListMapper

    TaskServiceImpl -->|uses| TaskMapperImpl
    TaskListServiceImpl -->|uses| TaskListMapperImpl

    TaskServiceImpl -->|CRUD| TaskRepository
    TaskListServiceImpl -->|CRUD| TaskListRepository

    TaskRepository -->|SQL| Postgres
    TaskListRepository -->|SQL| Postgres

    TestAppTests -->|loads context| Application
    TestAppTests -->|uses| H2

    Application -->|reads config| Config

    %% Click Events
    click TaskController "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/controllers/TaskController.java"
    click TaskListController "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/controllers/TaskListController.java"
    click GlobalExceptionHandler "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/controllers/GlobalExceptionHandler.java"

    click TaskDto "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/domain/dto/TaskDto.java"
    click TaskListDto "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/domain/dto/TaskListDto.java"
    click ErrorResponse "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/domain/dto/ErorrResponse.java"

    click TaskMapper "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/mappers/TaskMapper.java"
    click TaskMapperImpl "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/mappers/impl/TaskMapperImpl.java"
    click TaskListMapper "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/mappers/TaskListMapper.java"
    click TaskListMapperImpl "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/mappers/impl/TaskListMapperImpl.java"

    click TaskServiceImpl "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/services/impl/TaskServiceImpl.java"
    click TaskListServiceImpl "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/services/impl/TaskListServiceImpl.java"
    click TaskService "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/services/TaskService.java"
    click TaskListService "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/services/TaskListService.java"

    click TaskRepository "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/repositories/TaskRepository.java"
    click TaskListRepository "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/repositories/TaskListRepository.java"

    click Application "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/java/com/gyro/test_app/TestAppApplication.java"
    click Config "https://github.com/hilalinabil/spring_prjt/blob/master/src/main/resources/application.properties"

    click TestAppTests "https://github.com/hilalinabil/spring_prjt/blob/master/src/test/java/com/gyro/test_app/TestAppApplicationTests.java"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef controllers fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef dto fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef mapper fill:#b2dfdb,stroke:#333,stroke-width:1px
    classDef service fill:#fff9c4,stroke:#333,stroke-width:1px
    classDef repo fill:#ffe0b2,stroke:#333,stroke-width:1px
    classDef db fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef config fill:#d1c4e9,stroke:#333,stroke-width:1px
    classDef app fill:#f0f4c3,stroke:#333,stroke-width:1px
    classDef test fill:#eceff1,stroke:#333,stroke-width:1px
```
