# lukas9812/api.consumer architecture

> Architecture diagram of the GitHub repository lukas9812/api.consumer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lukas9812/api.consumer
- Repository: https://github.com/lukas9812/api.consumer

## Overview

This repository is a two-process RabbitMQ example: the publisher fetches country data from an external API and sends it to a queue; the receiver consumes messages, parses country data, and writes a country name to rolling-file output. The README documents the shared connection-management role, while the sampled services show the publisher and consumer using that manager. The receiver’s file-writing implementation is an external dependency; its internal details are not present in the tree.

Main entry points: [`RabbitPublisher/Services/PublisherService.cs`](https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/PublisherService.cs) (Publisher service), [`RabbitReceiver/Services/ConsumerService.cs`](https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/ConsumerService.cs) (Consumer service), [`RabbitReceiver/Services/ProcessDataService.cs`](https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/ProcessDataService.cs) (Data processor), [`RabbitPublisher/Services/ApiCallerService.cs`](https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/ApiCallerService.cs) (API caller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_publisher["Publisher"]
  node_api_caller["API caller"]
  node_publisher_host["Publisher host<br/>[HostedService.cs]"]
  node_publisher_service["Publisher service"]
end

subgraph group_broker["Messaging"]
  node_rabbitmq["RabbitMQ broker"]
end

subgraph group_receiver["Receiver"]
  node_receiver_host["Receiver host<br/>[HostedService.cs]"]
  node_consumer["Consumer service<br/>[ConsumerService.cs]"]
  node_processor["Data processor"]
  node_country_model["Country model<br/>[Country.cs]"]
end

subgraph group_connections["Connection Management"]
  node_publisher_connection["Publisher connection manager<br/>[RabbitMqService.cs]"]
  node_receiver_connection["Receiver connection manager<br/>[RabbitMqService.cs]"]
end

node_api(("Country API"))
node_file_output["Rolling file output"]

node_publisher_host -->|"starts"| node_publisher_service
node_publisher_service -->|"fetches data"| node_api_caller
node_api_caller -->|"requests country data"| node_api
node_publisher_service -->|"creates channel"| node_publisher_connection
node_publisher_connection -->|"manages connection"| node_rabbitmq
node_publisher_service -->|"publishes message"| node_rabbitmq
node_receiver_host -->|"starts"| node_consumer
node_consumer -->|"creates channel"| node_receiver_connection
node_receiver_connection -->|"manages connection"| node_rabbitmq
node_rabbitmq -->|"delivers message"| node_consumer
node_consumer -->|"processes message"| node_processor
node_processor -->|"deserializes as"| node_country_model
node_processor -->|"writes country name"| node_file_output

click node_api_caller "https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/ApiCallerService.cs"
click node_publisher_host "https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/HostedService.cs"
click node_publisher_service "https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/PublisherService.cs"
click node_publisher_connection "https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/RabbitMqService.cs"
click node_receiver_host "https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/HostedService.cs"
click node_consumer "https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/ConsumerService.cs"
click node_receiver_connection "https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/RabbitMqService.cs"
click node_processor "https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/ProcessDataService.cs"
click node_country_model "https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Model/Country.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api_caller,node_publisher_host,node_publisher_service toneBlue
class node_rabbitmq toneAmber
class node_receiver_host,node_consumer,node_processor,node_country_model,node_api toneMint
class node_publisher_connection,node_receiver_connection toneRose
class node_file_output toneIndigo
```

## Components

### Publisher

- [API caller](https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/ApiCallerService.cs): `RabbitPublisher/Services/ApiCallerService.cs`
- [Publisher host](https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/HostedService.cs): `RabbitPublisher/Services/HostedService.cs`
- [Publisher service](https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/PublisherService.cs): `RabbitPublisher/Services/PublisherService.cs`

### Messaging

- **RabbitMQ broker**

### Receiver

- [Receiver host](https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/HostedService.cs): `RabbitReceiver/Services/HostedService.cs`
- [Consumer service](https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/ConsumerService.cs): `RabbitReceiver/Services/ConsumerService.cs`
- [Data processor](https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/ProcessDataService.cs): `RabbitReceiver/Services/ProcessDataService.cs`
- [Country model](https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Model/Country.cs): `RabbitReceiver/Model/Country.cs`

### Connection Management

- [Publisher connection manager](https://github.com/lukas9812/api.consumer/blob/master/RabbitPublisher/Services/RabbitMqService.cs): `RabbitPublisher/Services/RabbitMqService.cs`
- [Receiver connection manager](https://github.com/lukas9812/api.consumer/blob/master/RabbitReceiver/Services/RabbitMqService.cs): `RabbitReceiver/Services/RabbitMqService.cs`

### Other components

- **Country API**
- **Rolling file output**

## Connections

- Publisher host → Publisher service: starts (evidence: `RabbitPublisher/Services/HostedService.cs`)
- Publisher service → API caller: fetches data (evidence: `RabbitPublisher/Services/PublisherService.cs`)
- API caller → Country API: requests country data (evidence: `RabbitPublisher/Services/ApiCallerService.cs`)
- Publisher service → Publisher connection manager: creates channel (evidence: `RabbitPublisher/Services/PublisherService.cs`)
- Publisher connection manager → RabbitMQ broker: manages connection (evidence: `README.md`)
- Publisher service → RabbitMQ broker: publishes message (evidence: `RabbitPublisher/Services/PublisherService.cs`)
- Receiver host → Consumer service: starts (evidence: `RabbitReceiver/Services/HostedService.cs`)
- Consumer service → Receiver connection manager: creates channel (evidence: `RabbitReceiver/Services/ConsumerService.cs`)
- Receiver connection manager → RabbitMQ broker: manages connection (evidence: `README.md`)
- RabbitMQ broker → Consumer service: delivers message (evidence: `README.md`)
- Consumer service → Data processor: processes message (evidence: `RabbitReceiver/Services/ConsumerService.cs`)
- Data processor → Country model: deserializes as (evidence: `RabbitReceiver/Services/ProcessDataService.cs`)
- Data processor → Rolling file output: writes country name (evidence: `RabbitReceiver/Services/ProcessDataService.cs`)
