# akkshatbhandari/real_time_email_queue_system architecture

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

- Interactive diagram: https://gitdiagram.com/akkshatbhandari/real_time_email_queue_system
- Repository: https://github.com/akkshatbhandari/real_time_email_queue_system

## Overview

This repository implements an asynchronous welcome-email queue: a client registers a user, the producer records the user, email job, and outbox event, and a publisher dispatches work for a consumer to send and track. The source index confirms the outbox publisher’s database and queue dependencies; the worker excerpt shows status checks, delivery, and acknowledgments. The README provides no further capability details, and several integrations are only partially sampled, so unsupported links are omitted or marked unverified.

Main entry points: [`email_queue_system/producer/app/routes/users.py`](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/routes/users.py) (User API), [`email_queue_system/producer/app/database.py`](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/database.py) (Producer database access), [`email_queue_system/producer/app/services/outbox_publisher.py`](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/services/outbox_publisher.py) (Outbox publisher), [`email_queue_system/consumer/app/worker.py`](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/worker.py) (Message worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_producer["Email producer"]
  node_users_api["User API<br/>[users.py]"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_user_schema["User schema<br/>[user.py]"]
  node_welcome_email["Welcome email builder<br/>[email_service.py]"]
end

subgraph group_records["Producer records"]
  node_producer_db["Producer database access<br/>[database.py]"]
  node_user_model["User record<br/>[user.py]"]
  node_job_model["Email job record<br/>[email_job.py]"]
  node_outbox_model["Outbox event record<br/>[outbox.py]"]
end

subgraph group_dispatch["Queue dispatch"]
  node_publisher["Outbox publisher"]
  node_queue_service["Queue publisher<br/>[queue_service.py]"]
end

subgraph group_consumer["Email consumer"]
  node_consumer_worker["Message worker<br/>[worker.py]"]
  node_consumer_rabbit["RabbitMQ consumer<br/>[rabbitmq.py]"]
  node_consumer_db["Consumer database access<br/>[database.py]"]
  node_email_sender["SMTP email sender<br/>[email_service.py]"]
end

node_client(("API client"))
node_broker["RabbitMQ"]
node_producer_store[("PostgreSQL")]
node_smtp["SMTP service"]

node_client -->|"sends request"| node_api_app
node_api_app -->|"routes requests"| node_users_api
node_users_api -->|"validates input"| node_user_schema
node_users_api -->|"builds email"| node_welcome_email
node_users_api -->|"uses session"| node_producer_db
node_users_api -->|"creates user"| node_user_model
node_users_api -->|"creates job"| node_job_model
node_users_api -->|"creates event"| node_outbox_model
node_producer_db -->|"connects to"| node_producer_store
node_api_app -->|"creates tables"| node_producer_db
node_publisher -->|"reads events"| node_producer_db
node_publisher -->|"loads events"| node_outbox_model
node_publisher -->|"publishes through"| node_queue_service
node_queue_service -->|"publishes messages"| node_broker
node_consumer_worker -->|"consumes messages"| node_consumer_rabbit
node_consumer_rabbit -->|"receives messages"| node_broker
node_consumer_worker -->|"checks and updates"| node_consumer_db
node_consumer_worker -->|"sends email"| node_email_sender
node_consumer_db -->|"connects to"| node_producer_store
node_email_sender -->|"delivers via"| node_smtp

click node_users_api "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/routes/users.py"
click node_api_app "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/main.py"
click node_user_schema "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/schemas/user.py"
click node_welcome_email "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/services/email_service.py"
click node_producer_db "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/database.py"
click node_user_model "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/models/user.py"
click node_job_model "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/models/email_job.py"
click node_outbox_model "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/models/outbox.py"
click node_publisher "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/services/outbox_publisher.py"
click node_queue_service "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/services/queue_service.py"
click node_consumer_worker "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/worker.py"
click node_consumer_rabbit "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/rabbitmq.py"
click node_consumer_db "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/database.py"
click node_email_sender "https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/email_service.py"

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_users_api,node_api_app,node_user_schema,node_welcome_email,node_client toneBlue
class node_producer_db,node_user_model,node_job_model,node_outbox_model,node_producer_store toneAmber
class node_publisher,node_queue_service toneMint
class node_consumer_worker,node_consumer_rabbit,node_consumer_db,node_email_sender toneRose
class node_broker,node_smtp toneIndigo
```

## Components

### Email producer

- [User API](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/routes/users.py): `email_queue_system/producer/app/routes/users.py`
- [FastAPI app](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/main.py): `email_queue_system/producer/app/main.py`
- [User schema](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/schemas/user.py): `email_queue_system/producer/app/schemas/user.py`
- [Welcome email builder](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/services/email_service.py): `email_queue_system/producer/app/services/email_service.py`

### Producer records

- [Producer database access](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/database.py): `email_queue_system/producer/app/database.py`
- [User record](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/models/user.py): `email_queue_system/producer/app/models/user.py`
- [Email job record](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/models/email_job.py): `email_queue_system/producer/app/models/email_job.py`
- [Outbox event record](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/models/outbox.py): `email_queue_system/producer/app/models/outbox.py`

### Queue dispatch

- [Outbox publisher](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/services/outbox_publisher.py): `email_queue_system/producer/app/services/outbox_publisher.py`
- [Queue publisher](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/producer/app/services/queue_service.py): `email_queue_system/producer/app/services/queue_service.py`

### Email consumer

- [Message worker](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/worker.py): `email_queue_system/consumer/app/worker.py`
- [RabbitMQ consumer](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/rabbitmq.py): `email_queue_system/consumer/app/rabbitmq.py`
- [Consumer database access](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/database.py): `email_queue_system/consumer/app/database.py`
- [SMTP email sender](https://github.com/akkshatbhandari/real_time_email_queue_system/blob/main/email_queue_system/consumer/app/email_service.py): `email_queue_system/consumer/app/email_service.py`

### Other components

- **API client**
- **RabbitMQ**
- **PostgreSQL**
- **SMTP service**

## Connections

- API client → FastAPI app: sends request (evidence: `email_queue_system/producer/app/main.py`)
- FastAPI app → User API: routes requests (evidence: `email_queue_system/producer/app/main.py`)
- User API → User schema: validates input (evidence: `email_queue_system/producer/app/routes/users.py`)
- User API → Welcome email builder: builds email (evidence: `email_queue_system/producer/app/routes/users.py`)
- User API → Producer database access: uses session (evidence: `email_queue_system/producer/app/routes/users.py`)
- User API → User record: creates user (evidence: `email_queue_system/producer/app/routes/users.py`)
- User API → Email job record: creates job (evidence: `email_queue_system/producer/app/routes/users.py`)
- User API → Outbox event record: creates event (evidence: `email_queue_system/producer/app/routes/users.py`)
- Producer database access → PostgreSQL: connects to (evidence: `email_queue_system/producer/app/database.py`)
- FastAPI app → Producer database access: creates tables (evidence: `email_queue_system/producer/app/main.py`)
- Outbox publisher → Producer database access: reads events (evidence: `email_queue_system/producer/app/services/outbox_publisher.py`)
- Outbox publisher → Outbox event record: loads events (evidence: `email_queue_system/producer/app/services/outbox_publisher.py`)
- Outbox publisher → Queue publisher: publishes through (evidence: `email_queue_system/producer/app/services/outbox_publisher.py`)
- Queue publisher → RabbitMQ: publishes messages (evidence: `email_queue_system/producer/app/services/queue_service.py`)
- Message worker → RabbitMQ consumer: consumes messages (evidence: `email_queue_system/consumer/app/worker.py`)
- RabbitMQ consumer → RabbitMQ: receives messages (evidence: `email_queue_system/consumer/app/rabbitmq.py`)
- Message worker → Consumer database access: checks and updates (evidence: `email_queue_system/consumer/app/worker.py`)
- Message worker → SMTP email sender: sends email (evidence: `email_queue_system/consumer/app/worker.py`)
- Consumer database access → PostgreSQL: connects to (evidence: `email_queue_system/consumer/app/database.py`)
- SMTP email sender → SMTP service: delivers via (evidence: `email_queue_system/consumer/app/email_service.py`)
