# kievmaia/springwolf-async-api-exemple architecture

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

- Interactive diagram: https://gitdiagram.com/kievmaia/springwolf-async-api-exemple
- Repository: https://github.com/kievmaia/springwolf-async-api-exemple

## Overview

##### Project type and purpose
- This is a Spring Boot backend application whose sole purpose is to demonstrate the automatic generation of AsyncAPI documentation (via Springwolf) for event-driven APIs built on AWS SNS/SQS.
- It also includes a simple publisher (SnsPublisherService) and a listener (SqsListenerService) to show how events flow, all wired to AWS emulated by LocalStack in Docker Compose.

##### High-level components (based on the file tree & README)
- Docker Compose / LocalStack: emulates AWS services locally (SNS, SQS).
- Spring Boot Application
- Configuration modules: AWS configs (SnsConfig, SqsConfig), Jackson (ObjectMapperConfig)
- DTOs & Enums: message payload definitions (ExamplePayloadDto, AnotherPayloadDto, ExampleEnum)
- Messaging services: SnsPublisherService (publishes messages to a topic), SqsListenerService (listens on a queue)
- Springwolf AsyncAPI generator: introspects publisher/listener annotations and generates UI & JSON docs.
- End-users/developers: consume the generated AsyncAPI UI or JSON endpoint.

##### Relationships and data-flow
- On application start, Docker Compose spins up LocalStack with SNS and SQS.
- Spring Boot app connects (via SnsConfig/SqsConfig) to LocalStack endpoints.
- SnsPublisherService → sends event → LocalStack SNS Topic → routed to LocalStack SQS Queue → SqsListenerService within the app
- Springwolf inspects these flows and exposes:
- HTTP GET /springwolf/docs → AsyncAPI JSON
- HTTP GET /springwolf/asyncapi-ui.html → interactive UI

##### Architectural patterns & design principles
- Event-driven, asynchronous microservice
- Clear separation of concerns:
- configuration (in /configuration)
- domain/messages (in /dtos and /enums)
- integration/messaging (in /messaging)
- documentation generation (Springwolf)
- Use of dependency injection for configuration and services (Spring Boot)
- Emulation of external dependencies via Docker Compose (LocalStack)

##### Detailed capture of architecture
- Don’t overthink: break the project into these core components and show how they interact.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Infrastructure Layer
    subgraph "Infrastructure Layer" 
        direction TB
        LSContainer["LocalStack Container"]:::infra
        SNS["SNS Topic"]:::infra
        SQS["SQS Queue"]:::infra
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        subgraph "Spring Boot Application" 
            direction TB
            SB["SpringWolfAsyncApiExempleApplication<br/>(Entry Point)"]:::app

            subgraph "Configuration Layer"
                direction TB
                SnsCfg["SnsConfig"]:::app
                SqsCfg["SqsConfig"]:::app
                ObjMapCfg["ObjectMapperConfig"]:::app
            end

            subgraph "Messaging Layer"
                direction TB
                Publisher["SnsPublisherService"]:::app
                Listener["SqsListenerService"]:::app
            end

            subgraph "Documentation Module"
                direction TB
                Springwolf["Springwolf AsyncAPI Generator"]:::app
            end
        end
    end

    %% Presentation Layer
    Dev["Developer/Client"]:::ext

    %% Data Flow Arrows
    Publisher -->|"publishes to"| SNS
    SNS -->|"routes to"| SQS
    SQS -->|"consumed by"| Listener
    Springwolf -->|"HTTP GET /springwolf/docs UI/JSON"| Dev

    %% Config Connections
    SB --> SnsCfg
    SB --> SqsCfg
    SB --> ObjMapCfg
    SB --> Publisher
    SB --> Listener
    SB --> Springwolf

    %% Infra Connections
    SnsCfg --> LSContainer
    SqsCfg --> LSContainer

    %% Click Events
    click LSContainer "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/docker/docker-compose.yaml"
    click SNS "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/docker/localstack-init.sh"
    click SB "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/src/main/java/com/kiev/SpringWolfAsyncApiExempleApplication.java"
    click SnsCfg "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/src/main/java/com/kiev/configuration/aws/SnsConfig.java"
    click SqsCfg "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/src/main/java/com/kiev/configuration/aws/SqsConfig.java"
    click ObjMapCfg "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/src/main/java/com/kiev/configuration/jackson/ObjectMapperConfig.java"
    click Publisher "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/src/main/java/com/kiev/messaging/SnsPublisherService.java"
    click Listener "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/src/main/java/com/kiev/messaging/SqsListenerService.java"
    click Dev "https://github.com/kievmaia/springwolf-async-api-exemple/blob/main/README.md"

    %% Styles
    classDef infra fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef app fill:#e0ffe0,stroke:#28a745,color:#28a745;
    classDef ext fill:#ffe5b4,stroke:#f66d06,color:#f66d06;
```
