# bad-microservices/amqp_helper architecture

> Architecture diagram of the GitHub repository bad-microservices/amqp_helper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bad-microservices/amqp_helper
- Repository: https://github.com/bad-microservices/amqp_helper

## Overview

##### Main Components

a. Core Components (Central Layer):
- AMQPConfig (Configuration Management)
- AMQPClient (Client Implementation)
- AMQPService (Server Implementation)
- AMQPFunction (RPC Function Wrapper)
- AMQPLogHandler (Logging Integration)

b. External Dependencies (Top Layer):
- aio-pika (Main AMQP Library)
- Python's asyncio (Async Runtime)
- Python's logging (for Log Handler)

c. Message Broker (Bottom Layer):
- AMQP Broker (e.g., RabbitMQ)
- Exchange
- Queues

##### Component Relationships

- AMQPConfig → All other components (provides configuration)
- AMQPClient → AMQP Broker (sends requests)
- AMQPService → AMQP Broker (handles requests)
- AMQPLogHandler → AMQP Broker (sends logs)
- External Applications → AMQPClient/AMQPService (usage points)

##### Interaction Flows

a. RPC Flow:
- Client → AMQPClient → Broker → AMQPService → Function Execution → Response

b. Logging Flow:
- Application → AMQPLogHandler → Broker → Log Consumers

c. Configuration Flow:
- AMQPConfig → Components → Broker Connection

##### Implementation Details

- Connection parameters flow
- Exception handling paths
- Message routing patterns
- Queue and exchange creation points

##### Notes Section

Notes about:
- Async operation requirements
- Configuration options
- Error handling strategies
- Logging levels and routing

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Dependencies Layer
    subgraph External
        AioPika["aio-pika"]:::external
        Asyncio["asyncio"]:::external
        Logging["logging"]:::external
    end

    %% Core Components Layer
    subgraph Core
        Config["AMQPConfig"]:::core
        Client["AMQPClient"]:::core
        Service["AMQPService"]:::core
        Function["AMQPFunction"]:::core
        LogHandler["AMQPLogHandler"]:::core
    end

    %% Message Broker Layer
    subgraph Broker
        AMQP["AMQP Broker"]:::broker
        Exchange["Exchange"]:::broker
        Queues["Queues"]:::broker
    end

    %% External Applications
    ExtApp["External Applications"]:::external

    %% Relationships
    ExtApp --> Client
    ExtApp --> Service
    ExtApp --> LogHandler
    
    Config --> Client
    Config --> Service
    Config --> Function
    Config --> LogHandler
    
    Client --> AMQP
    Service --> AMQP
    LogHandler --> AMQP
    
    AMQP --> Exchange
    Exchange --> Queues
    
    AioPika --> Client
    AioPika --> Service
    Asyncio --> Client
    Asyncio --> Service
    Logging --> LogHandler

    %% Click Events
    click Config "https://github.com/bad-microservices/amqp_helper/blob/main/amqp_helper/_amqpconfig.py"
    click Client "https://github.com/bad-microservices/amqp_helper/blob/main/amqp_helper/_amqpclient.py"
    click Service "https://github.com/bad-microservices/amqp_helper/blob/main/amqp_helper/_amqpservice.py"
    click Function "https://github.com/bad-microservices/amqp_helper/blob/main/amqp_helper/_amqpfunction.py"
    click LogHandler "https://github.com/bad-microservices/amqp_helper/blob/main/amqp_helper/_amqploghandler.py"

    %% Styles
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px
    classDef broker fill:#FFE5B4,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["External Dependencies"]:::external
        L3["Broker Components"]:::broker
    end
```
