# dragnozender/zensys---djsp architecture

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

- Interactive diagram: https://gitdiagram.com/dragnozender/zensys---djsp
- Repository: https://github.com/dragnozender/zensys---djsp

## Overview

ZenSys is a distributed scheduler for one-time, cron, and interval jobs. Users manage schedules and inspect run history through the dashboard or REST API. The main flow separates command ingestion and persistence from due-job scheduling, Kafka dispatch, worker execution, lifecycle-state persistence, and read queries. Retry delivery and executor-failure recovery form separate reliability paths. The graph follows the README and sampled code; unsampled service wiring is included only where the README documents it.

Main entry points: [`Backend/executor-service/src/main/java/com/zensys/executor_service/service/JobExecutionService.java`](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/executor-service/src/main/java/com/zensys/executor_service/service/JobExecutionService.java) (Task Executor), [`Backend/api-gateway/src/main/java/com/zensys/api_gateway/ApiGatewayApplication.java`](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/api-gateway/src/main/java/com/zensys/api_gateway/ApiGatewayApplication.java) (API Gateway), [`Backend/watcher-service/src/main/java/com/zensys/watcher_service/service/ExecutorLivenessWatcher.java`](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/watcher-service/src/main/java/com/zensys/watcher_service/service/ExecutorLivenessWatcher.java) (Executor Recovery), [`Backend/retry-service/src/main/java/com/zensys/retry_service/service/RetrySweeperService.java`](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/retry-service/src/main/java/com/zensys/retry_service/service/RetrySweeperService.java) (Retry Sweeper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["User Access"]
  node_dashboard["Operations Dashboard<br/>[App.tsx]"]
  node_api["API Gateway"]
  node_registry["Service Registry"]
end

subgraph group_commands["Job Commands"]
  node_jobwrite["Job Commands<br/>[JobService.java]"]
  node_jobread["Job Search"]
  node_consumer["Command And Event Consumer<br/>[JobConsumer.java]"]
end

subgraph group_runtime["Scheduling And Execution"]
  node_watcher["Schedule Watcher"]
  node_dispatcher["Run Dispatcher"]
  node_executor["Task Executor"]
  node_taskrunner["Task Runner<br/>[TaskRunner.java]"]
end

subgraph group_reliability["Reliability"]
  node_retry["Retry Sweeper"]
  node_liveness["Executor Recovery"]
end

subgraph group_state["State And Messaging"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis")]
  node_kafka["Kafka"]
end

node_user(("Operator"))

node_user -->|"manages jobs"| node_dashboard
node_dashboard -->|"calls REST"| node_api
node_api -->|"routes writes"| node_jobwrite
node_api -->|"routes queries"| node_jobread
node_jobwrite -->|"publishes commands"| node_kafka
node_kafka -->|"delivers commands"| node_consumer
node_consumer -->|"persists state"| node_postgres
node_jobread -->|"queries jobs and runs"| node_postgres
node_watcher -->|"claims due jobs"| node_postgres
node_watcher -->|"publishes run events"| node_kafka
node_kafka -->|"delivers run events"| node_dispatcher
node_dispatcher -->|"dispatches execution"| node_executor
node_executor -->|"runs task"| node_taskrunner
node_executor -->|"publishes lifecycle and retry events"| node_kafka
node_kafka -->|"delivers lifecycle events"| node_consumer
node_kafka -->|"delivers retry events"| node_retry
node_retry -->|"leases delayed retries"| node_redis
node_retry -->|"redispatches due runs"| node_kafka
node_executor -->|"writes heartbeats"| node_redis
node_liveness -->|"checks liveness"| node_redis
node_liveness -->|"recovers orphan runs"| node_postgres
node_liveness -->|"publishes recovery events"| node_kafka
node_registry -.->|"service discovery"| node_api

click node_dashboard "https://github.com/dragnozender/zensys---djsp/blob/main/Frontend/src/App.tsx"
click node_api "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/api-gateway/src/main/java/com/zensys/api_gateway/ApiGatewayApplication.java"
click node_registry "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/service-registry/src/main/java/com/zensys/service_registry/ServiceRegistryApplication.java"
click node_jobwrite "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/job-service/src/main/java/com/zensys/job_service/service/JobService.java"
click node_jobread "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/job-search-service/src/main/java/com/zensys/job_search_service/controller/JobSearchController.java"
click node_consumer "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/consumer-service/src/main/java/com/zensys/consumer_service/kafka/JobConsumer.java"
click node_watcher "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/watcher-service/src/main/java/com/zensys/watcher_service/service/JobWatcherService.java"
click node_dispatcher "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/job-consumer-service/src/main/java/com/zensys/job_consumer_service/kafka/JobRunConsumer.java"
click node_executor "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/executor-service/src/main/java/com/zensys/executor_service/service/JobExecutionService.java"
click node_taskrunner "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/executor-service/src/main/java/com/zensys/executor_service/runner/TaskRunner.java"
click node_retry "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/retry-service/src/main/java/com/zensys/retry_service/service/RetrySweeperService.java"
click node_liveness "https://github.com/dragnozender/zensys---djsp/blob/main/Backend/watcher-service/src/main/java/com/zensys/watcher_service/service/ExecutorLivenessWatcher.java"

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_dashboard,node_api,node_registry toneBlue
class node_jobwrite,node_jobread,node_consumer toneAmber
class node_watcher,node_dispatcher,node_executor,node_taskrunner toneMint
class node_retry,node_liveness toneRose
class node_postgres,node_redis,node_kafka,node_user toneIndigo
```

## Components

### User Access

- [Operations Dashboard](https://github.com/dragnozender/zensys---djsp/blob/main/Frontend/src/App.tsx): `Frontend/src/App.tsx`
- [API Gateway](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/api-gateway/src/main/java/com/zensys/api_gateway/ApiGatewayApplication.java): `Backend/api-gateway/src/main/java/com/zensys/api_gateway/ApiGatewayApplication.java`
- [Service Registry](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/service-registry/src/main/java/com/zensys/service_registry/ServiceRegistryApplication.java): `Backend/service-registry/src/main/java/com/zensys/service_registry/ServiceRegistryApplication.java`

### Job Commands

- [Job Commands](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/job-service/src/main/java/com/zensys/job_service/service/JobService.java): `Backend/job-service/src/main/java/com/zensys/job_service/service/JobService.java`
- [Job Search](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/job-search-service/src/main/java/com/zensys/job_search_service/controller/JobSearchController.java): `Backend/job-search-service/src/main/java/com/zensys/job_search_service/controller/JobSearchController.java`
- [Command And Event Consumer](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/consumer-service/src/main/java/com/zensys/consumer_service/kafka/JobConsumer.java): `Backend/consumer-service/src/main/java/com/zensys/consumer_service/kafka/JobConsumer.java`

### Scheduling And Execution

- [Schedule Watcher](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/watcher-service/src/main/java/com/zensys/watcher_service/service/JobWatcherService.java): `Backend/watcher-service/src/main/java/com/zensys/watcher_service/service/JobWatcherService.java`
- [Run Dispatcher](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/job-consumer-service/src/main/java/com/zensys/job_consumer_service/kafka/JobRunConsumer.java): `Backend/job-consumer-service/src/main/java/com/zensys/job_consumer_service/kafka/JobRunConsumer.java`
- [Task Executor](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/executor-service/src/main/java/com/zensys/executor_service/service/JobExecutionService.java): `Backend/executor-service/src/main/java/com/zensys/executor_service/service/JobExecutionService.java`
- [Task Runner](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/executor-service/src/main/java/com/zensys/executor_service/runner/TaskRunner.java): `Backend/executor-service/src/main/java/com/zensys/executor_service/runner/TaskRunner.java`

### Reliability

- [Retry Sweeper](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/retry-service/src/main/java/com/zensys/retry_service/service/RetrySweeperService.java): `Backend/retry-service/src/main/java/com/zensys/retry_service/service/RetrySweeperService.java`
- [Executor Recovery](https://github.com/dragnozender/zensys---djsp/blob/main/Backend/watcher-service/src/main/java/com/zensys/watcher_service/service/ExecutorLivenessWatcher.java): `Backend/watcher-service/src/main/java/com/zensys/watcher_service/service/ExecutorLivenessWatcher.java`

### State And Messaging

- **PostgreSQL**
- **Redis**
- **Kafka**

### Other components

- **Operator**

## Connections

- Operator → Operations Dashboard: manages jobs
- Operations Dashboard → API Gateway: calls REST
- API Gateway → Job Commands: routes writes
- API Gateway → Job Search: routes queries
- Job Commands → Kafka: publishes commands
- Kafka → Command And Event Consumer: delivers commands
- Command And Event Consumer → PostgreSQL: persists state
- Job Search → PostgreSQL: queries jobs and runs
- Schedule Watcher → PostgreSQL: claims due jobs
- Schedule Watcher → Kafka: publishes run events
- Kafka → Run Dispatcher: delivers run events
- Run Dispatcher → Task Executor: dispatches execution
- Task Executor → Task Runner: runs task
- Task Executor → Kafka: publishes lifecycle and retry events
- Kafka → Command And Event Consumer: delivers lifecycle events
- Kafka → Retry Sweeper: delivers retry events
- Retry Sweeper → Redis: leases delayed retries
- Retry Sweeper → Kafka: redispatches due runs
- Task Executor → Redis: writes heartbeats
- Executor Recovery → Redis: checks liveness
- Executor Recovery → PostgreSQL: recovers orphan runs
- Executor Recovery → Kafka: publishes recovery events
- Service Registry → API Gateway: service discovery
