# justcodes/loafer-go architecture

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

- Interactive diagram: https://gitdiagram.com/justcodes/loafer-go
- Repository: https://github.com/justcodes/loafer-go

## Overview

##### Main Components

a. Core Components:
- Message Manager (central orchestrator)
- Route Handler System
- AWS Integration Layer
- SNS Producer
- SQS Consumer
- Message Processing Workers Pool

b. External Services:
- AWS SNS
- AWS SQS

##### Application Integration Layer
- How client applications integrate with Loafer Go
- Configuration objects (Config, ClientConfig)

##### Core Processing Layer
- Manager component (from manager.go)
- Router interface implementation
- Worker Pool management

##### AWS Service Layer
- SNS Client & Producer
- SQS Client & Consumer
- Message handling flow

Use these specific visual elements:

- Components:
- Hexagons for interfaces

- Blue: Core Loafer components
- Orange: AWS services
- Green: Message flow paths
- Gray: Configuration components

##### Key Flows

a) Producer Flow:
**Client App → SNS Producer → AWS SNS → AWS SQS**

b) Consumer Flow:
**AWS SQS → SQS Consumer → Worker Pool → Handler Functions**

##### Important Details

- Message routing configuration
- Worker pool scaling
- Error handling paths
- Configuration options
- Retry mechanisms
- Message visibility timeout handling

##### Specific Implementation Notes

Key features:
- Multiple route handling capability
- Async message processing
- Message backoff mechanism
- AWS credential management
- Queue configuration options

- Message flow direction
- Component types
- Configuration options
- Worker pool scaling indicators
- Error handling paths

Keep these aspects in mind:
- Separation between producer and consumer functionality
- Async nature of the system
- Demonstrate how multiple handlers can process messages from the same queue
- Configuration points for AWS credentials and endpoints

##### The flexibility in routing and handling messages

This will give a comprehensive view of how Loafer Go integrates with AWS messaging services while maintaining the right level of abstraction to understand the system's architecture without getting lost in implementation details.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application Layer"]
        APP[Client Application]
        CFG[Configuration]:::config
    end

    subgraph Core["Core Processing Layer"]
        MGR[Message Manager]:::core
        RTR[Route Handler]:::core
        WRK[Worker Pool]:::core
        INTF[Core Interfaces]:::core
        LOG[Logger]:::core
        ERR[Error Handler]:::core
    end

    subgraph AWS["AWS Integration Layer"]
        AWSCFG[AWS Configuration]:::config
        
        subgraph SNS["SNS Components"]
            SNSC[SNS Client]:::aws
            SNSP[SNS Producer]:::aws
            SNSCFG[SNS Config]:::config
        end
        
        subgraph SQS["SQS Components"]
            SQSC[SQS Client]:::aws
            SQSCSM[SQS Consumer]:::aws
            SQSCFG[SQS Config]:::config
            MSG[Message Processor]:::aws
        end
    end

    subgraph External["AWS Cloud Services"]
        AWSSNS[("AWS SNS")]:::external
        AWSSQS[("AWS SQS")]:::external
    end

    %% Connections
    APP --> CFG
    APP --> MGR
    CFG --> AWSCFG
    
    MGR --> RTR
    MGR --> WRK
    MGR --> INTF
    MGR --> LOG
    MGR --> ERR
    
    RTR --> MSG
    WRK --> MSG
    
    SNSC --> SNSCFG
    SNSP --> SNSC
    SNSC --> AWSSNS
    
    SQSC --> SQSCFG
    SQSCSM --> SQSC
    SQSC --> AWSSQS
    
    AWSSNS --> AWSSQS
    
    %% Click Events
    click MGR "https://github.com/JustCodes/loafer-go/blob/main/manager.go"
    click RTR "https://github.com/JustCodes/loafer-go/blob/main/aws/sqs/route.go"
    click SNSP "https://github.com/JustCodes/loafer-go/blob/main/aws/sns/producer.go"
    click MSG "https://github.com/JustCodes/loafer-go/blob/main/aws/sqs/message.go"
    click CFG "https://github.com/JustCodes/loafer-go/blob/main/config.go"
    click AWSCFG "https://github.com/JustCodes/loafer-go/blob/main/aws/config.go"
    click SNSCFG "https://github.com/JustCodes/loafer-go/blob/main/aws/sns/config.go"
    click SQSCFG "https://github.com/JustCodes/loafer-go/blob/main/aws/sqs/config.go"
    click INTF "https://github.com/JustCodes/loafer-go/blob/main/interfaces.go"
    click ERR "https://github.com/JustCodes/loafer-go/blob/main/errors.go"
    click LOG "https://github.com/JustCodes/loafer-go/blob/main/logger.go"
    click SNSC "https://github.com/JustCodes/loafer-go/blob/main/aws/sns/client.go"
    click SQSC "https://github.com/JustCodes/loafer-go/blob/main/aws/sqs/client.go"

    %% Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef aws fill:#ff9900,stroke:#ff9900,color:#000
    classDef external fill:#ff9900,stroke:#ff9900,color:#000
    classDef config fill:#95a5a6,stroke:#95a5a6,color:#000

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[AWS Components]:::aws
        L3[Configuration]:::config
    end
```
