# aws-developers-learning/sqs-sample architecture

> Architecture diagram of the GitHub repository aws-developers-learning/sqs-sample, 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/aws-developers-learning/sqs-sample
- Repository: https://github.com/aws-developers-learning/sqs-sample

## Overview

##### Main Components
- Producer Application:
- Represented as a Spring Boot microservice.
- Contains a REST controller (e.g., SqsController) that listens for POST requests on the “/send” endpoint.
- Uses a service (SqsSenderMessage) to send messages to the SQS queue.
- Has its own configuration (SqsConfig) defined in its package.
- AWS SQS Queue:
- Central message broker.
- Acts as the middleman that receives messages from the producer and delivers them to the listener.
- Listener Application:
- Represented as another Spring Boot microservice.
- Contains a listener component (SqsReceiverMessage) responsible for polling the SQS queue.
- Logs/handles the incoming messages upon reception.
- External Interaction (Optional):
- Client or API testing tool (e.g., Postman or HTTPie) that sends a POST request to the producer.

##### Relationships and Interactions
- The client sends a POST request to the Producer Application’s endpoint (/send) with a message payload.
- The Producer Application uses its SqsSenderMessage service to push the message into the SQS queue (configured via SqsConfig).
- The SQS queue temporarily stores the message.
- The Listener Application actively polls or gets notified from the SQS queue.
- Upon receiving the message, the Listener (using SqsReceiverMessage) processes/logs the message.

##### Architectural Patterns and Design Principles
- Messaging/Asynchronous Communication: Highlight the use of AWS SQS as an asynchronous broker to decouple the producer from the consumer.
- Microservices Separation: Each application (producer and listener) is an independent Spring Boot service.
- Cloud Integration: The design includes integration with AWS services (access keys, SQS queue creation, AWS SDK usage as noted in the README).

##### Relevant Technologies, Frameworks, and Libraries
- Spring Boot (for creating both the Producer and Listener applications)
- AWS SDK / Spring Cloud AWS (for integration with AWS SQS)
- Maven (pom.xml files indicate the build tool and dependency management)
- AWS SQS (as the messaging broker)

## Diagram (Mermaid)

```mermaid
graph TD
    Client["HTTP Client / Postman"]:::clientStyle

    subgraph "Producer Application (Spring Boot)"
        P_App["Producer Application"]:::producerStyle
        P_Controller["SqsController (/send)"]:::producerStyle
        P_Service["SqsSenderMessage"]:::producerStyle
        P_Config["SqsConfig"]:::producerStyle
    end

    SQS["AWS SQS Queue"]:::sqsStyle

    subgraph "Listener Application (Spring Boot)"
        L_App["Listener Application"]:::listenerStyle
        L_Listener["SqsReceiverMessage"]:::listenerStyle
    end

    Client -->|"POST /send"| P_Controller
    P_Controller -->|"calls"| P_Service
    P_Service -->|"sendsMessage"| SQS
    P_Service -->|"uses"| P_Config
    SQS -->|"deliversMessage"| L_Listener

    click P_App "https://github.com/aws-developers-learning/sqs-sample/tree/main/awssqsproducer/"
    click P_Controller "https://github.com/aws-developers-learning/sqs-sample/blob/main/awssqsproducer/src/main/java/io/github/awsdeveloperslearning/awssqsproducer/controller/SqsController.java"
    click P_Service "https://github.com/aws-developers-learning/sqs-sample/blob/main/awssqsproducer/src/main/java/io/github/awsdeveloperslearning/awssqsproducer/service/SqsSenderMessage.java"
    click P_Config "https://github.com/aws-developers-learning/sqs-sample/blob/main/awssqsproducer/src/main/java/io/github/awsdeveloperslearning/awssqsproducer/config/SqsConfig.java"
    click L_App "https://github.com/aws-developers-learning/sqs-sample/tree/main/awssqslistener/"
    click L_Listener "https://github.com/aws-developers-learning/sqs-sample/blob/main/awssqslistener/src/main/java/io/github/awsdeveloperslearning/awssqslistener/listener/SqsReceiverMessage.java"

    classDef clientStyle fill:#f9d342,stroke:#333,stroke-width:2px;
    classDef producerStyle fill:#85C1E9,stroke:#1F618D,stroke-width:2px;
    classDef sqsStyle fill:#F5B041,stroke:#BA4A00,stroke-width:2px;
    classDef listenerStyle fill:#82E0AA,stroke:#229954,stroke-width:2px;
```
