Product · Architecture · AWS MVP

Benchframe Flux on AWS: the MVP architecture

One small instance, durable data, optional Macs for iOS.

People use Benchframe Flux through a web app and an iOS app. This page describes how the platform is meant to run on AWS in its first production shape, in four views of the C4 model: system context, containers, the iOS track, and the components of the broker.

Status

Target architecture (MVP), not as-built. This is the intended design. The rollout to AWS has not happened yet, and details can change before it does.

Benchframe Flux in action

What the platform produces

Before the architecture, a look at the product it carries. A user describes an app in one sentence, a person approves the plan at a gate, and the finished web app appears in My apps, ready to open. Behind each step, the operator sees the same run as a workflow canvas. The screens show the Polish interface.

  1. Benchframe Flux web app: the idea field with a one-sentence description of the app to build.
    1 · Idea One sentence in: describe the app you want in the idea field.
  2. Benchframe Flux web app: an approval card with three actions, Tak, dalej (yes, go ahead), Chcę coś zmienić (I want a change) and Zakończ bez wyniku (end without a result), with a short explanation of each below.
    2 · Approval A human approval gate with three choices: go ahead, which lets the run continue; ask for a change, which sends it back to the agent with your note; or end it with no result.
  3. Benchframe Flux web app on a phone: My apps with the newly generated Wspólne wydatki (Shared expenses) app, ready to open.
    3 · Delivery The finished app lands in My apps.
  4. Benchframe Flux web app: a generated web app running in the browser.
    4 · Result The running app, opened straight from My apps.

Apps Benchframe Flux generates

  • Phone screen of a generated web app called Shared expenses, showing who owes whom.
    Generated web app: Shared expenses, who owes whom.

Every app starts as one sentence. After a person approves the plan, Benchframe Flux builds the web app, publishes it and adds it to My apps. It opens in any phone browser, with no store review in between.

The operator view

Operator panel: the workflow canvas of a web-app run, with the steps of the run laid out as connected nodes.
Operator panel: the workflow canvas of a web-app run.

01 · System context (C1)

Who talks to the system

Users and operators reach Benchframe Flux over HTTPS. Behind it sit the services it depends on: GitHub for repositories and pull requests, Anthropic and OpenAI for the Claude and Codex CLI workers, Apple for sign-in, push and TestFlight, Microsoft Entra ID for sign-in, and a low-cost model API for request classification. Operators and Mac hosts use a private network.

C1 system context Users and operators use Benchframe Flux on AWS. The system talks to GitHub, Anthropic, OpenAI, Apple, Microsoft Entra ID and a low-cost model API. Optional Mac build hosts join over a private network. HTTPS: web app, iOS app HTTPS, private network git push, PR Claude CLI Codex CLI OIDC API identity, push private network worker link (WSS) build, TestFlight User person Asks for an app, contentor a code change Operator person Workflows, agents, cost,human-gate decisions Benchframe Flux on AWS software system Orchestrates AI agents:workflow canvases, runs,Claude and Codex workers,human gates, audit, FinOps GitHub external Repositories,pull requests, OAuth Anthropic external Claude CLI workers OpenAI external Codex CLI workers Microsoft Entra ID external Operator and usersign-in (OIDC) Low-cost model API external Request classification Apple external Sign in, push,App Store Connect,TestFlight Private network VPN For operators, Macsand build workers Mac build hosts optional, own systems Xcode, Simulator andsigning steps only
C1: the system and everything around it.
  • Person
  • System in scope
  • External system
  • Mac host
Scroll sideways to see the whole diagram.

The key change from the current setup: the Mac stops being part of the system. Two Macs become optional, equal build hosts for the steps that need Xcode. The rest of a run lives on AWS.

02 · Containers (C2)

What runs on the instance

Everything that is ours runs on one EC2 instance under Docker Compose, around a few managed AWS services. Worker containers are started by the broker from a managed pool.

C2 containers on AWS One EC2 instance runs nginx, orchestration-api, web-manager, am-web, PostgreSQL, worker containers and an idle timer with Docker Compose. Around it sit managed AWS services: an entry and wake-up function, SSM Parameter Store, S3 buckets and CloudWatch. Operators and Mac hosts reach the instance over a private network. AWS, EU region, one workload account One EC2 instance: Graviton arm64, persistent spot, Docker Compose Workers: arm64, started by the broker HTTPS User Operator Mac build hosts see the iOS track Private network VPN Entry and wake-up Lambda, API Gateway, DNS Shows a 'starting' page andstarts the instance when itsleeps, then redirects SSM Parameter Store SecureString Secrets, read at start S3: artifacts Build outputs and renders S3: backups Nightly database dumps CloudWatch Logs, disk and RAM alarms nginx container TLS on 443, web app SPA,REST and WebSocket proxy web-manager container, Next.js Operator console am-web container, static Operator panel orchestration-api container, Spring Boot REST and WebSocket endpoints, workflow engine,dispatch, auth, FinOps, schedules idle-timer host service Stops the instancewhen it is idle PostgreSQL 17 container Runs, steps, canvases worker-claude Claude CLI worker-codex Codex CLI worker-connector GitHub, verify, merge EBS data volume encrypted, gp3 Database, broker data, repo mirror;separate from the instance video-render container, on demand One render at a time;results go to S3
C2: containers on the instance and the managed services around it.
  • Person
  • Container or component
  • Data store
  • Managed AWS service
  • External system
Scroll sideways to see the whole diagram.

Design rules

  • One active broker. A single broker is active at any time. There are no two brokers writing to two databases during the migration.
  • Only port 443 is public. Everything else, including worker links, the operator console, the database and administrative access, is reachable only from inside the instance, over the private network, or through AWS Systems Manager.
  • Secrets stay out of files and images. Secrets live in SSM Parameter Store (SecureString) and are read at start by a script that never logs values. Mac hosts keep their own signing keys in the macOS Keychain, never in the cloud.
  • Boring building blocks. PostgreSQL 17 runs in Docker Compose on the instance and artifacts go straight to S3. The MVP deliberately has no ECS, EKS, load balancer, RDS, NAT gateway or multi-AZ.
  • EU region, own network. One workload account in an EU region, a dedicated VPC with a single public subnet and a fixed public address.

Workers as hybrid containers

  • Worker images are built from one Dockerfile in variants for Claude, Claude with slots, Codex and the connector, each with a linux/arm64 build.
  • The broker starts containers through its worker-fleet module, which allows only listed images, no privileged mode, all Linux capabilities dropped and no new privileges.
  • Each worker declares what it can do (platform, architecture, capabilities, capacity), and the broker routes steps by those declarations.
  • The first run uses one-shot containers for Claude and Codex steps and a fixed pool for the connector. Multi-slot workers are enabled only after protocol tests and a security review.
  • Worker containers cannot read instance metadata, so a worker never inherits the instance's cloud permissions.

03 · iOS track (C2, hybrid)

Macs only where Xcode is needed

Only steps that need Xcode, Simulator, XCTest or signing go to a Mac. Macs join the broker over the private network, as a remote worker does today.

C2 iOS track on Mac hosts Linux workers on EC2 plan, code, review and open pull requests. Only Xcode, Simulator and signing steps go to one of two optional Mac hosts, which connect to the broker over a private network and hand work back through an immutable commit SHA. EC2 (AWS) Mac host A (optional) Mac host B (optional) WSS WSS commit SHA Apple external App Store Connect, TestFlight Private network VPN nginx container Reachable over theprivate network only orchestration-api container Dispatch by capabilityand executor kind Linux arm64 workers containers Planning, coding, review, PR App repository mirror + GitHub iOS workers check out the samecommit SHA as the Linux workers iOS worker native launchd process Build, TestFlight, xcodebuild;signing key stays in Keychain iOS worker native launchd process Equal peer of host A;same build and signing role
C2 hybrid: Linux workers on AWS and optional Mac hosts for iOS steps.
  • Container or component
  • Data store
  • Mac host
  • External system
Scroll sideways to see the whole diagram.
  • Native, not containerized. The iOS worker is a native launchd process on the Mac, because Xcode, Simulator and signing do not exist on Linux. The App Store Connect key stays in that Mac's Keychain.
  • Optional and equal. Two Macs are interchangeable peers. Either can take an Xcode step when it is switched on and neither is required. With both off, a normal web, content or SDLC run still completes end to end.
  • Hand-off by commit SHA. Coding happens on Linux, then xcodebuild and XCTest run on a Mac at the same immutable commit SHA, then review and the pull request continue on Linux. No writable directory is shared over the network.
  • Visible waiting. If no compatible Mac is on, the iOS step waits in the queue with an explicit state instead of hanging unnoticed.

04 · Components (C3)

Inside the broker

The broker is one Spring Boot process organized as a modular monolith. It barely changes internally for AWS. Components that the MVP touches have a dashed amber outline.

C3 broker components The orchestration-api process is a modular monolith. Requests pass through authentication to REST and consumer controllers, then to the workflow engine, which uses platform services such as the dispatch bus, WebSocket hub, scheduler, agent manager and worker fleet. A storage layer reaches PostgreSQL, S3 and SSM Parameter Store. orchestration-api: one Spring Boot process (modular monolith) Platform services nginx auth-service Apple and Entra JWT, worker tokens, RBAC REST controllers Workflows, agents, FinOps, admin consumer-service Consumer API, human-gate inbox, hosted web apps workflow-engine Run state machine, canvas materialization, step dispatch, leases, reapers presence-service Fleet presence finops, audit Cost and audit trail dispatch-bus In-process queue plusa durable queue ws-hub Worker, host andconsumer sockets scheduler-service Run schedules; wakesthe instance beforea schedule fires idleness indicator New rule: no users,no processes, nolive runs worker-fleet Starts worker containers;Claude, Codex andconnector pools agent-manager Agent catalog, skills,memory; intake routeruses a low-cost API storage PostgreSQL ports, migrations, S3 client, Git mirror, secret store Workers and iOS hosts Model API low-cost PostgreSQL 17 S3 artifacts SSM Parameter Store
C3: components of the orchestration-api process.
  • Container or component
  • Changed for the MVP
  • Data store
  • External system
Scroll sideways to see the whole diagram.

What changes for the MVP

ComponentChange
storageS3 endpoint instead of MinIO using the instance role, and secrets read from SSM at start.
worker-fleetClaude, Codex and connector pools on EC2 in arm64, worker secrets from SSM, instance metadata blocked for worker containers.
Idleness health indicatorIdle means no users (no consumer sessions or requests for a set time), no processes (no steps in progress, no CLI processes) and no live runs. A worker connection alone does not count as activity, and a run waiting at a human gate does not block sleep.
scheduler-serviceSchedules cannot fire while the instance sleeps, so the wake-up function starts the machine before a due time.
agent-managerThe intake router moves from a local model to a low-cost model API (embeddings plus pre-routing).
consumer-serviceHosted user apps answer only once the instance is up. Moving static apps to S3 and CloudFront is out of scope for the MVP.

05 · Deployment

How it runs on EC2

The target release flow, from a merged commit to a running version. It reuses what the platform already does today and replaces only the parts tied to a Mac. Like the rest of this page, it describes the intended design, not a system that is live. If the instance is asleep when a release is published, it picks the release up when it wakes.

Deployment flow

  1. Build an arm64 image Container images are built for the instance's arm64 architecture from one tagged commit, on build machines outside the instance, so a release never spends the instance's CPU credits.
  2. Push to the registry Images go to a private container registry. Each tag is the full commit identifier and cannot be overwritten.
  3. Read secrets from Parameter Store On deploy, the instance reads its credentials from SSM Parameter Store with its own role. Nothing secret is baked into an image or kept in the repository.
  4. Back up and migrate the database Before a new broker version starts, a database backup is written to object storage. Schema migrations run as the new version boots.
  5. Blue-green switch with an intake pause The new broker starts beside the old one. New orders are paused only for the moment of the switch; traffic moves once the new broker reports ready, then intake resumes. Steps already running carry over.
  6. Smoke check The running version is compared with the released commit, and a few read-only requests confirm the platform answers through the public entry point.
  7. Roll back if needed An unhealthy new version is replaced by the previous one automatically. Any earlier commit can be redeployed in one step, and a destructive schema change is undone from the pre-deploy backup.

What carries over and what changes

Reused as-is

  • Blue-green broker switch with a short order-intake pause
  • Automatic return to the previous version when the new one is unhealthy
  • Database backup and restore tooling, with every backup verified before it is trusted
  • Worker container images, now built for both architectures
  • Hosted web apps, served by the broker from its git mirrors, so no per-app deployment exists

Reworked for AWS

  • Secrets move from the macOS Keychain to SSM Parameter Store
  • Process supervision moves from launchd to containers and systemd timers
  • Artifact storage moves from a local object store to S3
  • Release orchestration moves from a hand-run script on a Mac to a pipeline that builds, pushes and triggers the instance
  • The public entry moves from a private-network tunnel to HTTPS with a managed certificate and a wake-up page
  • Host health guards (disk, CPU, backups) become cloud monitoring alarms

06 · Cost, spot and sleep

How the instance stays cheap

  • Data is separate from the machine. PostgreSQL, broker data and the repository mirror sit on their own encrypted EBS volume with deletion protection. The instance can be stopped, or replaced after a spot reclaim, and the same volume and public address are reattached.
  • Fast start. A custom arm64 image ships with Docker, pulled container images and worker CLIs. The goal, still to be measured, is that the service responds within a few minutes of a start command.
  • Sleeping when idle. An idle timer on the instance polls an idleness health endpoint every few minutes and shuts the machine down after a set period of inactivity.
  • Wake-up on demand. A small, stateless function (Node.js) is the only serverless piece, and it only starts and stops the instance. While the machine sleeps, the public address shows a 'starting' page, starts the instance and redirects once it is up.
  • Spot with a safety net. A persistent spot request with stop-on-interruption, and an on-demand fallback of the same type when spot capacity is short. The two-minute interruption notice pauses intake and stops the broker gracefully. Interrupted steps are retried after the next start.
  • What costs money while it sleeps. EBS volumes and snapshots, the public IPv4 address, S3 storage, and the wake-up path (HTTPS entry, DNS, certificate).

07 · Risks

Known risks and how they are handled

RiskEffectMitigation
Spot instance reclaimed during a CLI stepThe step restarts and costs twiceTwo-minute notice, intake pause, step retry, run state on persistent EBS
CPU credits exhausted on a burstable instance type (builds, verify)Throttled performanceStandard credit mode with no surcharge, measurement, move to a larger family if needed
arm64 compatibility of CLIs, git tooling, Remotion, Chrome, ffmpegFeatures unavailable on GravitonAudit of images and tools before production
Hosted apps and schedules while the instance sleepsApps unavailable, schedules do not startWake before a due time; full 24/7 only in a mode without sleep
Changed idleness ruleMachine sleeps mid-work, or never sleepsTests on real states: human gate, step in progress, open user session
Cold start timeUsers wait after a sleepCustom image with pulled containers, a 'starting' page, measurement
One instance, one availability zoneNo availability if the zone failsAccepted for the MVP; managed services and multi-AZ are the next stage

Outside the MVP

  • Auxiliary services from the local stack (search, metrics dashboards). Each will either run on the instance or be replaced by CloudWatch.
  • Some integrations: issue-tracker sync, AWS Bedrock as a model lane, and App Store Connect automation outside the Mac hosts.
  • Moving to managed AWS services (RDS, ECS, ALB) once availability becomes a requirement.

08 · Talk to us

Questions about the deployment model?

Write to hello@benchframe.com and we will walk you through the design.