# paulocoutinhox/queuefy architecture

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

- Interactive diagram: https://gitdiagram.com/paulocoutinhox/queuefy
- Repository: https://github.com/paulocoutinhox/queuefy

## Overview

Queuefy is an asynchronous task queue and scheduler: callers declare tasks and enqueue immediate or scheduled runs; workers claim due runs from a shared store, execute handlers, and settle or retry them. Recurring triggers write future runs through the same queue, enabling one-claim-per-run coordination across workers and machines. The graph includes the documented scheduling modes, retries, lifecycle hooks, worker recovery, queue controls, and pluggable stores. Some links use README evidence because implementation excerpts are incomplete.

Main entry points: [`src/queuefy/app.py`](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/app.py) (Queue API), [`src/queuefy/worker.py`](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/worker.py) (Worker), [`src/queuefy/run.py`](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/run.py) (Run Record), [`src/queuefy/trigger.py`](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/trigger.py) (Schedule Triggers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Task and Scheduling"]
  node_app["Queue API<br/>[app.py]"]
  node_task["Task Definition<br/>[task.py]"]
  node_trigger["Schedule Triggers<br/>[trigger.py]"]
  node_cron["Cron Parser<br/>[cron.py]"]
end

subgraph group_execution["Worker Execution"]
  node_worker["Worker<br/>[worker.py]"]
  node_retry["Retry Policies<br/>[retry.py]"]
  node_hooks["Lifecycle Hooks<br/>[worker.py]"]
  node_asgi["ASGI Lifespan<br/>[asgi.py]"]
end

subgraph group_storage["Run Persistence"]
  node_store["Store Contract<br/>[base.py]"]
  node_memory[("Memory Store<br/>[memory.py]")]
  node_redis[("Redis Store<br/>[redis.py]")]
  node_sqlalchemy[("SQLAlchemy Store<br/>[sqlalchemy.py]")]
end

subgraph group_core["Shared Runtime"]
  node_run["Run Record<br/>[run.py]"]
  node_clock["Time Utilities<br/>[clock.py]"]
end

node_caller(("Application Caller"))
node_handler(("Task Handler"))

node_caller -->|"enqueues tasks"| node_app
node_caller -->|"declares tasks"| node_task
node_app -->|"writes runs"| node_store
node_app -->|"gets next due"| node_trigger
node_trigger -->|"parses cron"| node_cron
node_app -->|"builds run"| node_run
node_worker -->|"claims runs"| node_store
node_worker -->|"executes handler"| node_handler
node_worker -.->|"calculates retries"| node_retry
node_worker -->|"fires lifecycle hooks"| node_hooks
node_worker -->|"settles attempts"| node_run
node_worker -->|"timestamps claims"| node_clock
node_app -.->|"accepts pluggable store"| node_memory
node_app -.->|"accepts pluggable store"| node_redis
node_app -.->|"accepts pluggable store"| node_sqlalchemy
node_asgi -->|"starts worker"| node_worker
node_run -->|"records retry policy"| node_retry

click node_app "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/app.py"
click node_task "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/task.py"
click node_trigger "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/trigger.py"
click node_cron "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/cron.py"
click node_worker "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/worker.py"
click node_retry "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/retry.py"
click node_store "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/store/base.py"
click node_memory "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/store/memory.py"
click node_redis "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/store/redis.py"
click node_sqlalchemy "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/store/sqlalchemy.py"
click node_run "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/run.py"
click node_clock "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/clock.py"
click node_hooks "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/worker.py"
click node_asgi "https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/asgi.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_app,node_task,node_trigger,node_cron toneBlue
class node_worker,node_retry,node_hooks,node_asgi toneAmber
class node_store,node_memory,node_redis,node_sqlalchemy toneMint
class node_run,node_clock,node_handler toneRose
class node_caller toneIndigo
```

## Components

### Task and Scheduling

- [Queue API](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/app.py): `src/queuefy/app.py`
- [Task Definition](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/task.py): `src/queuefy/task.py`
- [Schedule Triggers](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/trigger.py): `src/queuefy/trigger.py`
- [Cron Parser](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/cron.py): `src/queuefy/cron.py`

### Worker Execution

- [Worker](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/worker.py): `src/queuefy/worker.py`
- [Retry Policies](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/retry.py): `src/queuefy/retry.py`
- [Lifecycle Hooks](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/worker.py): `src/queuefy/worker.py`
- [ASGI Lifespan](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/asgi.py): `src/queuefy/asgi.py`

### Run Persistence

- [Store Contract](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/store/base.py): `src/queuefy/store/base.py`
- [Memory Store](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/store/memory.py): `src/queuefy/store/memory.py`
- [Redis Store](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/store/redis.py): `src/queuefy/store/redis.py`
- [SQLAlchemy Store](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/store/sqlalchemy.py): `src/queuefy/store/sqlalchemy.py`

### Shared Runtime

- [Run Record](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/run.py): `src/queuefy/run.py`
- [Time Utilities](https://github.com/paulocoutinhox/queuefy/blob/main/src/queuefy/clock.py): `src/queuefy/clock.py`

### Other components

- **Application Caller**
- **Task Handler**

## Connections

- Application Caller → Queue API: enqueues tasks (evidence: `README.md`)
- Application Caller → Task Definition: declares tasks (evidence: `README.md`)
- Queue API → Store Contract: writes runs (evidence: `src/queuefy/app.py`)
- Queue API → Schedule Triggers: gets next due (evidence: `src/queuefy/app.py`)
- Schedule Triggers → Cron Parser: parses cron (evidence: `src/queuefy/trigger.py`)
- Queue API → Run Record: builds run (evidence: `src/queuefy/app.py`)
- Worker → Store Contract: claims runs (evidence: `src/queuefy/worker.py`)
- Worker → Task Handler: executes handler (evidence: `README.md`)
- Worker → Retry Policies: calculates retries (evidence: `src/queuefy/worker.py`)
- Worker → Lifecycle Hooks: fires lifecycle hooks (evidence: `src/queuefy/worker.py`)
- Worker → Run Record: settles attempts (evidence: `src/queuefy/worker.py`)
- Worker → Time Utilities: timestamps claims (evidence: `src/queuefy/worker.py`)
- Queue API → Memory Store: accepts pluggable store (evidence: `README.md`)
- Queue API → Redis Store: accepts pluggable store (evidence: `README.md`)
- Queue API → SQLAlchemy Store: accepts pluggable store (evidence: `README.md`)
- ASGI Lifespan → Worker: starts worker (evidence: `src/queuefy/asgi.py`)
- Run Record → Retry Policies: records retry policy (evidence: `src/queuefy/run.py`)
