# up2code/spring-book-store architecture

> Architecture diagram of the GitHub repository up2code/spring-book-store, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/up2code/spring-book-store
- Repository: https://github.com/up2code/spring-book-store

## Overview

##### Main Components

a) Application Layer:
- Spring Boot Application Core
- Controllers (Auth, Author, Book)
- Services Layer
- Repository Layer
- Security Components (JWT)
- Entity Models
- DTOs/Request Models

b) Infrastructure:
- PostgreSQL Database
- Monitoring Stack
- Prometheus (Metrics Collection)
- Grafana (Visualization)
- pgAdmin (Database Management)

**[Client Layer]**
- ↓
**[Application Layer]**
- ↓
**[Data & Monitoring Layer]**

##### Detailed Component Breakdown

a) Client Layer:
- External API consumers
- Swagger UI endpoint
- OpenAPI documentation endpoint

b) Application Layer (Spring Boot):
- Security Filter Chain
- JWT Authentication Filter
- Security Config
- Controllers Layer
- AuthController
- AuthorController
- BookController
- Service Layer
- BookService
- AuthorService
- CustomUserDetailsService
- Repository Layer
- BookRepository
- AuthorRepository
- Entity Models
- Book
- Author

c) Data & Monitoring Layer:
- PostgreSQL Database
- Prometheus (Metrics Collection)
- Grafana (Dashboards)
- pgAdmin

##### Important Relationships

- JWT Authentication flow
- CRUD operations flow
- Monitoring data flow
- Database connections

##### Technical Details

- Port mappings:
- Main application: 8080
- Prometheus: 9090
- Grafana: 3000
- Database credentials (noted in configuration)
- JWT security implementation

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL["Client Layer"]
        API[API Consumers]
        SWAGGER["Swagger UI :8080/swagger-ui"]
        OPENAPI["OpenAPI Docs :8080/v3/api-docs"]
    end

    %% Application Layer
    subgraph AL["Application Layer"]
        %% Security
        subgraph SEC["Security Components"]
            SECCONFIG["Security Config"]:::security
            JWTFILTER["JWT Auth Filter"]:::security
            JWTUTIL["JWT Utilities"]:::security
        end

        %% Controllers
        subgraph CTRL["Controllers"]
            AUTHCTRL["Auth Controller"]:::controller
            AUTHORCTRL["Author Controller"]:::controller
            BOOKCTRL["Book Controller"]:::controller
        end

        %% Services
        subgraph SVC["Services"]
            BOOKSVC["Book Service"]:::service
            AUTHORSVC["Author Service"]:::service
            USERSVC["Custom User Details Service"]:::service
        end

        %% Repositories
        subgraph REPO["Repositories"]
            BOOKREPO["Book Repository"]:::repository
            AUTHORREPO["Author Repository"]:::repository
        end

        %% Models
        subgraph MOD["Models"]
            subgraph ENT["Entities"]
                BOOKENT["Book Entity"]:::entity
                AUTHORENT["Author Entity"]:::entity
            end
            subgraph DTO["DTOs"]
                BOOKDTO["Book DTO"]:::dto
                AUTHORDTO["Author DTO"]:::dto
            end
        end
    end

    %% Data & Monitoring Layer
    subgraph DML["Data & Monitoring Layer"]
        DB[(PostgreSQL)]:::database
        PROM["Prometheus :9090"]:::monitoring
        GRAF["Grafana :3000"]:::monitoring
        PGADMIN["pgAdmin"]:::tool
    end

    %% Relationships
    API --> SWAGGER & OPENAPI
    API --> AUTHCTRL & AUTHORCTRL & BOOKCTRL
    
    AUTHCTRL & AUTHORCTRL & BOOKCTRL --> JWTFILTER
    JWTFILTER --> JWTUTIL
    JWTFILTER --> SECCONFIG
    
    AUTHCTRL --> USERSVC
    AUTHORCTRL --> AUTHORSVC
    BOOKCTRL --> BOOKSVC
    
    BOOKSVC --> BOOKREPO
    AUTHORSVC --> AUTHORREPO
    
    BOOKREPO & AUTHORREPO --> DB
    
    PROM --> AL
    GRAF --> PROM
    PGADMIN --> DB

    %% Styles
    classDef controller fill:#2196F3,stroke:#1565C0,color:white
    classDef service fill:#4CAF50,stroke:#2E7D32,color:white
    classDef repository fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef security fill:#FF9800,stroke:#EF6C00,color:white
    classDef entity fill:#607D8B,stroke:#37474F,color:white
    classDef dto fill:#795548,stroke:#4E342E,color:white
    classDef database fill:#00BCD4,stroke:#00838F,color:white
    classDef monitoring fill:#E91E63,stroke:#AD1457,color:white
    classDef tool fill:#9E9E9E,stroke:#424242,color:white

    %% Click Events
    click AUTHCTRL "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/controller/AuthController.java"
    click AUTHORCTRL "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/controller/AuthorController.java"
    click BOOKCTRL "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/controller/BookController.java"
    click BOOKSVC "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/service/BookService.java"
    click AUTHORSVC "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/service/AuthorService.java"
    click USERSVC "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/service/CustomUserDetailsService.java"
    click BOOKREPO "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/repository/BookRepository.java"
    click AUTHORREPO "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/repository/AuthorRepository.java"
    click SECCONFIG "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/config/SecurityConfig.java"
    click JWTFILTER "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/filter/JwtAuthFilter.java"
    click JWTUTIL "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/utils/JwtUtil.java"
    click BOOKENT "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/entity/Book.java"
    click AUTHORENT "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/entity/Author.java"
    click BOOKDTO "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/model/BookDto.java"
    click AUTHORDTO "https://github.com/up2code/spring-book-store/blob/main/src/main/java/dev/up2up/springbookstore/model/AuthorDto.java"
    click DB "https://github.com/up2code/spring-book-store/tree/main/docker/postgres/"
    click PROM "https://github.com/up2code/spring-book-store/tree/main/docker/prometheus/"
    click GRAF "https://github.com/up2code/spring-book-store/tree/main/docker/grafana/"
    click PGADMIN "https://github.com/up2code/spring-book-store/tree/main/docker/pgadmin/"
```
