# srinu-design/hopper architecture

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

- Interactive diagram: https://gitdiagram.com/srinu-design/hopper
- Repository: https://github.com/srinu-design/hopper

## Overview

Hopper accepts tenant-scoped jobs over HTTP, stores them durably in PostgreSQL, and has workers execute registered tasks with at-least-once delivery, retries, and dead-letter handling. Scheduling, administration, and operational controls extend that workflow. The README documents core behavior; source excerpts and the SOURCE INDEX support selected module relationships. Several scheduler, API, and queue implementations were not sampled, so their internal call paths are not expanded.

Main entry points: [`src/hopper/api/main.py`](https://github.com/srinu-design/hopper/blob/main/src/hopper/api/main.py) (HTTP application), [`src/hopper/queue/postgres.py`](https://github.com/srinu-design/hopper/blob/main/src/hopper/queue/postgres.py) (PostgreSQL queue), [`src/hopper/worker/loop.py`](https://github.com/srinu-design/hopper/blob/main/src/hopper/worker/loop.py) (Worker loop), [`src/hopper/minibroker/client.py`](https://github.com/srinu-design/hopper/blob/main/src/hopper/minibroker/client.py) (Mini broker client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api["HTTP application<br/>[main.py]"]
  node_jobroutes["Job endpoints<br/>[jobs.py]"]
  node_admin["Admin endpoints<br/>[admin.py]"]
  node_auth["Tenant authentication<br/>[api_keys.py]"]
  node_authstore["Tenant and key store<br/>[store.py]"]
  node_scheduleapi["Schedule endpoints<br/>[schedules.py]"]
  node_web["Web console<br/>[app.js]"]
end

subgraph group_queue["Queue and workers"]
  node_postgresapi[("PostgreSQL queue<br/>[postgres.py]")]
  node_worker["Worker loop<br/>[loop.py]"]
  node_taskregistry["Task registry<br/>[registry.py]"]
  node_httptask["HTTP task<br/>[http.py]"]
  node_context["Job context<br/>[context.py]"]
  node_dlq["Dead-letter handling<br/>[dlq.py]"]
end

subgraph group_schedule["Scheduling"]
  node_schedules["Scheduled jobs<br/>[schedules.py]"]
  node_cron["Cron scheduler<br/>[cron.py]"]
  node_reaper["Lease reaper<br/>[reaper.py]"]
  node_retention["Job retention<br/>[retention.py]"]
end

subgraph group_ops["Limits and observability"]
  node_limits["Rate limits<br/>[limiter.py]"]
  node_backpressure["Queue backpressure<br/>[backpressure.py]"]
  node_metrics["Prometheus metrics<br/>[metrics.py]"]
end

subgraph group_broker["Mini broker"]
  node_miniclient["Mini broker client<br/>[client.py]"]
  node_miniserver["Mini broker server<br/>[server.py]"]
  node_ministore[("Mini broker store<br/>[store.py]")]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]
node_redis[("Redis")]

node_client -->|"sends requests"| node_api
node_api -->|"routes requests"| node_jobroutes
node_api -->|"routes requests"| node_admin
node_api -->|"routes requests"| node_scheduleapi
node_api -->|"installs console"| node_web
node_jobroutes -->|"enqueues jobs"| node_postgresapi
node_postgresapi -->|"stores job rows"| node_postgres
node_worker -->|"claims and updates"| node_postgresapi
node_worker -->|"dispatches tasks"| node_taskregistry
node_worker -->|"sets job context"| node_context
node_taskregistry -->|"registers handler"| node_httptask
node_postgresapi -->|"supports replay"| node_dlq
node_scheduleapi -->|"manages schedules"| node_schedules
node_cron -->|"enqueues due jobs"| node_postgresapi
node_reaper -->|"reclaims expired leases"| node_postgresapi
node_retention -->|"deletes expired jobs"| node_postgresapi
node_admin -->|"manages tenants and keys"| node_authstore
node_auth -->|"checks API keys"| node_authstore
node_api -->|"configures limiter"| node_limits
node_api -->|"configures backpressure"| node_backpressure
node_limits -->|"uses token buckets"| node_redis
node_backpressure -->|"uses cached depth"| node_redis
node_api -->|"serves metrics"| node_metrics
node_miniclient -->|"sends broker commands"| node_miniserver
node_miniserver -->|"updates message state"| node_ministore
node_miniclient -.->|"adapts broker interface"| node_worker

click node_api "https://github.com/srinu-design/hopper/blob/main/src/hopper/api/main.py"
click node_jobroutes "https://github.com/srinu-design/hopper/blob/main/src/hopper/api/jobs.py"
click node_admin "https://github.com/srinu-design/hopper/blob/main/src/hopper/api/admin.py"
click node_auth "https://github.com/srinu-design/hopper/blob/main/src/hopper/auth/api_keys.py"
click node_authstore "https://github.com/srinu-design/hopper/blob/main/src/hopper/auth/store.py"
click node_postgresapi "https://github.com/srinu-design/hopper/blob/main/src/hopper/queue/postgres.py"
click node_worker "https://github.com/srinu-design/hopper/blob/main/src/hopper/worker/loop.py"
click node_taskregistry "https://github.com/srinu-design/hopper/blob/main/src/hopper/tasks/registry.py"
click node_httptask "https://github.com/srinu-design/hopper/blob/main/src/hopper/tasks/http.py"
click node_context "https://github.com/srinu-design/hopper/blob/main/src/hopper/tasks/context.py"
click node_dlq "https://github.com/srinu-design/hopper/blob/main/src/hopper/queue/dlq.py"
click node_scheduleapi "https://github.com/srinu-design/hopper/blob/main/src/hopper/api/schedules.py"
click node_schedules "https://github.com/srinu-design/hopper/blob/main/src/hopper/queue/schedules.py"
click node_cron "https://github.com/srinu-design/hopper/blob/main/src/hopper/scheduler/cron.py"
click node_reaper "https://github.com/srinu-design/hopper/blob/main/src/hopper/scheduler/reaper.py"
click node_retention "https://github.com/srinu-design/hopper/blob/main/src/hopper/scheduler/retention.py"
click node_limits "https://github.com/srinu-design/hopper/blob/main/src/hopper/ratelimit/limiter.py"
click node_backpressure "https://github.com/srinu-design/hopper/blob/main/src/hopper/ratelimit/backpressure.py"
click node_metrics "https://github.com/srinu-design/hopper/blob/main/src/hopper/metrics.py"
click node_web "https://github.com/srinu-design/hopper/blob/main/src/hopper/web/static/app.js"
click node_miniclient "https://github.com/srinu-design/hopper/blob/main/src/hopper/minibroker/client.py"
click node_miniserver "https://github.com/srinu-design/hopper/blob/main/src/hopper/minibroker/server.py"
click node_ministore "https://github.com/srinu-design/hopper/blob/main/src/hopper/minibroker/store.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_api,node_jobroutes,node_admin,node_auth,node_authstore,node_scheduleapi,node_web,node_client toneBlue
class node_postgresapi,node_worker,node_taskregistry,node_httptask,node_context,node_dlq,node_postgres,node_redis toneAmber
class node_schedules,node_cron,node_reaper,node_retention toneMint
class node_limits,node_backpressure,node_metrics toneRose
class node_miniclient,node_miniserver,node_ministore toneIndigo
```

## Components

### HTTP API

- [HTTP application](https://github.com/srinu-design/hopper/blob/main/src/hopper/api/main.py): `src/hopper/api/main.py`
- [Job endpoints](https://github.com/srinu-design/hopper/blob/main/src/hopper/api/jobs.py): `src/hopper/api/jobs.py`
- [Admin endpoints](https://github.com/srinu-design/hopper/blob/main/src/hopper/api/admin.py): `src/hopper/api/admin.py`
- [Tenant authentication](https://github.com/srinu-design/hopper/blob/main/src/hopper/auth/api_keys.py): `src/hopper/auth/api_keys.py`
- [Tenant and key store](https://github.com/srinu-design/hopper/blob/main/src/hopper/auth/store.py): `src/hopper/auth/store.py`
- [Schedule endpoints](https://github.com/srinu-design/hopper/blob/main/src/hopper/api/schedules.py): `src/hopper/api/schedules.py`
- [Web console](https://github.com/srinu-design/hopper/blob/main/src/hopper/web/static/app.js): `src/hopper/web/static/app.js`

### Queue and workers

- [PostgreSQL queue](https://github.com/srinu-design/hopper/blob/main/src/hopper/queue/postgres.py): `src/hopper/queue/postgres.py`
- [Worker loop](https://github.com/srinu-design/hopper/blob/main/src/hopper/worker/loop.py): `src/hopper/worker/loop.py`
- [Task registry](https://github.com/srinu-design/hopper/blob/main/src/hopper/tasks/registry.py): `src/hopper/tasks/registry.py`
- [HTTP task](https://github.com/srinu-design/hopper/blob/main/src/hopper/tasks/http.py): `src/hopper/tasks/http.py`
- [Job context](https://github.com/srinu-design/hopper/blob/main/src/hopper/tasks/context.py): `src/hopper/tasks/context.py`
- [Dead-letter handling](https://github.com/srinu-design/hopper/blob/main/src/hopper/queue/dlq.py): `src/hopper/queue/dlq.py`

### Scheduling

- [Scheduled jobs](https://github.com/srinu-design/hopper/blob/main/src/hopper/queue/schedules.py): `src/hopper/queue/schedules.py`
- [Cron scheduler](https://github.com/srinu-design/hopper/blob/main/src/hopper/scheduler/cron.py): `src/hopper/scheduler/cron.py`
- [Lease reaper](https://github.com/srinu-design/hopper/blob/main/src/hopper/scheduler/reaper.py): `src/hopper/scheduler/reaper.py`
- [Job retention](https://github.com/srinu-design/hopper/blob/main/src/hopper/scheduler/retention.py): `src/hopper/scheduler/retention.py`

### Limits and observability

- [Rate limits](https://github.com/srinu-design/hopper/blob/main/src/hopper/ratelimit/limiter.py): `src/hopper/ratelimit/limiter.py`
- [Queue backpressure](https://github.com/srinu-design/hopper/blob/main/src/hopper/ratelimit/backpressure.py): `src/hopper/ratelimit/backpressure.py`
- [Prometheus metrics](https://github.com/srinu-design/hopper/blob/main/src/hopper/metrics.py): `src/hopper/metrics.py`

### Mini broker

- [Mini broker client](https://github.com/srinu-design/hopper/blob/main/src/hopper/minibroker/client.py): `src/hopper/minibroker/client.py`
- [Mini broker server](https://github.com/srinu-design/hopper/blob/main/src/hopper/minibroker/server.py): `src/hopper/minibroker/server.py`
- [Mini broker store](https://github.com/srinu-design/hopper/blob/main/src/hopper/minibroker/store.py): `src/hopper/minibroker/store.py`

### Other components

- **API client**
- **PostgreSQL**
- **Redis**

## Connections

- API client → HTTP application: sends requests
- HTTP application → Job endpoints: routes requests (evidence: `src/hopper/api/main.py`)
- HTTP application → Admin endpoints: routes requests (evidence: `src/hopper/api/main.py`)
- HTTP application → Schedule endpoints: routes requests (evidence: `src/hopper/api/main.py`)
- HTTP application → Web console: installs console (evidence: `src/hopper/api/main.py`)
- Job endpoints → PostgreSQL queue: enqueues jobs (evidence: `src/hopper/api/jobs.py`)
- PostgreSQL queue → PostgreSQL: stores job rows
- Worker loop → PostgreSQL queue: claims and updates
- Worker loop → Task registry: dispatches tasks (evidence: `src/hopper/worker/loop.py`)
- Worker loop → Job context: sets job context (evidence: `src/hopper/worker/loop.py`)
- Task registry → HTTP task: registers handler (evidence: `src/hopper/tasks/http.py`)
- PostgreSQL queue → Dead-letter handling: supports replay
- Schedule endpoints → Scheduled jobs: manages schedules
- Cron scheduler → PostgreSQL queue: enqueues due jobs
- Lease reaper → PostgreSQL queue: reclaims expired leases
- Job retention → PostgreSQL queue: deletes expired jobs
- Admin endpoints → Tenant and key store: manages tenants and keys (evidence: `src/hopper/api/admin.py`)
- Tenant authentication → Tenant and key store: checks API keys (evidence: `src/hopper/auth/api_keys.py`)
- HTTP application → Rate limits: configures limiter (evidence: `src/hopper/api/main.py`)
- HTTP application → Queue backpressure: configures backpressure (evidence: `src/hopper/api/main.py`)
- Rate limits → Redis: uses token buckets (evidence: `src/hopper/ratelimit/limiter.py`)
- Queue backpressure → Redis: uses cached depth
- HTTP application → Prometheus metrics: serves metrics (evidence: `src/hopper/api/main.py`)
- Mini broker client → Mini broker server: sends broker commands (evidence: `src/hopper/minibroker/client.py`)
- Mini broker server → Mini broker store: updates message state (evidence: `src/hopper/minibroker/server.py`)
- Mini broker client → Worker loop: adapts broker interface (evidence: `src/hopper/minibroker/client.py`)
