Mobile and web apps don't usually exist alone. They almost always talk to a server somewhere — for authentication, for data storage, for AI calls, for push notifications, for payments. That server is "the backend." Understanding what a backend is, why you need one, and how the major options differ is one of the biggest mental leaps a returning developer makes today.
What a backend actually is
A backend is a computer (or a fleet of them) running software that your app talks to over the internet. The "computer" might be a physical machine in a data center, a virtual machine on AWS, a container on Railway, or a serverless function on Cloudflare — the abstraction varies, but conceptually it's a remote computer running your code.
Your iOS app is the frontend — what the user sees and touches on their phone. Your backend is the server-side — the code and data that lives on a machine somewhere, accessible to your app via HTTPS calls.
The communication looks like this: your iOS app sends an HTTP request to a URL like https://api.yourapp.com/users/me; your backend receives that request, does some work (reads a database, calls another API, runs some logic), and sends an HTTP response back; your app displays the result.
Why your app needs one
For trivial apps (a calculator, a one-off utility, a static reference list), you don't need a backend. The app's data and logic all live on the phone.
For almost everything else, you need a backend. Five categories of reason:
- Shared data. Multiple users need to see or affect the same state. A chat app needs a backend so users' messages reach each other. A leaderboard needs a backend so scores from different players appear in the same list.
- Secret credentials. Your app calls Claude / OpenAI / Stripe. The API keys for those services CANNOT live on the user's phone — they'd be trivially extracted and abused. The keys live on your backend, which the user's phone calls; the backend then calls the third-party services with the secret key.
- Heavy computation. AI calls, video processing, financial calculations, large data joins — doing these on a phone drains battery, requires download of large models, and is slower. The backend does the heavy lifting and returns the result.
- Cross-device continuity. A user's data needs to follow them from iPhone to iPad to Mac. The data has to live somewhere that all three can reach.
- Server-side logic you control. Pricing rules, feature flags, content moderation, fraud detection, business logic that you don't want users to be able to reverse-engineer from the app binary.
What backends actually do (concretely)
For an AI-powered iOS app like RDR2 Companion, the backend's job list is something like:
- Receive user questions from the iOS app via HTTPS POST.
- Authenticate the user — check that this request comes from a paid subscriber, not a random hacker.
- Rate-limit — prevent any single user from spamming the AI and running up your bill.
- Call the Claude API with the user's question + your system prompt + your API key (the key the user never sees).
- Receive Claude's response, optionally post-process it (clean up formatting, redact, log).
- Return the response to the iOS app over HTTPS.
- Log the interaction for analytics, billing, and abuse monitoring.
For a different type of app, the list is different. A photo-sharing app's backend stores and serves images. A multiplayer game's backend keeps game state in sync. A subscription app's backend handles Apple's IAP receipt verification.
A common architecture, end to end
For an AI iOS app, the full stack typically looks like this:
- iOS app (frontend) — Swift / SwiftUI on the user's iPhone.
- HTTPS / TLS — the encrypted transport between phone and backend.
- Backend server — Node.js / Python / Go / etc. running on Railway / AWS / Vercel / wherever.
- Database — PostgreSQL, MongoDB, or a managed database service (Supabase, RDS, Firestore).
- External APIs — Claude, Stripe, Apple, Google. The backend is the one talking to them.
- Logging / monitoring — Datadog, Sentry, your platform's built-in logs.
- Object storage (if you have file uploads) — S3, R2, Cloud Storage.
- CDN (if you serve static assets) — Cloudflare, CloudFront.
Not every app needs all of these. Many small apps live with just iOS + backend + database + external APIs. The other pieces come in as the app grows.
The major backend options in 2026
The market sorts roughly into five tiers, ordered from easiest-to-start to most-control:
- Railway — PaaS (Platform as a Service). Push code, get a running server. Built-in databases, deploy from GitHub, predictable pricing. Loved by solo devs and small teams.
- Vercel — similar shape to Railway, but specialized for web apps (Next.js especially). Great for frontends and serverless functions.
- Render / Fly.io / Heroku — Railway-style PaaS alternatives.
- Firebase / Supabase / AWS Amplify — BaaS (Backend as a Service). Authentication, database, file storage, push notifications, all out of the box, accessed directly from your iOS app via an SDK. You write very little backend code.
- AWS / Azure / Google Cloud Platform — the hyperscalers. Maximum flexibility and feature breadth, steepest learning curve, most ways to overspend. Where serious production systems eventually live.
- Cloudflare Workers / Vercel Edge / AWS Lambda — serverless. Functions that run on demand and scale automatically. Cheap at low volume, can be limiting for complex apps.
- Self-hosted — rent a VPS (Hetzner, DigitalOcean), install your own software. Most control, most operational work, lowest unit cost.
PaaS vs IaaS vs BaaS vs Serverless — the four major shapes
IaaS (Infrastructure as a Service)
You rent raw virtual machines and do everything else yourself: install Linux, set up Nginx, configure databases, secure the network. AWS EC2, Azure VMs, Google Compute Engine. Most flexible, most work.
PaaS (Platform as a Service)
You push code; the platform handles the servers, scaling, deployment, basic monitoring. Railway, Heroku, Render, Fly.io, Google Cloud Run, AWS App Runner. Sweet spot for most solo developers and small teams.
BaaS (Backend as a Service)
The platform provides ready-made backend functionality (auth, database, storage, push) that your client app calls directly via an SDK. Firebase, Supabase, AWS Amplify. You write almost no server-side code. Fast to start; can be limiting and expensive at scale.
Serverless / FaaS (Functions as a Service)
You upload individual functions that run on demand. Cloudflare Workers, AWS Lambda, Vercel Edge Functions, Google Cloud Functions. Scales automatically, pay-per-request, cheap at low volume. Can have cold-start latency and request-duration limits.
These categories are not mutually exclusive — many production systems mix them. A common pattern: a PaaS-hosted backend that calls a few BaaS services (Firebase Auth, S3 for storage), with some heavy operations running as serverless functions.
How to choose
The honest decision framework:
Start with PaaS (Railway / Vercel) if:
- You're a solo developer or small team.
- You need a real backend server (not just BaaS-style SDK calls from the app).
- You want predictable pricing and minimal ops work.
- Your traffic is modest (single-digit thousands of users to start).
- You're using AI APIs and want a clean proxy pattern.
This is where you are with the RDR2 Companion, and it's the right choice for that stage.
Start with BaaS (Firebase / Supabase) if:
- You want to ship the smallest possible amount of backend code.
- Your needs map cleanly to what the BaaS offers (auth + DB + storage + push).
- You don't have third-party API calls that need to be proxied.
- You're OK with vendor lock-in for now and will revisit if you grow.
Move to AWS / Azure / GCP when:
- You've hit a real Limit of your PaaS (scaling, networking, regulatory, cost at scale).
- You need services your PaaS doesn't offer (sophisticated networking, ML pipelines, broad managed databases, etc.).
- You have the operational capacity (or hired help) to manage the complexity.
- The business case clearly justifies the migration cost.
Self-host when:
- You want maximum control and minimum unit cost, and have the time / skill.
- You're building for compliance scenarios that require on-premises.
- Educational reasons — doing it once teaches you a lot.
Backend anti-patterns to avoid
- Premature scale. Building on AWS with Kubernetes "in case you scale" before you have a single user is the most common solo-developer mistake. Start simple. Migrate when you have to.
- Multi-cloud from day one. Two clouds = two operational burdens. Pick one.
- API keys in the iOS app. Already covered above — this is the most common security mistake.
- No rate limiting. A single abusive user can run up a $1,000 AI API bill overnight. Rate-limit everything that hits a paid API.
- No monitoring. If you don't know your backend is down, your users will tell you — via App Store reviews. Set up basic uptime + error monitoring on day one.
- Manual deploys. Push-to-deploy via GitHub (which Railway and Vercel both offer for free) prevents many footguns.
- Plain HTTP. Always HTTPS. iOS App Transport Security enforces this anyway.
- Logging secrets. Logs get shipped to many places. Don't log API keys, tokens, or PII.
Economics at small scale
For a solo iOS dev with a few thousand users, realistic monthly backend costs:
- Railway: $5-$30/mo for a small backend + Postgres. Predictable.
- Vercel: $0-$20/mo for a small Next.js app on the hobby tier.
- Firebase: $0-$50/mo at small scale; rapidly more if you hit the high-volume read tiers.
- AWS: wide range. Can be ~$10/mo with care; can be $500/mo with one misconfigured NAT gateway.
- Cloudflare Workers: often free or $5/mo at small scale.
The dominant cost for most AI-powered iOS apps isn't the backend itself — it's the AI API costs (Claude / OpenAI). Backend hosting is usually 10-20% of total infra cost; AI inference is the other 80-90%.
Migrating between backends
It's not as painful as people fear, IF you've structured your code to make it possible. The general approach:
- Keep the API surface stable. Your iOS app talks to URLs and JSON shapes. As long as those don't change, the backend can be rewritten underneath without an app update.
- Avoid vendor-specific APIs in your backend code. Wrap them. If you call Railway-specific features directly throughout your code, you'll regret it. If you wrap them in your own abstraction, swapping is mechanical.
- Migrate data carefully. Plan the database migration before you flip traffic.
- Run both in parallel briefly. Send some traffic to the new backend, verify, then ramp.
- DNS cutover is the final step. Point the API hostname at the new backend.
Most teams migrate exactly once, when they outgrow their first platform. The second platform tends to last forever or until acquisition.
Deep-dives on specific backends: Railway, AWS, Azure, Google Cloud, Firebase. For the side-by-side cost comparison, see Backend Comparison.
- Railway — Documentation
- AWS — Services overview
- Google Cloud — Documentation
- Firebase — Documentation