# contribsys/faktory architecture

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

- Interactive diagram: https://gitdiagram.com/contribsys/faktory
- Repository: https://github.com/contribsys/faktory

## Overview

##### Project type and purpose
- This is a full‐stack work queue server (“Faktory”) written in Go.
- Purpose: receive JSON jobs via clients/CLI, enqueue them, dispatch to workers, persist state in Redis, and provide a Web UI for monitoring.

##### File structure
- Top-level entry points:
- cmd/faktory → the daemon/server
- cmd/faktory-cli → the CLI
- Core components:
- client/ → Go client library to push/fetch jobs
- server/ → the server API, connection handling, job lifecycle
- storage/ → Redis‐backed queue/history operations
- manager/ → scheduling, retry, middleware, fetch logic
- webui/ → HTML templates, static assets, HTTP handlers
- util/ → cross-platform utilities (process, file, JSON, logging)
- internal/pool → internal client/connection pooling
- Packaging, Docker, Makefile, CI workflows show how it’s built, tested, and deployed.

##### README for additional insights
- Describes the high-level flow: clients submit jobs → server enqueues → workers fetch → retries on failure → Web UI for management.
- Mentions external dependencies: Redis for storage, any language may use the API.

##### Elements
- Labels: “Client Library”, “CLI”, “Faktory Server API”, “Manager”, “Storage (Redis)”, “Web UI”
- Push jobs → Server → Storage
- Fetch jobs ← Server ← Storage
- Web UI ↔ Server
- Green for core server modules
- Yellow for external dependencies (Redis)
- Gray for Web UI

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Clients / CLI / Workers"
    direction TB
    CL("CLI"):::ext
    CL2("Client Library"):::ext
    WK("Worker"):::ext
    CL -->|"CLI commands"| API["Faktory Server API"]:::core
    CL2 -->|"PUSH/POP Jobs"| API
    WK -->|"FETCH Jobs"| API
  end

  subgraph "Faktory Server"
    direction TB
    API -->|"dispatch"| MAN["Manager Layer"]:::core
    MAN -->|"enqueue/dequeue"| STR["Storage Layer"]:::core
  end

  subgraph "Redis"
    direction TB
    STR -->|"LPUSH/RPOP"| Q("Queue Lists"):::data
    STR -->|"SADD/ZRANGE"| H("Sorted Sets/History"):::data
  end

  subgraph "Web UI"
    direction TB
    BROWSER("Browser"):::ui
    BROWSER -->|"HTTP"| API
  end

  classDef ext fill:#d0e1ff,stroke:#0050a0;
  classDef core fill:#d0ffd8,stroke:#008000;
  classDef data fill:#fffacc,stroke:#a08000;
  classDef ui fill:#dddddd,stroke:#888888;

  class CL,CL2,WK ext;
  class API,MAN,STR core;
  class Q,H data;
  class BROWSER ui;

  click CL "https://github.com/contribsys/faktory/blob/main/cmd/faktory-cli/main.go"
  click CL2 "https://github.com/contribsys/faktory/blob/main/client/client.go"
  click API "https://github.com/contribsys/faktory/blob/main/server/server.go"
  click MAN "https://github.com/contribsys/faktory/blob/main/manager/manager.go"
  click STR "https://github.com/contribsys/faktory/blob/main/storage/redis.go"
  click BROWSER "https://github.com/contribsys/faktory/blob/main/webui/web.go"
```
