# git-agni/prod-farm-ios-core architecture

> Architecture diagram of the GitHub repository git-agni/prod-farm-ios-core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/git-agni/prod-farm-ios-core
- Repository: https://github.com/git-agni/prod-farm-ios-core
- Video tour (about a minute): https://gitdiagram.com/git-agni/prod-farm-ios-core/video

## Overview

Phone Farm iOS is a dashboard/API and worker application for registering physical iPhones and running versioned, scheduled TikTok workflows. Operators register devices and create schedules; the scheduler persists and queues due executions, workers run plugin tasks against devices, and the dashboard exposes execution history and controls. The README also documents live video/input, uploads, recurring jobs, and pluggable authentication and task plugins. Source excerpts confirm the server, worker, queue, and device-supervision links; some dashboard and automation details are documented capabilities whose internal wiring was not sampled.

Main entry points: [`src/api/app.ts`](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/api/app.ts) (HTTP API), [`src/api/server.ts`](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/api/server.ts) (Server runtime), [`src/devices/connection-manager.ts`](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/connection-manager.ts) (Connection manager), [`src/scheduler/repository.ts`](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/repository.ts) (Schedule repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Dashboard and API"]
  node_dashboard["Dashboard<br/>[tasks.ts]"]
  node_api["HTTP API<br/>[app.ts]"]
  node_server["Server runtime<br/>[server.ts]"]
end

subgraph group_devices["Device management"]
  node_registration["Device registration<br/>[registration.ts]"]
  node_device_registry[("Device registry<br/>[registry.ts]")]
  node_supervisor["WDA supervisor<br/>[wda-service.ts]"]
  node_connection_manager["Connection manager"]
  node_wda_service_api["WDA service API"]
  node_wda_client["WDA service client"]
end

subgraph group_scheduling["Scheduling and execution"]
  node_scheduler_runtime["Scheduler runtime<br/>[runtime.ts]"]
  node_repository["Schedule repository<br/>[repository.ts]"]
  node_queue["Per-device job queue<br/>[queue.ts]"]
  node_worker["Worker<br/>[worker.ts]"]
  node_executor["Automation executor<br/>[executor.ts]"]
end

subgraph group_automation["Plugins and persistence"]
  node_postgres[("PostgreSQL<br/>[schema.ts]")]
  node_plugin_registry["Plugin registry<br/>[registry.ts]"]
  node_tiktok_plugin["TikTok plugin<br/>[tiktok-plugin.ts]"]
  node_tiktok_actions["TikTok actions<br/>[actions.ts]"]
end

node_operator(("Operator"))
node_phones(("Physical iPhones"))
node_wda["WebDriverAgent"]
node_appium["Appium"]
node_auth_plugin["Auth provider"]
node_tiktok["TikTok"]

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"requests"| node_api
node_server -->|"creates"| node_api
node_server -->|"starts"| node_scheduler_runtime
node_server -->|"starts"| node_registration
node_server -->|"loads plugins"| node_plugin_registry
node_server -.->|"loads optionally"| node_auth_plugin
node_api -->|"manages registration"| node_registration
node_api -->|"reads and updates"| node_device_registry
node_api -->|"requests status"| node_wda_client
node_api -->|"manages schedules"| node_repository
node_api -->|"uses plugin routes"| node_plugin_registry
node_api -->|"streams and controls"| node_phones
node_registration -->|"stores devices"| node_device_registry
node_supervisor -->|"starts and stops"| node_connection_manager
node_supervisor -->|"serves"| node_wda_service_api
node_connection_manager -->|"loads devices"| node_device_registry
node_connection_manager -->|"discovers devices"| node_phones
node_connection_manager -->|"probes status"| node_wda
node_connection_manager -->|"checks readiness"| node_appium
node_wda_client -->|"requests status"| node_wda_service_api
node_scheduler_runtime -->|"creates"| node_repository
node_repository -->|"persists schedules and executions"| node_postgres
node_repository -->|"enqueues due work"| node_queue
node_worker -->|"records attempts"| node_repository
node_worker -->|"consumes jobs"| node_queue
node_worker -->|"runs automation"| node_executor
node_worker -->|"resolves tasks"| node_plugin_registry
node_executor -->|"executes on device"| node_phones
node_plugin_registry -->|"registers"| node_tiktok_plugin
node_tiktok_plugin -->|"provides actions"| node_tiktok_actions
node_tiktok_actions -->|"automates"| node_tiktok

click node_dashboard "https://github.com/git-agni/prod-farm-ios-core/blob/main/static/dashboard/ts/tasks.ts"
click node_api "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/api/app.ts"
click node_server "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/api/server.ts"
click node_registration "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/registration.ts"
click node_device_registry "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/registry.ts"
click node_supervisor "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/wda-service.ts"
click node_connection_manager "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/connection-manager.ts"
click node_wda_service_api "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/wda-service-http.ts"
click node_wda_client "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/wda-service-client.ts"
click node_scheduler_runtime "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/runtime.ts"
click node_repository "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/repository.ts"
click node_queue "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/queue.ts"
click node_worker "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/worker.ts"
click node_executor "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/executor.ts"
click node_postgres "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/database/schema.ts"
click node_plugin_registry "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/registry.ts"
click node_tiktok_plugin "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/tiktok-plugin.ts"
click node_tiktok_actions "https://github.com/git-agni/prod-farm-ios-core/blob/main/src/tiktok/actions.ts"

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_server toneBlue
class node_registration,node_device_registry,node_supervisor,node_connection_manager,node_wda_service_api,node_wda_client toneAmber
class node_scheduler_runtime,node_repository,node_queue,node_worker,node_executor toneMint
class node_postgres,node_plugin_registry,node_tiktok_plugin,node_tiktok_actions toneRose
class node_operator,node_phones,node_wda,node_appium,node_auth_plugin,node_tiktok toneIndigo
```

## Components

### Dashboard and API

- [Dashboard](https://github.com/git-agni/prod-farm-ios-core/blob/main/static/dashboard/ts/tasks.ts): `static/dashboard/ts/tasks.ts`
- [HTTP API](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/api/app.ts): `src/api/app.ts`
- [Server runtime](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/api/server.ts): `src/api/server.ts`

### Device management

- [Device registration](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/registration.ts): `src/devices/registration.ts`
- [Device registry](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/registry.ts): `src/devices/registry.ts`
- [WDA supervisor](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/wda-service.ts): `src/devices/wda-service.ts`
- [Connection manager](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/connection-manager.ts): `src/devices/connection-manager.ts`
- [WDA service API](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/wda-service-http.ts): `src/devices/wda-service-http.ts`
- [WDA service client](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/devices/wda-service-client.ts): `src/devices/wda-service-client.ts`

### Scheduling and execution

- [Scheduler runtime](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/runtime.ts): `src/scheduler/runtime.ts`
- [Schedule repository](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/repository.ts): `src/scheduler/repository.ts`
- [Per-device job queue](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/queue.ts): `src/scheduler/queue.ts`
- [Worker](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/worker.ts): `src/scheduler/worker.ts`
- [Automation executor](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/scheduler/executor.ts): `src/scheduler/executor.ts`

### Plugins and persistence

- [PostgreSQL](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/database/schema.ts): `src/database/schema.ts`
- [Plugin registry](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/registry.ts): `src/registry.ts`
- [TikTok plugin](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/tiktok-plugin.ts): `src/tiktok-plugin.ts`
- [TikTok actions](https://github.com/git-agni/prod-farm-ios-core/blob/main/src/tiktok/actions.ts): `src/tiktok/actions.ts`

### Other components

- **Operator**
- **Physical iPhones**
- **WebDriverAgent**
- **Appium**
- **Auth provider**
- **TikTok**

## Connections

- Operator → Dashboard: uses
- Dashboard → HTTP API: requests
- Server runtime → HTTP API: creates
- Server runtime → Scheduler runtime: starts
- Server runtime → Device registration: starts
- Server runtime → Plugin registry: loads plugins
- Server runtime → Auth provider: loads optionally
- HTTP API → Device registration: manages registration
- HTTP API → Device registry: reads and updates
- HTTP API → WDA service client: requests status
- HTTP API → Schedule repository: manages schedules
- HTTP API → Plugin registry: uses plugin routes
- HTTP API → Physical iPhones: streams and controls
- Device registration → Device registry: stores devices
- WDA supervisor → Connection manager: starts and stops
- WDA supervisor → WDA service API: serves
- Connection manager → Device registry: loads devices
- Connection manager → Physical iPhones: discovers devices
- Connection manager → WebDriverAgent: probes status
- Connection manager → Appium: checks readiness
- WDA service client → WDA service API: requests status
- Scheduler runtime → Schedule repository: creates
- Schedule repository → PostgreSQL: persists schedules and executions
- Schedule repository → Per-device job queue: enqueues due work
- Worker → Schedule repository: records attempts
- Worker → Per-device job queue: consumes jobs
- Worker → Automation executor: runs automation
- Worker → Plugin registry: resolves tasks
- Automation executor → Physical iPhones: executes on device
- Plugin registry → TikTok plugin: registers
- TikTok plugin → TikTok actions: provides actions
- TikTok actions → TikTok: automates
