# How it works

> What an app, a deployment, a replica and an image are, how a push becomes a running app, how a request reaches it, and the words the dashboard uses.

You connect a GitHub repository once. From then on, every push to your branch is built and put online, with HTTPS, logs and a way back to an earlier version. This page names the parts and what each one does.

## The parts

| Word | What it is |
| --- | --- |
| App | One repository, one branch, one running service. It has an address, settings, variables, domains and a team |
| Deployment | One commit of the branch, built and put online. Every deployment is kept with its build log |
| Image | What the build makes of a commit: your files and packages, ready to start. One image per deployment, reused by a restart or a rollback |
| Replica | One running copy of the image. An app runs one or more replicas, or none while it sleeps |
| Region | Where the replicas run. Chosen when the app is created, changeable later |
| Team | Who owns the apps and pays for them. Every app belongs to one team |

## From push to live

![A push is built, released and then live](https://arrangic.com/docs/img/deployment.svg)

1. **You push.** A push to the branch of the app starts a deployment. You can also start one by hand, from a [deploy hook](https://arrangic.com/docs/deployments.md#deploy-hook), or roll back to an earlier one.
2. **It is built.** The commit is fetched, your packages are installed and your build command runs. The result is the image. See [How an app is built](https://arrangic.com/docs/builds.md).
3. **It is released.** Your [deploy commands](https://arrangic.com/docs/deploy-commands.md) run once, a database migration for example. Then one replica of the new version starts; once it listens on its port, or answers on its [health check path](https://arrangic.com/docs/deployments.md#health-check), the other replicas follow and the old ones stop.
4. **It is live.** The app answers at its address. If a step failed, the version that was running stays online and your visitors see nothing of it.

## How a request reaches your app

1. A visitor opens your address: the platform URL of the app, or a domain of your own.
2. The platform takes the HTTPS connection with the certificate of that hostname. Your app never handles certificates.
3. The request is handed to a replica of your app over plain HTTP, on the port in the `PORT` variable, with the visitor's address in the `X-Real-IP` header.
4. Your app answers. The platform sends the answer back over HTTPS.

If the app is asleep, the platform holds the request, starts a replica and hands the request over once the app listens. See [Requests and sockets](https://arrangic.com/docs/requests.md) and [Sleep and wake](https://arrangic.com/docs/sleep-and-wake.md).

## What this means for your app

- **It listens on `PORT`, on all interfaces,** and serves plain HTTP. See [The running app](https://arrangic.com/docs/running-app.md).
- **It keeps nothing on its disk or in its memory that it cannot lose.** A replica is replaced at every deployment, and stopped while the app sleeps. Data belongs in a database or a store outside the app.
- **It can run more than once.** With several replicas, every replica handles requests on its own; they share nothing. See [Scaling](https://arrangic.com/docs/scaling.md).
- **Work without a visitor** belongs in a [cron job](https://arrangic.com/docs/cron-jobs.md), which runs on a machine of its own while the app sleeps.

## Where things are in the dashboard

| You want to | Where |
| --- | --- |
| Deploy, restart, pause | The top of the app, and **More actions** |
| See each deployment and its build log | **Deployments** |
| See CPU, memory, requests and response time | **Metrics** |
| Read what the app prints | **Logs** |
| Set variables | **Settings**, **Variables** |
| Change the commands, the port, the Node version, the health check, the branch, the deploy hook | **Settings**, **Build & deploy** |
| Change the size, the replicas, the region, sleeping | **Settings**, **Scaling** |
| Add a domain | **Settings**, **Domains** |
| Run a command on a schedule | **Settings**, **Cron** |
| Members, billing, notifications | **Team settings** |

---

This page on the site: https://arrangic.com/docs/how-it-works  
All pages of the documentation: https://arrangic.com/llms.txt
