# rafapcjs/bibliotech- architecture

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

- Interactive diagram: https://gitdiagram.com/rafapcjs/bibliotech-
- Repository: https://github.com/rafapcjs/bibliotech-

## Overview

- Client / Web Interface: Although this is not a separate “frontend” directory, note that the README mentions an “Interfaz web intuitiva” which implies the existence of a web client that interacts with your API.
- API Layer (Presentation Layer): Represented by the various controllers in the “presentation” packages (e.g., AuthorController, BookController, CategoryController). These manage incoming HTTP requests.
- Service Layer (Business Logic Layer): Each domain (books, authors, categories) has a corresponding service interface and implementation, such as IAuthorService with AuthorServiceImpl, encapsulating business rules.
- Data Access / Persistence Layer: This includes the “persistencie” packages with entities and their repositories (for example, Author, Book, Category entities and their respective repositories) that interact with the database.
- Common/Utility Components: Represent shared aspects like exception handling, configuration (SwaggerConfig, CorsConfig, jpa auditing), and response formatting (ApiResponse, ApiError).

- A connection from the Repository layer to the Database (labeled PostgreSQL/MySQL) to demonstrate persistent storage.

##### Architectural design and patterns
- Screaming Architecture: Emphasize that each package (books, authors, categories, etc.) clearly “screams” its purpose. This means grouping by domain instead of technical layers exclusively.
- MVC-Like Organization: Although it’s built with Spring Boot, the separation between controllers (presentation), services (business logic), and repositories (data access) is clear.
- Dependency Injection and Configuration: Note that configuration files (application.yml and various utility config classes) bind these layers and third-party integrations (e.g., Swagger for documenting the API) together.

##### Technologies and frameworks
- Java 11+ as the runtime base.
- Spring Boot as the core framework to build the RESTful API.
- PostgreSQL/MySQL as the backing database.
- Swagger for API documentation.
- Additionally, mention tools like Maven (pom.xml, mvnw scripts) which serve as the build and dependency management tools.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Layer"
        client("Client (Web Interface)"):::client
    end

    subgraph "API Layer (Presentation)"
        authorController("AuthorController"):::presentation
        bookController("BookController"):::presentation
        categoryController("CategoryController"):::presentation
    end

    subgraph "Service Layer (Business)"
        iAuthorService("IAuthorService"):::service
        authorServiceImpl("AuthorServiceImpl"):::service
        iBookServices("IBookServices"):::service
        bookServicesImpl("BookServicesImpl"):::service
        iCategoryServices("ICategoryServices"):::service
        categoryServicesImpl("CategoryServicesImpl"):::service
    end

    subgraph "Data Access / Persistence"
        authorEntity("Author Entity"):::data
        authorRepository("Author Repository"):::data
        bookEntity("Book Entity"):::data
        booksRepository("Books Repository"):::data
        categoryEntity("Category Entity"):::data
        categoryRepository("Category Repository"):::data
        customerEntity("Customer Entity"):::data
        customerRepository("Customer Repository"):::data
    end

    subgraph "Factories"
        authorFactory("AuthorFactory"):::factory
        bookFactory("BookFactory"):::factory
        categoryFactory("CategoryFactory"):::factory
    end

    subgraph "Common / Utilities"
        globalExceptionHandler("GlobalExceptionHandler"):::common
        resourceNotFound("ResourceNotFoundException"):::common
        apiResponse("ApiResponse"):::common
        apiError("ApiError"):::common
        swaggerConfig("SwaggerConfig"):::common
        corsConfig("CorsConfig"):::common
        jpaAuditingConfig("JpaAuditingConfiguration"):::common
        modelMapperConfig("ModelMapperConfig"):::common
        pageableUtil("PageableUtil"):::common
    end

    database("Database (PostgreSQL/MySQL)"):::database

    %% Connections from Client to API Layer
    client -->|"REST_Call"| authorController
    client -->|"REST_Call"| bookController
    client -->|"REST_Call"| categoryController

    %% Connections from API Controllers to Service Layer
    authorController -->|"delegates"| authorServiceImpl
    bookController -->|"delegates"| bookServicesImpl
    categoryController -->|"delegates"| categoryServicesImpl

    %% Connections from Service Layer to Data Access Layer
    authorServiceImpl -->|"calls"| authorRepository
    bookServicesImpl -->|"calls"| booksRepository
    categoryServicesImpl -->|"calls"| categoryRepository

    %% Connections from Repositories to Database
    authorRepository -->|"persists"| database
    booksRepository -->|"persists"| database
    categoryRepository -->|"persists"| database
    customerRepository -->|"persists"| database

    %% Connections from Service Layer to Factories
    authorServiceImpl -->|"creates"| authorFactory
    bookServicesImpl -->|"creates"| bookFactory
    categoryServicesImpl -->|"creates"| categoryFactory

    %% Connections from API Controllers to Common Utilities
    authorController -->|"handles"| globalExceptionHandler
    bookController -->|"handles"| globalExceptionHandler
    categoryController -->|"handles"| globalExceptionHandler

    authorController -->|"docs"| swaggerConfig
    bookController -->|"docs"| swaggerConfig
    categoryController -->|"docs"| swaggerConfig

    %% Class Definitions for Colour Coding
    classDef client fill:#f9e,stroke:#333,stroke-width:2px
    classDef presentation fill:#bbf,stroke:#333,stroke-width:2px
    classDef service fill:#bfb,stroke:#333,stroke-width:2px
    classDef data fill:#ffb,stroke:#333,stroke-width:2px
    classDef factory fill:#ddf,stroke:#333,stroke-width:2px
    classDef common fill:#fcc,stroke:#333,stroke-width:2px
    classDef database fill:#cfc,stroke:#333,stroke-width:2px

    %% Click Events for API Layer (Presentation)
    click authorController "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/author/presentation/controllers/AuthorContoller.java"
    click bookController "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/book/presentation/controller/BookController.java"
    click categoryController "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/categories/presentation/controller/CategoryController.java"

    %% Click Events for Service Layer (Business)
    click iAuthorService "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/author/service/interfaces/IAuthorService.java"
    click authorServiceImpl "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/author/service/implementation/AuthorServiceImpl.java"
    click iBookServices "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/book/services/interfaces/IBookServices.java"
    click bookServicesImpl "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/book/services/implementation/BookServicesImpl.java"
    click iCategoryServices "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/categories/service/interfaces/ICategoryServices.java"
    click categoryServicesImpl "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/categories/service/implementation/CategoryServicesImpl.java"

    %% Click Events for Data Access / Persistence Layer
    click authorEntity "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/author/persistencie/entities/Author.java"
    click authorRepository "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/author/persistencie/repositories/AuthorRepository.java"
    click bookEntity "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/book/persistencie/entities/Book.java"
    click booksRepository "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/book/persistencie/repositories/BooksRepository.java"
    click categoryEntity "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/categories/persistencie/entities/Category.java"
    click categoryRepository "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/categories/persistencie/repositories/CategoryRepository.java"
    click customerEntity "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/customer/persistencie/entities/Customer.java"
    click customerRepository "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/customer/persistencie/repositories/CustomerRepository.java"

    %% Click Events for Factories
    click authorFactory "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/author/factory/AuthorFactory.java"
    click bookFactory "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/book/factory/BookFactory.java"
    click categoryFactory "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/categories/factory/CategoryFactory.java"

    %% Click Events for Common/Utility Components
    click globalExceptionHandler "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/exception/exceptionGlobal/ExceptionGlobal.java"
    click resourceNotFound "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/exception/exceptions/ResourceNotFoundException.java"
    click apiResponse "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/responses/ApiResponse.java"
    click apiError "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/responses/ApiError.java"
    click swaggerConfig "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/utils/SwaggerConfig.java"
    click corsConfig "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/utils/CorsConfig.java"
    click jpaAuditingConfig "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/utils/JpaAuditingConfiguration.java"
    click modelMapperConfig "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/utils/ModelMapperConfig.java"
    click pageableUtil "https://github.com/rafapcjs/bibliotech-/blob/master/src/main/java/com/bookLibrary/rafapcjs/commons/utils/pageable/PageableUtil.java"
```
