# youabledev/spring-safe-http architecture

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

- Interactive diagram: https://gitdiagram.com/youabledev/spring-safe-http
- Repository: https://github.com/youabledev/spring-safe-http

## Overview

##### Project Type Analysis
This is a Spring Boot library project focused on providing HTTP body encryption/decryption functionality. It's designed to be integrated into other Spring Boot applications as a dependency.

##### Main Components

A. Core Components:
- Request Handling Layer
- Response Handling Layer
- Encryption/Decryption Service Layer
- Configuration Layer

B. Key Classes and Their Relationships:
- Annotation Components (@DecryptRequest, @EncryptResponse)
- Advice Components (DecryptRequestBodyAdvice)
- AOP Components (EncryptResponseAspect)
- Cipher Implementation (AESCipher, RSACipher)
- Auto-configuration (AutoConfig)

**[Client Application] <---> [Spring Safe HTTP Library]**

- v
**[Request Processing Flow]     [Response Processing Flow]**

##### Integration Layer
- How the library integrates with the host application
- Annotation-based integration points

##### Processing Layer
- Request Decryption Flow
- Response Encryption Flow

##### Core Services Layer
- Encryption/Decryption Services
- Cipher Implementations

##### Specific Elements

- Blue: Spring Framework components
- Green: Encryption/Decryption services
- Yellow: Annotation processors
- Gray: Configuration components

c. Components:
- [Client Request] -> [@DecryptRequest] -> [DecryptRequestBodyAdvice] -> [HttpCipher] -> [Controller]
- [Controller] -> [@EncryptResponse] -> [EncryptResponseAspect] -> [HttpCipher] -> [Encrypted Response]

##### Important Details to Highlight

- Auto-configuration capability
- AES and RSA cipher implementations
- Spring AOP integration
- Request/Response interceptor pattern

##### Implementation Notes

- Use standardized UML notation where appropriate
- Notes for important configuration requirements
- Relationship with Spring Boot's auto-configuration mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CR[Client Request]
        ER[Encrypted Response]
    end

    subgraph "Spring Safe HTTP Library"
        subgraph "Request Processing Flow"
            DR["@DecryptRequest"]:::annotation
            DRA["DecryptRequestBodyAdvice"]:::advice
            DIM["DecryptedHttpInputMessage"]:::component
        end

        subgraph "Response Processing Flow"
            ERA["@EncryptResponse"]:::annotation
            REA["EncryptResponseAspect"]:::aspect
        end

        subgraph "Core Services"
            HC["HttpCipher Interface"]:::interface
            AESC["AES Cipher"]:::implementation
            RSAC["RSA Cipher"]:::implementation
        end

        subgraph "Configuration"
            AC["AutoConfig"]:::config
            AI["Auto Configuration Imports"]:::config
        end
    end

    subgraph "Spring Application"
        CTRL[Controller]:::spring
    end

    %% Flow
    CR --> DR
    DR --> DRA
    DRA --> DIM
    DIM --> HC
    HC --> CTRL
    CTRL --> ERA
    ERA --> REA
    REA --> HC
    HC --> ER

    %% Service Implementation Relations
    HC --> AESC
    HC --> RSAC
    AC --> HC

    %% Styling
    classDef spring fill:#6DB33F,stroke:#000,color:white
    classDef annotation fill:#FFD700,stroke:#000
    classDef advice fill:#87CEEB,stroke:#000
    classDef aspect fill:#87CEEB,stroke:#000
    classDef component fill:#FFFFFF,stroke:#000
    classDef interface fill:#90EE90,stroke:#000
    classDef implementation fill:#98FB98,stroke:#000
    classDef config fill:#D3D3D3,stroke:#000

    %% Click Events
    click DR "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/annotation/DecryptRequest.java"
    click DRA "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/advice/DecryptRequestBodyAdvice.java"
    click DIM "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/advice/DecryptedHttpInputMessage.java"
    click ERA "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/annotation/EncryptResponse.java"
    click REA "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/aop/EncryptResponseAspect.java"
    click HC "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/cipher/HttpCipher.java"
    click AESC "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/cipher/AESCipher.java"
    click RSAC "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/cipher/RSACipher.java"
    click AC "https://github.com/youabledev/spring-safe-http/blob/main/src/main/java/com/youable/safehttp/config/AutoConfig.java"
    click AI "https://github.com/youabledev/spring-safe-http/blob/main/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports"
```
