All projects

  • Employer work
  • Live

Mobile build platform

An orchestrator API that provisions, builds, signs and ships white-label iOS and Android apps.

Role
Infrastructure Engineer, Patron Points
Period
2025 – present
Context
Employer work
Status
Live
Tags
Platform, CI/CD, Python, Kubernetes, API
production white-label apps
300+
build jobs in a full fleet rebuild
~600
to process a full rebuild
24-48 hrs
app builds in its first six months
1,865

A Flask orchestrator API that runs the whole lifecycle of 300+ production white-label apps, each built as both an iOS and an Android artifact: Apple credentials, Android keystores, Firebase and GCP projects, Azure DevOps builds, MinIO artifact storage and Jira tickets. It replaced a half-finished Ansible project.

Problem

Patron Points ships more than 300 production white-label loyalty apps, each with an iOS and an Android build. Each one needs Apple certificates, provisioning profiles, an Android keystore, Firebase configs, branding images and a build pipeline. That used to depend on a half-finished Ansible project and a lot of manual steps, and Apple credentials broke often.

Approach: an API that acts as the manager

I rebuilt it as a Flask API using the application factory pattern. Each area (iOS, Android, Azure DevOps, storage, Firebase, Google Play, Jira) is its own module or blueprint, registered by the factory. That keeps modules isolated and testable, makes config per environment simple, and lets the API scale as one stateless gunicorn service on Kubernetes.

The code has three layers:

  • Controllers: single-purpose units such as create a JWT, check a certificate, build a P12 or generate a keystore. Clean parameters in, plain dicts out.
  • Module orchestrators: chain controllers inside one module, for example the iOS flow.
  • A master orchestrator: runs the full pipeline end to end and coordinates everything else.

The API does not just trigger builds. It manages them: it opens and updates the Jira ticket, provisions what is missing, hands the build agents everything they need, receives their callbacks, and closes or escalates the ticket at the end.

What one new-app request does

POST /build/new takes the app details and runs, in order, bailing early on failure:

  1. Opens a Jira ticket for the requester, or attaches to an existing one, and records a history row.
  2. Checks for duplicates in PostgreSQL and MinIO, and checks Azure DevOps connectivity.
  3. Writes the app config and links the Apple developer account (issuer).
  4. iOS: an orchestrator health-checks every credential across Apple, PostgreSQL and MinIO, and creates only what is missing: distribution certificate, P12, bundle ID, provisioning profile.
  5. Android: generates a signing keystore and stores it.
  6. Firebase: finds a Firebase project with spare capacity (moving to the next one at 28 apps), creates the Android and iOS apps, downloads google-services.json and GoogleService-Info.plist, and stores them.
  7. Generates short-lived pre-signed MinIO URLs for every credential and image, and triggers the Azure DevOps pipeline runs.
  8. Build agents (macOS Mac minis for iOS, Linux agent containers on Kubernetes for some Android builds) download everything, apply branding, build, sign, optionally ship to TestFlight or Google Play, and call POST /build/complete.
  9. When every platform reports in, the API posts a final Jira comment with build links and deploy results. It closes the ticket only if every platform and every requested deploy succeeded. Otherwise it escalates priority and leaves it open.

Failures degrade gracefully. If iOS credentials fail (for example an expired Apple agreement), iOS is skipped with a ticket note and Android still builds. If a Google Play account cannot be verified, the upload is skipped with a note naming the exact service account to invite, and the build still runs.

Google Cloud and Firebase provisioning

Google Play caps how many developer accounts one service account can join, so the API gives each Play developer account its own GCP service account. POST /build/google-play-accounts creates it in a shared capacity project, rolls to the next project when one fills up, stores the key in MinIO and posts the email to Jira for operations to invite. It is idempotent and serialized with a database lock. Play accounts are then auto-discovered per app by probing each key against the package name, and the match is saved.

Endpoints

  • Builds: /build/new, /build/rebuild, /build/rebuild/all, /build/complete (agent callback), /build/status/<id>.
  • Config: /build/apps, GET and PATCH /build/config, /build/storage/migrate.
  • Assets: upload, list, pre-sign and delete app images and credential files.
  • Health: /build/credentials/check across every app, /build/firebase/diagnose.
  • Google Play: provision and list developer accounts.
  • iOS: credential health check and repair, renew credentials, create certificate, P12 and provisioning profile, validate credentials, normalize PEM keys.

Every endpoint supports a dry run. With debugging: true it does all the read-only checks (Apple, PostgreSQL, MinIO, Azure DevOps, Firebase capacity), skips every write, and reports where it stopped and what would have run next. Every call also emits structured JSON log events, so failures are diagnosable from the logs without reproducing the request.

Storage: a MinIO deployment I manage

I run the MinIO deployment that holds the build inputs and outputs. One bucket holds credentials and artifacts, organised per app and per Apple issuer: provisioning profiles, keystores, Firebase configs, certificates, P12s, keys and Google Play service account keys. Another holds branding images. At build time the API maps every image to a 30-minute pre-signed URL, and the pipeline routes each file into the right place by name (icon, splash or general image). Play service account links get four hours, because they have to outlive the build.

Fleet scale

  • 300+ production apps, each producing two artifacts: an iOS build and an Android build.
  • A full fleet rebuild (/build/rebuild/all) triggers about 600 build jobs.
  • Those jobs queue through the build agent pools and are processed over roughly 24 to 48 hours. They do not all finish at once.

Outcome

  • A new client app goes from request to finished build in four to six minutes.
  • 1,865 individual app builds went through the API in its first six months. That count is separate from full fleet rebuilds.
  • Apple credential failures are caught by health checks before they break a build, instead of during one.