# Self-hosting OpenKedai

A **hub** lets several tablets and phones work as one shop, and serves the web back office. The
POS app works without one (single-device mode); add a hub when a second device arrives, or when
you want the back office. See [Running a hub](https://docs.openkedai.com/hub/) for what it does.

The hub is one small program with one port (8080) and one data folder. It needs no database
server: each shop is a SQLite file. A $5 server, a Raspberry Pi or a mini PC at the shop runs it.

## Where to run it

| Where | Good for | Guide |
| --- | --- | --- |
| **A computer at the shop** (mini PC, Raspberry Pi 4/5, NAS) | Shops with several devices: everything keeps working when the internet is down | [Docker](https://docs.openkedai.com/self-hosting/docker/) or [Linux installer](https://docs.openkedai.com/self-hosting/linux/), then [On the shop's network](https://docs.openkedai.com/self-hosting/lan-hub/) |
| **A cloud server** (any VPS, DigitalOcean Droplet) | One device or a few; the back office from anywhere | [Linux installer](https://docs.openkedai.com/self-hosting/linux/), [Docker](https://docs.openkedai.com/self-hosting/docker/), [DigitalOcean](https://docs.openkedai.com/self-hosting/digitalocean/) |
| **A hosting platform** | No server to look after | [Fly.io](https://docs.openkedai.com/self-hosting/fly/), [Render](https://docs.openkedai.com/self-hosting/render/), [Railway](https://docs.openkedai.com/self-hosting/railway/) |

A hub in the cloud works, but devices then need the internet to see each other's orders (a
waiter's phone sending to the counter, shared tables). Every device keeps selling and printing
when the hub can't be reached, and catches up afterwards. For a café or restaurant with several
devices, a hub at the shop is best.

## After it starts

1. Find the **setup code** in the hub's log (a line ending `Setup code: K7QM-2XPA`). It's the hub
   owner's key for adding shops; keep it to yourself.
2. Open the hub's address in a browser and choose **Set up a new shop**, or move an existing
   POS device's shop to it (**Settings → Hub**). See [the back office](https://docs.openkedai.com/back-office/).

## Looking after it

- **Backups:** the hub takes a snapshot of every shop every 24 hours and keeps the last 7. You can
  also copy them to S3-compatible storage. See [Backups](https://docs.openkedai.com/self-hosting/backups/).
- **Updates:** each guide says how. Updates run database changes on their own, after keeping a
  copy of each shop's file.
- **Settings:** every setting has a safe default; see [Configuration](https://docs.openkedai.com/self-hosting/configuration/).
- **HTTPS and remote access:** see [HTTPS and remote access](https://docs.openkedai.com/self-hosting/https/).

## What it uses

Measured on every release (`pnpm budget`): about 120 MB of memory at idle, under 256 MB with a
busy shop, almost no CPU when idle, a start in under a second, and an image of about 80 MB.
