# carlosfgti/node-rabbitmq architecture

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

- Interactive diagram: https://gitdiagram.com/carlosfgti/node-rabbitmq
- Repository: https://github.com/carlosfgti/node-rabbitmq

## Overview

##### Project Type and Purpose
- This is a small messaging demo application built with Node.js and RabbitMQ, orchestrated via Docker Compose.
- Its purpose is to illustrate how a producer service can enqueue messages and how a consumer service dequeues and processes them, all running alongside a RabbitMQ server with management UI.

##### File Structure
- Top-level:
- docker-compose.yaml – defines three services (rabbitmq, producer, consumer)
- package.json & package-lock.json – Node.js dependencies
- readme.md – high-level description
- src/
- producer.js – Node.js script that publishes messages to a RabbitMQ queue
- consumer.js – Node.js script that subscribes to the same queue and handles incoming messages

##### Extract Insights from README
- Confirms three main components: producer, consumer, RabbitMQ server (management UI included).
- Technology stack: Node.js, amqplib (RabbitMQ client), Docker, Docker Compose.

a. Main Components
- Producer Service (Node.js container)
- Consumer Service (Node.js container)
- RabbitMQ Broker (Docker container with management plugin/UI)
- (Optional) External clients or dashboards that interact with the management UI
b. Relationships and Interactions
- Producer → RabbitMQ: publish messages to a named queue
- Consumer ← RabbitMQ: consume messages from the same queue
- Management UI ↔ RabbitMQ: HTTP port for monitoring
c. Architectural Patterns & Principles
- Asynchronous message-driven communication (decoupling producer & consumer)
- Containerization for environment parity and isolation
- Single-responsibility services: each script has a clear role
d. Key Technologies
- Node.js & amqplib library for AMQP protocol
- RabbitMQ server with default “task_queue” or user-defined queue
- Docker Compose for multi-container orchestration

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Docker Compose Environment"
        direction TB
        Producer["Producer Service\n(src/producer.js)"]:::app
        RabbitMQ["RabbitMQ Broker\n(5672 AMQP, 15672 HTTP UI)"]:::broker
        Consumer["Consumer Service\n(src/consumer.js)"]:::app
        DockerComposeConfig["Docker Compose Config\n(docker-compose.yaml)"]:::infra
    end

    Producer -->|"publish to queue \"task_queue\""| RabbitMQ
    RabbitMQ -->|"deliver from queue \"task_queue\""| Consumer
    UI["Management UI\n(HTTP 15672)"]:::ui
    UI -->|"monitoring API"| RabbitMQ
    DockerComposeConfig -.-> Producer
    DockerComposeConfig -.-> RabbitMQ
    DockerComposeConfig -.-> Consumer

    subgraph "Project Files"
        Package["package.json"]:::infra
        Readme["readme.md"]:::infra
    end

    click Producer "https://github.com/carlosfgti/node-rabbitmq/blob/main/src/producer.js"
    click Consumer "https://github.com/carlosfgti/node-rabbitmq/blob/main/src/consumer.js"
    click RabbitMQ "https://github.com/carlosfgti/node-rabbitmq/blob/main/docker-compose.yaml"
    click DockerComposeConfig "https://github.com/carlosfgti/node-rabbitmq/blob/main/docker-compose.yaml"
    click Package "https://github.com/carlosfgti/node-rabbitmq/blob/main/package.json"
    click Readme "https://github.com/carlosfgti/node-rabbitmq/blob/main/readme.md"

    classDef app fill:#B0E0E6,stroke:#000,stroke-width:1px
    classDef broker fill:#FFA500,stroke:#000,stroke-width:1px
    classDef infra fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ui fill:#FFD700,stroke:#000,stroke-width:1px
```
