Install it, draw your first zone, take grocery orders
Basketrun is a grocery quick-delivery marketplace that you run as your own business. Local stores join and sell their groceries. Shoppers order from the stores near them in the shopper app, express in 15 to 30 minutes or in a delivery slot. Pickers pack each order in the store app, scan the barcodes and offer swaps for empty shelves. Drivers bring it to the door with the driver app. Store owners run their store from a web panel, and you run the whole marketplace from the super-admin.
This guide is written for first-time installers. Every command is shown in full, every setting says where to find it, and every business rule is explained in plain words. Read Part 01 to get the server running, Part 02 to connect payments, email, maps and push, and Part 03 to build your three apps.
Get started
1Welcome
Thank you for choosing Basketrun. This guide takes you from the download to a running grocery marketplace with your first zone, your first store and your three apps on real phones.
What you get
- The shopper app (Flutter, Android and iOS): delivery address with a zone check on the map, a home page with express, stores near you, aisles and deals, store pages, search, product pages, a cart for one store at a time, a swap choice for every item, express delivery or a scheduled slot, coupons, a tip, checkout by card (Stripe), cash on delivery or wallet credit, live tracking with the driver on the map, swap approvals, a chat with the store and the driver, a 4-digit delivery code, ratings, reorder, a wallet for refunds and top-ups, saved addresses and notifications.
- The store app for pickers: new orders that ring until someone answers, the pick list by aisle, barcode scanning with the phone camera, missing items, swap offers the shopper approves, packing with the bag count, the hand-over to the driver, today's work and an open/paused switch.
- The driver app: online and offline, job offers with the pay shown before accepting, pickup and drop-off with a hand-off to Google Maps or Apple Maps, proof of delivery by code or photo, cash orders with change, earnings, trips and the next payout.
- The store panel (web) for owners and managers: an overview, the live orders board, the catalogue with CSV import, stock, opening hours and slots, the team, reports and store settings.
- The super-admin (web) for you: the overview, delivery zones drawn on a map with their fees, stores and their applications, commissions, drivers and their approval, orders and refunds, customers, coupons, the weekly payouts report, people, settings, legal pages and a setup check that tests every outside service live.
- A public website: a home page with an address check and the stores near it, a "Sell with us" application form for stores, and six legal pages you write in the super-admin.
- An install wizard and a sample city ("Lakeport": three stores, ten aisles, 182 products, drivers and coupons) you can load with one command to try everything.
- One-command self-hosting with Docker: the server (one compiled Rust program that also serves the web app), PostgreSQL, MinIO file storage and optional automatic HTTPS with Caddy.
What is in the download
| Path | What it is |
|---|---|
apps/backend/ | The server, written in Rust (Axum): the /api/v1 API for the web app and the three Flutter apps, the Stripe webhook, the background jobs, dispatch and the built web app, compiled into one program called basketrun. apps/backend/seed/ holds the sample city and the starter legal texts. |
apps/frontend/ | The web app: React 19, React Router 7, Vite, Tailwind CSS 4 and shadcn/ui. The super-admin, the store panel, the public site, sign-in and the install wizard. |
basketrun_mobile_flutter/ | The Flutter project. One codebase that builds three apps by flavour: shopper, store and driver. |
migrations/ | The PostgreSQL database schema. The server applies it by itself when it starts. |
docker/, compose.yaml | The Dockerfile, the Docker Compose stack and the Caddy HTTPS config. |
.env.example | Every server setting, explained. Copy it to .env. The apps have their own, basketrun_mobile_flutter/.env.example. |
tools/rename.mjs | One command that gives the apps and the web app your name, ids, colour and icons (chapter 16). |
docs/ | This documentation as one HTML file and as a PDF, plus the list of third-party licences. |
README.md, CHANGELOG.md, LICENSE.txt | A one-page quick start, the version history and the licence notes. |
AI disclosure
AI tools used to create this item: Yes
- Source code: Yes. Written with Claude by Anthropic as an AI coding assistant, then reviewed, tested (server tests against a real PostgreSQL, web app tests, Flutter widget and flow tests, and tests of the three apps against a running server) and integrated by us.
- Documentation: Yes. Drafted with Claude by Anthropic and checked against the code and the running apps.
- Graphics: Yes. The screen designs, the three app icons and the layouts of the preview images were made with Claude by Anthropic working in a design tool and in code. No image was made with an AI image generator: every screenshot in this guide and the item's previews is a capture of the running apps, and the demo's product, store and aisle photos are Pixabay photos shown on the demo only (not in the download).
- Demo text: Yes. The sample city's stores, product names, people and the starter legal texts were written with Claude by Anthropic and edited by us. The starter legal texts are a starting point, not legal advice.
AI-powered features: No. Basketrun has no AI features and calls no AI service.
Basketrun works with your own accounts at Stripe, Google (Firebase and, if you choose it, Google Maps), MapTiler, Apple and your email and storage providers. It is not made, endorsed or sponsored by any of them. Map data in the default maps is © OpenStreetMap contributors.
Screenshots
The main screens of the super-admin, the store panel, the public site and the three apps. Every chapter in Part 04 has more.
2Requirements
To run the server (recommended: Docker)
- A 64-bit Linux server (Intel/AMD or ARM) with Docker Engine 24 or newer and Docker Compose 2.20 or newer (the stack uses Compose's
includefeature). Docker Desktop or Colima on macOS, or Docker Desktop on Windows, works for trying it on your own computer. - For the first build (Docker compiles the Rust server and the web app from source): 2 processor cores and 4 GB of memory (or 2 GB plus swap), and about 6 GB of free disk for Docker's build cache. The first build compiles everything and takes the longest; later builds reuse the cache (a rebuild after a small change took about 70 seconds on a cloud server).
docker builder prunegives the cache space back once the app runs. - To run it the server needs far less: the finished app image is about 110 MB, and the app itself uses only a few megabytes of memory when idle. PostgreSQL and MinIO run beside it, so plan at least 1 GB of memory for a small marketplace. You can also build on another computer and run the result on a smaller server; see Put it online.
- A domain name and HTTPS for a public launch. The apps, Stripe and the browsers need a public
https://address with a valid certificate; the bundled Caddy gets one for you for free. - A current version of Chrome, Edge, Firefox or Safari for you and the store teams.
To build the mobile apps
Flutter on your own computer, Android Studio for the Android apps and a Mac with Xcode for the iOS apps. What you need in Part 03 lists the versions.
To build or change the server without Docker
- Rust 1.90 or newer (stable) from rustup.rs.
- Node.js 24 (22.12 or newer also works) and pnpm 11 (
corepack enableinstalls the pnpm version the project asks for). - PostgreSQL 15 or newer (the Docker stack ships PostgreSQL 17).
- Optional: any S3-compatible storage (MinIO, AWS S3, Cloudflare R2, Backblaze B2…). Without it, files are kept in a local folder.
Accounts you need
| Account | What it is for | Needed |
|---|---|---|
| Stripe | Card payments for orders and wallet top-ups, and card refunds. Without it, shoppers pay cash on delivery or with wallet credit. | To take card payments |
| An SMTP email provider | Password resets, invitations for store teams and drivers, application answers and store notices. Without it, each email is written to the app's log with its link. | For a public launch |
| Firebase (Google, free) | Push notifications to locked phones: new orders for pickers, offers for drivers, order updates for shoppers. Without it, the apps still update live while they are open. | Strongly advised |
| Apple Developer Program and Google Play Console | Publishing the three apps under your own name. | To publish the apps |
| MapTiler or Google Maps Platform | Map tiles and address search for a busy marketplace. The default OpenStreetMap needs no account. | Optional |
| S3-compatible storage | Product photos, store pictures, delivery photos and your logo. The bundled MinIO does this on the same server. | Optional |
3Extra costs you pay
Basketrun has no monthly fee of its own. What you pay each month depends on the outside services you turn on. Each of them is run by another company with its own pricing, and you, the buyer, are responsible for every one of these costs. The prices below are the providers' published list prices in November 2026; they change, so check each provider's own pricing page before you set your fees.
| Service | Price | What that means for you |
|---|---|---|
| Stripe (card payments) | 2.9% + 30¢ | Per successful US card payment, on every order, add-on and wallet top-up paid by card. On a $30 order that is about $1.17. Stripe keeps its fee when you refund a payment. Other countries and cards have their own rates. |
| OpenStreetMap tiles and address search (the default) | Free | Public map tiles and the Nominatim address search, under their fair-use policies: light use only, at most one address search a second (the server keeps every answer for 30 days, so repeated searches cost nothing). Fine for trying it and a small city; a busy marketplace should move to MapTiler or Google. |
| MapTiler | Free plan, then from about $25 a month | The free plan is for testing and small projects with a monthly cap on map loads; a live business needs a paid plan. Tiles and address search use the same key. |
| Google Maps Platform | Map loads in the apps free; address search 10,000 a month free, then $5 per 1,000 | The phone apps draw Google Maps with Google's mobile SDKs, which Google does not charge for. The server's address search uses Google's Geocoding API. Google needs a billing account even inside the free allowance. |
| Firebase Cloud Messaging (push) | Free | No charge per message. |
| Apple Developer Program | $99 a year | One membership publishes all three apps on the App Store. |
| Google Play Console | $25 once | One developer account publishes all three apps on Google Play. |
| Email (for example Amazon SES) | $0.10 per 1,000 | Per email sent. Other SMTP providers sell monthly plans with a free tier. |
| File storage | $0 to $0.015 per GB | The bundled MinIO or the server's own disk costs nothing extra. Cloudflare R2, for example, charges $0.015 per GB a month with the first 10 GB free and no fee for downloads. |
| Server (VPS) | about $10 to $40 a month | One server with 2 cores and 4 GB of memory runs the whole Docker stack for a city. |
| Domain name | about $10 to $20 a year | The address of your marketplace, for example shop.yourbrand.com. |
Shoppers pay the zone's delivery fee and the platform's flat service fee on each order, and you keep a commission on each store's item sales (Part 04). Set them so that Stripe's fee on a typical basket, your driver pay per trip and your running costs are covered.
4Install in 10 minutes with Docker
This runs Basketrun on your own computer or on a server. The first build compiles the server from source, so it takes longer than later starts.
- Unzip the download and open a terminal in the
basketrun/folder (the one withcompose.yamlin it). - Create your settings file:
cp .env.example .env - Open
.envin any text editor and fill in these four values:
Change both passwords: the example values are public. KeepAPP_URL=http://localhost:8080 # your public https:// address on a server APP_SECRET=paste-a-random-string-here # make one with: openssl rand -hex 32 POSTGRES_PASSWORD=pick-a-long-password # letters and digits only S3_SECRET_ACCESS_KEY=pick-another-password # at least 8 charactersAPP_SECRETsafe and never change it after the install, because it encrypts the keys you save in the super-admin. LeaveDATABASE_URLempty: Docker builds the database address from the values above, and that key is only for running the server without Docker. - Build and start everything:
Docker compiles the web app and the Rust server, then starts PostgreSQL and MinIO (file storage), creates the storage bucket and starts the app, which applies the database migrations by itself. Later builds reuse Docker's cache and are much quicker (about a minute after a small change).docker compose up -d --build - Find the install token in the app's log (if the app has restarted, use the last one):
The line readsdocker compose logs app | grep -i "install token"Install token: br-install-… (open /install and paste it). - Open http://localhost:8080. The install wizard opens: paste the token, check the server, create your super-admin account, name your platform and draw your first delivery zone.
- Optional: load the sample city to see everything with data in it (chapter 34):
docker compose exec app basketrun seed-demo --confirm
See what the app is doing with docker compose logs -f app. Stop it with docker compose down; your data stays in Docker volumes. Use another port by setting APP_PORT=8090 in .env and running docker compose up -d. The app port is open on this computer only (APP_BIND=127.0.0.1); on a server, visitors come in through HTTPS as the next chapter shows.
A phone cannot reach localhost on your computer. The Android emulator reaches it as http://10.0.2.2:8080; the iOS simulator as http://localhost:8080. A real phone needs the server's https address, so put it online first (next chapter).
If the build stops with "signal: 9" or "killed", the server ran out of memory while compiling. Add swap (for example 4 GB) and run the same command again, or build on a bigger computer and copy the result, as the next chapter explains.
5Put it online
For real orders, Basketrun must be reachable at a public https:// address: the three apps talk to it, Stripe sends its payment webhook to it and shoppers come back to it after paying.
1. Pick a server (VPS)
| Size | Good for |
|---|---|
| 2 cores, 4 GB memory, 40 GB disk | Building on the server and running a city with several stores, dozens of drivers and thousands of orders a day. |
| 1 to 2 cores, 1 to 2 GB memory | Running a build made on another computer (see "Build on another computer" below), or building with swap added. |
| 4+ cores, 8+ GB memory | Several busy cities on one install. |
Any provider that sells Linux servers with Docker works. Disk use grows mainly with product and delivery photos, so move files to outside storage once it grows (see File storage).
2. DNS
At your domain registrar, add an A record for the address you want (for example shop for shop.yourbrand.com) pointing at your server's IP address. Wait until ping shop.yourbrand.com shows that IP.
3. Settings
In .env:
APP_URL=https://shop.yourbrand.com
APP_DOMAIN=shop.yourbrand.com
TRUSTED_PROXY_HOPS=1
4. Start with HTTPS (Caddy)
When nothing else on the server uses ports 80 and 443, the bundled Caddy does it all. Open both ports in your server's firewall, then:
docker compose --profile https up -d --build
The https profile adds Caddy, a web server that gets and renews a free certificate for APP_DOMAIN by itself. Open https://shop.yourbrand.com; the first visit takes a few seconds while the certificate is issued. Caddy passes the live update stream through unbuffered, so the orders board and the tracking map move at once.
Caddy needs ports 80 and 443 for itself. If Traefik, Nginx Proxy Manager, an Nginx or Apache already owns them, leave out --profile https, start with docker compose up -d --build and let your proxy pass visitors on to Basketrun, as the next part shows.
Behind a proxy you already run
Where the proxy runs decides how it reaches the app:
- Installed on the server itself (Nginx or Apache from the system's packages): point it at
http://127.0.0.1:8080(APP_PORT), the port the app opens on this server only. - In a Docker container (Traefik, Nginx Proxy Manager, an Nginx container): it cannot use
127.0.0.1:8080, because inside a container that address is the container itself. Put the app on the proxy's Docker network instead, with acompose.override.yamlfile next tocompose.yaml. Docker Compose reads it by itself on everydocker composecommand.docker network lsshows the proxy's network name; the examples call itproxy.
Traefik: the labels tell Traefik the address, the entrypoint and the certificate resolver. Use the entrypoint and resolver names from your own Traefik setup (websecure and letsencrypt are common).
# compose.override.yaml: Basketrun behind a Traefik that runs in Docker
services:
app:
networks: [default, proxy] # default: the app's own database and storage
labels:
- traefik.enable=true
- traefik.docker.network=proxy # the same network name
- traefik.http.routers.basketrun.rule=Host(`shop.yourbrand.com`)
- traefik.http.routers.basketrun.entrypoints=websecure
- traefik.http.routers.basketrun.tls.certresolver=letsencrypt
- traefik.http.services.basketrun.loadbalancer.server.port=8080
networks:
proxy:
external: true
name: proxy # your proxy's network, as docker network ls shows it
Nginx in a container, or Nginx Proxy Manager: join the network the same way and give the app a name there that no other container uses.
# compose.override.yaml: Basketrun on the network of an Nginx container
services:
app:
networks:
default:
proxy:
aliases: [basketrun]
networks:
proxy:
external: true
name: proxy # your proxy's network, as docker network ls shows it
Then send the traffic to http://basketrun:8080. In Nginx:
location / {
proxy_pass http://basketrun:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off; # the live updates are a stream
client_max_body_size 21m; # PDF documents and CSV lists go up to 20 MB
}
In Nginx Proxy Manager, add a Proxy Host with scheme http, forward hostname basketrun and port 8080, request its SSL certificate, and paste the last two lines above into the Advanced tab. Keep TRUSTED_PROXY_HOPS=1: Traefik, Nginx and Nginx Proxy Manager each add one address, as the next section explains.
5. Visitor addresses and rate limits
Basketrun limits sign-ins, sign-ups and password resets per visitor address, so nobody can guess passwords at speed. It reads the visitor's address from the X-Forwarded-For header only behind the number of proxies you trust, set with TRUSTED_PROXY_HOPS. A visitor can type any X-Forwarded-For they like, so trusting it without a proxy would let them make up a new address for every try.
| Your setup | Setting |
|---|---|
The bundled Caddy (--profile https) | TRUSTED_PROXY_HOPS=1 (the Docker default). The app port is published on 127.0.0.1 only, so Caddy is the only way in, and Caddy replaces any X-Forwarded-For a visitor sends with the real address. |
| Your own Nginx, Apache or Traefik on the same server, on the host or in Docker (above) | TRUSTED_PROXY_HOPS=1 and keep APP_BIND=127.0.0.1. Turn off response buffering (Nginx: proxy_buffering off;) so the live updates work. |
| A load balancer or CDN in front of your proxy (for example Cloudflare, then Caddy) | TRUSTED_PROXY_HOPS=2: one hop for each proxy that adds an address. Never set a higher number than the proxies really in front of the app. |
| No proxy at all (app port open to the internet) | TRUSTED_PROXY_HOPS=0 and APP_BIND=0.0.0.0. No header is trusted, the per-address limits are off and only the per-account limits apply. The apps and Stripe need HTTPS, so this suits only testing. |
Super-admin → Setup check shows the current setting in its "Visitor addresses" row. The full list of limits is in Security notes.
Build on another computer
If your server is small, build the program on a bigger computer with Docker and copy it over. The packed program is one file that already holds the web app.
# on the bigger computer, in the basketrun folder (use --platform linux/arm64 for an ARM server)
docker build -f docker/Dockerfile --target pack -t basketrun-pack --platform linux/amd64 .
docker create --name basketrun-pack-copy basketrun-pack
mkdir -p prebuilt
docker cp basketrun-pack-copy:/basketrun prebuilt/basketrun
docker rm basketrun-pack-copy
# copy prebuilt/basketrun into the same folder on the server, then on the server:
BUILD_TARGET=prebuilt docker compose --profile https up -d --build
Set BUILD_TARGET=prebuilt in .env to keep it for later starts. The program must match the server's processor type (Intel/AMD = linux/amd64, ARM = linux/arm64).
Without Docker
Build the web app, then the server, and run the server behind your own HTTPS proxy:
cd apps/frontend && corepack enable && pnpm install && pnpm build && cd ../..
cargo build --release -p basketrun-server
./target/release/basketrun pack apps/frontend/dist/client ./basketrun
# .env next to where you start it: DATABASE_URL, APP_URL, APP_SECRET; STORAGE_DRIVER=local or your S3 bucket
BIND=127.0.0.1:8080 ./basketrun serve
Keep it running with a service manager such as systemd. The server applies the migrations when it starts; ./basketrun migrate applies them on their own. To load the sample city outside Docker, set DEMO_CATALOG=apps/backend/seed/lakeport.json before running ./basketrun seed-demo --confirm.
Other hosts
- Platforms that run a Docker image (most cloud container services): build the image with
docker build -f docker/Dockerfile -t basketrun ., give it a PostgreSQL 15+ database throughDATABASE_URL, an S3 bucket through theS3_*keys (orSTORAGE_DRIVER=localwith a persistent volume at/app/storage), and setAPP_URL,APP_SECRETandTRUSTED_PROXY_HOPSfor the platform's own proxy. The app listens on port 8080. - Managed PostgreSQL works through
DATABASE_URL. - Shared web hosting (cPanel, PHP hosting) cannot run Basketrun: it needs a server that runs Docker or a Linux program.
Two copies on one server
To run a staging copy next to the live one, unzip Basketrun into a second folder and give each copy its own .env:
# .env of the live copy
COMPOSE_PROJECT_NAME=basketrun
APP_PORT=8080
APP_URL=https://shop.yourbrand.com
# .env of the staging copy
COMPOSE_PROJECT_NAME=basketrun-staging
APP_PORT=8081
APP_URL=https://staging.yourbrand.com
SEARCH_INDEXING=off
COMPOSE_PROJECT_NAME keeps each copy's containers, database, files, network, image and build cache apart. Left empty, it is the folder's name, so two folders with the same name would share everything: always set it when you run two copies. Give each copy its own passwords and its own APP_SECRET. Only one copy can run the bundled Caddy, so put both behind one proxy you run yourself with a different router name or network alias for each. SEARCH_INDEXING=off keeps search engines away from the staging copy.
6Install wizard
The first visit to a new install opens the wizard at /install. It has seven steps and runs once; afterwards the page is locked so nobody else can take the server over.
- Server checks. Paste the setup token from the app's log (
docker compose logs app | grep -i "install token") and press Check the server. The app prints a new token at every start until the install is finished, so use the last line. Lost it? SetINSTALL_TOKENin.envto a value of your choice and restart the app withdocker compose up -d. The wizard then lists the database, file storage, the app address, email, Stripe, maps, push and the other settings, each marked ready or later. A red line blocks the next step until you fix.env, restart the app and check again. - Your admin account. Your name, email and a password of at least 10 characters. This is the platform's super-admin.
- Platform name and currency. The name everyone sees (for example "Basketrun · Lakeport"), the support email shoppers and stores write to, the currency, the time zone (slots, payout weeks and reports follow it) and the default commission you keep on each store's item sales.
- First delivery zone. Find your city, then drag the corners of the zone over the streets you deliver to. Name it and set its delivery fee, free delivery over an amount, minimum order, express delivery on or off, and scheduled slots (30 minutes with 6 orders per store, 1 hour with 12, or 2 hours with 24). Shoppers cannot order until one zone exists; you can add more later in Zones.
- Payments (Stripe). Your publishable key, secret key and webhook signing secret, with the webhook address to paste into Stripe (chapter 8). Optional now: until it is set, shoppers pay cash on delivery.
- Email (SMTP). The mail server, port, user name, password and the sender. Optional now: until it is set, reset and invite emails are written to the app's log.
- Finish. You are signed in as the super-admin and the wizard is locked. It lists what is set up and what is left for later, with the place in the super-admin where each one is done.
7Setup check
Super-admin → Setup check lists everything a running marketplace depends on, with a plain-words status and what to do about it. Run again checks everything again and then tests every service that can be tested for real; the results replace the rows they test.
| Row | What it shows, and what the test does |
|---|---|
| Database | PostgreSQL is reachable and how many migrations are applied. The test reads the PostgreSQL version. |
| File storage | The S3 bucket, or a warning that files are on this server's disk. The test writes, reads and deletes a small test file. |
| Email (SMTP) | The sender and mail server. The test connects and signs in. Settings → Email sends a real test email to any address you type. |
| Stripe | Whether the secret key is set (test or live mode) and whether the webhook signing secret is there. The test reads your Stripe balance. |
| Maps | Which map the apps and pages draw, and a warning when MapTiler or Google is chosen without a key (the maps then fall back to OpenStreetMap). |
| Push messages | Whether a Firebase service account is saved. Without it, the apps show updates only while they are open. |
| App address | Whether APP_URL is https. The test calls APP_URL/api/health from the server itself. |
| Visitor addresses | The TRUSTED_PROXY_HOPS setting (chapter 5). |
| Background jobs | Jobs that failed in the last 24 hours or wait too long (emails, payment checks, purges). |
| Install | Whether the install wizard has finished. |
Connect services
Every outside service can be set in .env or in Super-admin → Settings. Values saved in the super-admin take precedence over .env, secrets are stored encrypted with your APP_SECRET, and a saved secret is never shown again (only its last four characters). Change a secret by typing a new one.
8Card payments (Stripe)
Shoppers pay by card through Stripe Checkout on your own Stripe account: for an order, for items added to an open order and for wallet top-ups. An order paid by card is placed only when Stripe's signed webhook confirms the payment, so set up the webhook as well as the keys.
Stripe is a third-party payment service with its own pricing, and you pay its fees: in the USA 2.9% + 30¢ per successful card payment. Stripe keeps its fee when you refund. Other countries, cards and currencies have their own rates on Stripe's pricing page.
1. Keys
- Create a Stripe account at stripe.com and switch the Dashboard to Test mode (a sandbox) first.
- Open Developers → API keys and copy the Publishable key (
pk_test_…) and the Secret key (sk_test_…). - Paste them into Super-admin → Settings → Payments (Stripe), or into
STRIPE_PUBLISHABLE_KEYandSTRIPE_SECRET_KEYin.env. Use both test keys or both live keys, never one of each.
2. The webhook
- In Stripe, open Developers → Webhooks and add an endpoint (Stripe's newer dashboard calls it Add destination: choose events from Your account, then Webhook endpoint).
- Endpoint URL: your
APP_URLfollowed by/api/v1/webhooks/stripe, for examplehttps://shop.yourbrand.com/api/v1/webhooks/stripe. The Payments settings page shows the exact address to copy. - Select these events:
checkout.session.completed,checkout.session.async_payment_succeededandcheckout.session.expired. - Copy the endpoint's Signing secret (
whsec_…) into Super-admin → Settings → Payments (Stripe), orSTRIPE_WEBHOOK_SECRETin.env. Without it, card orders would never be confirmed, and the setup check says so.
3. Payment methods
Stripe Checkout shows the payment methods you turn on in Stripe → Settings → Payment methods. Cards, Apple Pay and Google Pay suit grocery orders. Leave slow bank payments off: an unpaid checkout ends after about 30 minutes and the order is then cancelled, with its slot, coupon, wallet credit and stock released.
4. Test, then go live
- Press Test on the Stripe row of the setup check.
- In the shopper app, place an order with card payment and pay with Stripe's test card
4242 4242 4242 4242(any future date, any CVC). The order appears on the store's live orders board within a second or two of the payment. - Repeat steps 1 and 2 in live mode with your live keys and a live webhook endpoint, and save them.
Fees, cash and refunds
The same settings page holds three more choices:
| Setting | What it does |
|---|---|
| Service fee per order | A flat fee on every order (default $0.99), shown to shoppers as "Service fee" in the cart, at checkout and on the receipt. The platform keeps it. 0 hides the line. |
| Cash on delivery | On or off for the whole platform. When it is on, each zone sets the most cash a driver may collect for one order, and each store can turn cash off for itself. |
| Refunds go to | Where automatic refunds of card orders go (missing items, refused swaps, the difference of a cheaper swap, cancelled orders): the shopper's wallet (at once, the default) or the card they paid with (5 to 10 days). A card refund Stripe refuses goes to the wallet instead, so the shopper never loses money. In the refund dialog of an order you can pick the other each time. |
DEMO_PAYMENTS="true" in .env turns on a test checkout page that pays with 4242 4242 4242 4242 and declines 4000 0000 0000 0002, without Stripe. It is "false" in the shipped file. Use it only on a private test copy, never on a live site.
An order paid by card waits as "waiting for payment" until Stripe's signed webhook confirms it; only then do the store and the drivers see it. Each Stripe event is applied once, so Stripe's retries never double anything. Every refund goes to Stripe with its own idempotency key, so a refund is never paid twice, even when a call is retried. When Stripe cannot be reached, the webhook answers so that Stripe tries again later.
Taking orders and payments from shoppers through Basketrun requires the Envato Extended Licence. The Regular Licence covers a single product whose end users are not charged.
9Email (SMTP)
Basketrun sends password reset links, invitations for store teams and drivers, answers to store applications, document requests, store suspension notices and the stores' daily summaries and low-stock emails.
- Get SMTP details from any email provider (Amazon SES, Postmark, Brevo, Mailgun, your own mail server…): host, port, user name, password and a sender address on a domain you have verified with that provider.
- Enter them in Super-admin → Settings → Email (SMTP), or the
SMTP_*keys in.env. Usestarttlson port 587,tlson port 465. - Press Send a test email on that page, or Test on the Email row of the setup check.
Without SMTP, each email is written to the app's log with its link (docker compose logs app), which is enough for testing. The same page lets you reword the platform emails (password reset, invitation, store suspended), with placeholders such as {{name}}, {{store}} and {{brand}} filled in for each email.
Email providers are third-party services with their own pricing, and you pay them: Amazon SES, for example, charges $0.10 per 1,000 emails, and most other providers sell monthly plans with a small free tier.
10File storage
Product photos, store pictures and logos, profile pictures, delivery photos, store application documents and your platform logo are stored in an S3-compatible bucket. The Docker stack includes MinIO with a private bucket on the same server, so this works out of the box.
- Another bucket (AWS S3, Cloudflare R2, Backblaze B2, Wasabi, DigitalOcean Spaces…): set
S3_ENDPOINT,S3_REGION,S3_BUCKET,S3_ACCESS_KEY_IDandS3_SECRET_ACCESS_KEYin.env, or enter them in Super-admin → Settings → Storage. Keep the bucket private. For AWS S3 leaveS3_ENDPOINTempty; for R2 use your account's S3 address and regionauto. - A local folder:
STORAGE_DRIVER=localkeeps files in theapp-storageDocker volume. Fine for one server.
The Storage page also sets how much room each store gets (default 2,048 MB) and each shopper or driver (default 50 MB), 0 for no limit, shows what is stored and has a Test storage button. Uploads are checked by their content, not their name: photos are JPG, PNG or WebP of at most 5 MB, documents are PDF and lists are CSV of at most 20 MB.
The bundled MinIO and the server's own disk cost nothing extra. Outside storage providers are third-party services with their own pricing, and you pay them for space and sometimes for downloads: Cloudflare R2, for example, charges $0.015 per GB a month after the first 10 GB, with no download fees.
11Maps
Maps show up in many places: the shopper's address pin and tracking map, the store and driver apps, the zone editor and the live map in the super-admin, and the store settings. Address search ("Find your city", typing an address in the shopper app) goes through your server, which asks the map provider and keeps every answer for 30 days. You pick one provider for all of it in Super-admin → Settings → Maps (or MAP_PROVIDER in .env).
| Provider | Cost | Key | Good for |
|---|---|---|---|
OpenStreetMap (osm, the default) | Free | None | Trying it, the sample city and a small city. Public tiles and the Nominatim address search under the OpenStreetMap fair-use policies: light use only, one address search a second at most. A busy marketplace should move to MapTiler or Google, or run its own tile server. |
MapTiler (maptiler) | Free plan for testing; paid plans from about $25 a month | One MapTiler key | The same OpenStreetMap-based maps with a provider that allows commercial traffic. Tiles in the apps and the web pages, and address search on the server, all use the key. |
Google Maps (google) | Map loads in the apps free; address search 10,000 a month free, then $5 per 1,000 | A server key, an Android key and an iOS key | Google's own maps in the phone apps and Google's address search. The web pages keep OpenStreetMap or MapTiler tiles. Google needs a billing account. |
MapTiler
- Sign up at cloud.maptiler.com, then open Account → Keys and copy your key (or create one per app).
- Paste it into Super-admin → Settings → Maps (provider MapTiler) or set
MAP_PROVIDER=maptilerandMAPTILER_KEYin.env. The apps read the server's choice and key when they start, so they need no rebuild; you can also setMAP_PROVIDERandMAPTILER_KEYin the app.envto fix them at build time. - The key ships inside the apps and the web pages, so anyone can read it. Watch its use on your MapTiler account page. If you limit the key in MapTiler's settings, check afterwards that the apps and the address search still work: they call MapTiler from the phone and from your server, not from a browser.
Google Maps
- In the Google Cloud console, create a project, add a billing account and turn on the Maps SDK for Android, the Maps SDK for iOS and the Geocoding API.
- Make three API keys under APIs & Services → Credentials:
- Server key: API restriction Geocoding API, application restriction the IP address of your server. Paste it into Super-admin → Settings → Maps (provider Google) or
GOOGLE_MAPS_KEYin.env. - Android key: Maps SDK for Android, restricted to Android apps with your three application ids and their SHA-1 signing fingerprints (Google Play shows the fingerprint of its app signing key under Setup → App signing). Put it in the app
.envasGOOGLE_MAPS_ANDROID_KEY. - iOS key: Maps SDK for iOS, restricted to iOS apps with your three bundle ids. Put it in the app
.envasGOOGLE_MAPS_IOS_KEY.
- Server key: API restriction Geocoding API, application restriction the IP address of your server. Paste it into Super-admin → Settings → Maps (provider Google) or
- Set
MAP_PROVIDER=googlein the app.envtoo, and rebuild the apps: Google's mobile SDKs read their key when the app is built. An app built without its Google key draws OpenStreetMap instead.
MapTiler and Google Maps Platform are third-party services with their own pricing, and you pay them. Check MapTiler's pricing page and Google's Maps Platform price list before you choose; both change their plans from time to time. OpenStreetMap's public servers are free but run by volunteers, so respect their usage policy.
12Push notifications (your own Firebase project)
Push notifications reach a locked phone: a new order rings in the store app, a job offer rings in the driver app, and shoppers hear when the store accepted, a swap needs an answer, the driver is close and the order is delivered. They go through Firebase Cloud Messaging in your own Firebase project, which is free. Without it, the apps still show every update live while they are open, and the in-app notification list still fills.
There are two halves: the apps need your project's ids (so each phone can get a push token), and the server needs a service account key (so it can send). One Firebase project serves all three apps.
Firebase is a third-party service run by Google with its own pricing, and you are responsible for any Firebase costs. Cloud Messaging has no charge per message; other Firebase products you turn on yourself may be billed under Google's plans.
1. Create the Firebase project
- Open the Firebase console, choose Create a project, name it after your marketplace and finish (Google Analytics is not needed).
- For iOS: in Firebase → Project settings → Cloud Messaging → Apple app configuration, upload an APNs authentication key (
.p8). Make it in your Apple Developer account under Certificates, Identifiers & Profiles → Keys with "Apple Push Notifications service" ticked, and note its Key ID and your Team ID. One key serves all three apps.
2. Register the three apps with flutterfire configure
Install the tools once: the Firebase CLI (npm install -g firebase-tools, then firebase login) and the FlutterFire CLI (dart pub global activate flutterfire_cli). Then, in basketrun_mobile_flutter/, run it once per app, with your own project id and the ids your apps use (chapter 16):
flutterfire configure --project=your-firebase-project --platforms=android,ios \
--android-package-name=com.basketrun.shopper --ios-bundle-id=com.basketrun.shopper \
--android-out=android/app/src/shopper/google-services.json \
--ios-out=ios/config/shopper/GoogleService-Info.plist \
--out=lib/firebase_options_shopper.dart --yes
# the same for the store app (com.basketrun.store, folders store/) and the driver app (com.basketrun.driver, driver/)
Each run registers the Android and iOS app in your project, writes the two config files into that flavour's own folder (the placeholders shipped there are replaced) and writes a lib/firebase_options_<app>.dart file with the values for the next step. You can also add the apps by hand in Firebase → Project settings → Add app and download the two files into the same folders.
3. Put the ids in each app's .env
The apps start Firebase from the FIREBASE_* keys of the .env they are built with. Each of the three apps has its own Firebase app ids, so keep one settings file per app, for example .env.shopper, .env.store and .env.driver (copies of .env.example), and copy the values from that app's firebase_options_<app>.dart:
| Key in the app .env | Where the value is |
|---|---|
FIREBASE_API_KEY | apiKey of the android options (current_key in google-services.json). The iOS options' key also works for an iOS-only build. |
FIREBASE_PROJECT_ID | projectId |
FIREBASE_MESSAGING_SENDER_ID | messagingSenderId |
FIREBASE_ANDROID_APP_ID | appId of the android options (1:…:android:…) |
FIREBASE_IOS_APP_ID | appId of the ios options (1:…:ios:…) |
FIREBASE_IOS_BUNDLE_ID | iosBundleId |
FIREBASE_STORAGE_BUCKET | storageBucket (optional) |
Then build each app with its own file, for example flutter run --flavor store --dart-define-from-file=.env.store. The generated firebase_options_*.dart files are not used by the app; delete them once the values are copied, or keep them for reference. The app's account page shows "Push: not set up" until the keys are there.
4. The service account for the server
- In Firebase → Project settings → Service accounts, choose Generate new private key. A JSON file downloads. Anyone with it can send pushes as your project, so keep it safe.
- In Super-admin → Settings → Push (FCM), paste the file's text or press Upload the JSON file, then save. The page shows the project id it read; the key is stored encrypted and never shown again. (In
.envinstead:FCM_PROJECT_IDandFCM_SERVICE_ACCOUNT_JSONas one line of JSON.) - The Push row of the setup check turns green.
5. Test it
Install the store app on a real phone (the iOS simulator does not get pushes), sign in as a picker, allow notifications and lock the phone. Place an order for that store from the shopper app: the store phone rings within a few seconds. (Settings → Push → Send a test push only checks the service account with Google; it sends no message.) Device tokens that Firebase reports as gone are removed by themselves.
The mobile apps
The folder basketrun_mobile_flutter/ is one Flutter project that builds three separate apps: the shopper app, the store app for pickers and the driver app. Each is published on its own, under its own name and id, in your own Google Play and App Store accounts. They all talk to your Basketrun server.
13What you need
- Flutter 3.35 or newer on the stable channel (Dart 3.9 or newer), from docs.flutter.dev. The apps are built and tested with Flutter 3.44.
flutter doctortells you what is still missing. - For Android: Android Studio with the Android SDK (the apps compile against API 36) and Java 17. The apps run on Android 7.0 (API 24) and newer.
- For iOS: a Mac with a current Xcode from the Mac App Store and CocoaPods (
brew install cocoapods). The apps run on iOS 15 and newer. - Your Basketrun server online at an
https://address (chapter 5), or a test copy on your computer for the emulator. - A real phone for the things a simulator cannot do: push notifications, the camera barcode scanner in the store app and the delivery photo in the driver app.
14Three apps from one codebase
Which app you get depends on the flavour you build: shopper, store or driver. Each flavour has its own name, id, link scheme and Firebase files, so the three apps can sit side by side on one phone.
| App | Flavour | Name on the phone | Android application id and iOS bundle id | Link scheme | Who signs in |
|---|---|---|---|---|---|
| Shopper app | shopper | Basketrun | com.basketrun.shopper | basketrun:// | Shoppers. They create their own account in the app, and can browse before signing in. |
| Store app | store | Basketrun Store | com.basketrun.store | basketrun-store:// | The team of a store: owners, managers and pickers, invited from the store panel. |
| Driver app | driver | Basketrun Driver | com.basketrun.driver | basketrun-driver:// | Drivers you invite and approve in the super-admin. |
Change the names and ids to your own before you publish (chapter 16). An account signs in only to its own app: a shopper who opens the driver app is told "This account is for the shopper app. Sign in there instead."
First run
- Open a terminal in
basketrun_mobile_flutter/and create the settings file:cp .env.example .env - In
.env, setAPI_BASE_URLto your server, for examplehttps://shop.yourbrand.com(the Android emulator reaches a server on your own computer ashttp://10.0.2.2:8080). - Fetch the packages and start an emulator, a simulator or a phone on USB:
flutter pub get flutter devices - Run the app you want:
On iOS, Flutter picks the Xcode scheme of the same name (flutter run --flavor shopper --dart-define-from-file=.env flutter run --flavor store --dart-define-from-file=.env flutter run --flavor driver --dart-define-from-file=.envshopper,store,driver) and its build configurations, such asDebug-shopper. The first iOS run installs the CocoaPods by itself.
Every run and every build needs --flavor and --dart-define-from-file. The settings are built into the app; nothing reads a .env file on the phone. A build without a flavour (tests, the web preview) falls back to APP_ROLE in the .env, then to the shopper app.
15Every key in the app .env
These settings are built into each app with --dart-define-from-file. An empty value means "not set up": the feature turns itself off instead of failing. Never put a server secret here; everything in this file can be read out of the published app.
| Key | What it does |
|---|---|
API_BASE_URL | Your Basketrun server, without /api/v1, for example https://shop.yourbrand.com. Required. |
MAP_PROVIDER | osm (OpenStreetMap, no key), maptiler or google. Empty: the app uses the provider the super-admin chose. A provider without its key falls back to OpenStreetMap, so a map always shows (chapter 11). |
MAPTILER_KEY | The MapTiler key. Empty: the server's key from Settings → Maps. |
GOOGLE_MAPS_ANDROID_KEY, GOOGLE_MAPS_IOS_KEY | Google Maps keys for the Android and iOS builds. Google's SDKs read them when the app is built, so the server cannot send them. |
FIREBASE_API_KEY, FIREBASE_PROJECT_ID, FIREBASE_MESSAGING_SENDER_ID, FIREBASE_ANDROID_APP_ID, FIREBASE_IOS_APP_ID, FIREBASE_IOS_BUNDLE_ID, FIREBASE_STORAGE_BUCKET | Your Firebase project, for push notifications (chapter 12). The app ids differ per app, so keep one .env file per app. Empty: the app runs without push and shows "Push: not set up". |
DEMO_LOGINS | true shows the one-click demo sign-ins on the sign-in page, but only when the server is in demo mode too. Keep false for every build you publish. |
SUPPORT_EMAIL | The email address shown in Help. Empty hides it. |
APP_ROLE | Only for builds without --flavor (tests, the web preview): shopper, store or driver. |
SAMPLE_DATA | true turns on sample mode: the app answers every call from its own built-in Lakeport data and needs no server. Keep false for every build you publish. |
SAMPLE_SCENE | Sample mode only: the moment of the story the app opens on: cart, store_closed, placed, picking, swap, ready, on_the_way, delivered, cash_job or missed_offer. Empty: each app's own start. |
Sample mode
Sample mode is for changing the look of the apps without a server: every screen fills from the built-in sample city, orders move on by themselves, and errors can be shown on purpose. Try it with:
flutter run --flavor shopper --dart-define-from-file=.env --dart-define=SAMPLE_DATA=true --dart-define=SAMPLE_SCENE=swap
Nothing you do in sample mode reaches a server, and the data starts fresh at every launch.
One-click demo sign-ins off for a live store
The demo sign-in cards need two switches: DEMO_MODE=true on the server and DEMO_LOGINS=true in the app. A live marketplace has both off, so its sign-in page shows only email and password. Keep a separate .env for a demo build if you want one; never publish it.
16Make the apps yours
Google Play and the App Store know each app by its application id or bundle id. Once an app is published, its id can never change; a new id is a new app. Pick ids on a domain you own, for example com.yourbrand.shopper, com.yourbrand.store and com.yourbrand.driver.
The quick way: one command
tools/rename.mjs renames and rebrands the three apps and the web app's defaults in one go. Commit or back up your copy first, then run it from the kit folder (the one that holds basketrun_mobile_flutter and apps). It needs Node.js (chapter 2) and, when you give it icons, Flutter.
node tools/rename.mjs --name "FreshCart" --id com.acme.freshcart --dry # only shows what would change
node tools/rename.mjs --name "FreshCart" --id com.acme.freshcart --color "#2563EB" --icon icon.png --icon-bg "#2563EB"
| Option | What it does |
|---|---|
--name | The brand people see. Replaces every "Basketrun" in text: the app names ("FreshCart", "FreshCart Store", "FreshCart Driver"), the emails, the starter legal pages and the web app's default name. Letters, digits, spaces, dots and hyphens, up to 30 characters. |
--id | The base of the three app ids, in reverse-domain form and lower case: com.acme.freshcart gives com.acme.freshcart.shopper, .store and .driver, on Android, on iOS and in the Firebase placeholder files. Set it before the first store upload. |
--scheme | Optional. The apps' link schemes: freshcart://, freshcart-store:// and freshcart-driver://, also on the web page that brings shoppers back from Stripe. By default the name in lower case without spaces. |
--color | Optional. The brand colour (hex) of the apps' theme and of the web app's default; the lighter and darker tints are worked out for you. |
--icon | Optional. A square PNG of at least 1024 px with no transparency: the icon of all three apps, or of the shopper app when the next two are given too. The script copies it to basketrun_mobile_flutter/assets/icon/ and runs dart run flutter_launcher_icons for you. |
--store-icon, --driver-icon | Optional. Their own icons for the store app and the driver app. |
--icon-bg | Optional. The colour behind the icon on Android 8 and newer, which masks icons to round or other shapes: use your icon's own background colour. |
--dry | Shows what would change and writes nothing. |
Folder, package and database names (basketrun_mobile_flutter, basketrun-server, POSTGRES_DB) stay as they are: nobody sees them. The script is safe to run again with new values; it reads the current ones from the project first. After renaming:
- Register the three new ids in your Firebase project, replace each app's
google-services.jsonandGoogleService-Info.plist, and copy the new app ids into each app's.env(chapter 12). If you use Google Maps, add the new ids to your key restrictions (chapter 11). - Rebuild the server and web app:
docker compose up -d --build. The web app's name, logo and colour can still change at any time in Super-admin → Settings → Branding. - Build the apps again (chapter 17).
By hand: names, ids and link schemes on Android
The script does everything below for you. To change one thing yourself, this is where it lives.
All three are in basketrun_mobile_flutter/android/app/build.gradle.kts:
// The three apps. Each flavour has its own id, name and (optional) src/<flavour>/google-services.json.
val apps = mapOf(
"shopper" to Pair("com.yourbrand.shopper", "YourBrand"),
"store" to Pair("com.yourbrand.store", "YourBrand Store"),
"driver" to Pair("com.yourbrand.driver", "YourBrand Driver"),
)
// Each app's deep-link scheme (yourbrand://order/<id> is the shopper's way back from Stripe Checkout).
val urlSchemes = mapOf("shopper" to "yourbrand", "store" to "yourbrand-store", "driver" to "yourbrand-driver")
Also change applicationId in defaultConfig to the shopper id. The namespace (com.basketrun) is the code's package name, not the app's id; it may stay.
By hand: names, ids and link schemes on iOS
- Open
basketrun_mobile_flutter/ios/Runner.xcworkspacein Xcode and select the Runner target, then Build Settings. - Search for
PRODUCT_BUNDLE_IDENTIFIER,APP_DISPLAY_NAMEandAPP_URL_SCHEME. Each has one value per build configuration:Debug-shopper,Release-shopper,Profile-shopper, and the same forstoreanddriver. Set the shopper values on the three shopper configurations, and so on. - Under Signing & Capabilities, choose your Apple team. Keep the Push Notifications and Background Modes → Remote notifications capabilities.
By hand: names inside the apps
The name shown inside each app comes from lib/core/constants/app_role.dart ('Basketrun', 'Basketrun Store', 'Basketrun Driver'). A few on-screen texts name the brand too (the receipt, sharing a product, the camera and location prompts, help texts): search the lib/ folder for Basketrun and change them. On iOS, the permission prompts are in ios/Runner/Info.plist (NSCameraUsageDescription, NSLocationWhenInUseUsageDescription, NSPhotoLibraryUsageDescription).
After changing ids, update Firebase (register the new ids and replace the config files, chapter 12) and your Google Maps key restrictions.
Logo and app icons
- App icons: each app has its own icon: a basket on green for the shopper app, a basket under a shop awning on cream for the store app and a basket with motion lines on charcoal for the driver app. The sources are
basketrun_mobile_flutter/assets/icon/shopper.png,store.pnganddriver.png(1024 px, no transparency). To change one by hand, replace its picture, setadaptive_icon_background(the colour behind it on Android 8 and newer) in that app'sflutter_launcher_icons-<app>.yaml, and rundart run flutter_launcher_iconsinbasketrun_mobile_flutter. It writes Android's icons toandroid/app/src/<app>/res/and the iOS icon setsAppIcon-shopper,AppIcon-storeandAppIcon-driver, which each app's build configurations already select. Keep the artwork inside the middle 60% so Android's round and shaped masks don't cut it. - The mark inside the apps (splash, sign-in) is drawn in code in
lib/features/common/auth/widgets/basket_mark.dart. The launch screens areandroid/app/src/main/res/drawable/launch_background.xmlandios/Runner/Base.lproj/LaunchScreen.storyboard.
By hand: colours and fonts
The whole look is one file: lib/core/theme/app_theme.dart. Every screen reads its colours from there, never a fixed value.
- Brand colour: change
brand,brandSoft,brandInkandbrandHaloinAppColors.lightandAppColors.dark, andFixedColors.brand(splash and notification tint). Basketrun ships green#0F8A4F. - Express colour:
zestand its family (yellow#FFC93C) mark Express and arrival times only. - Font: the apps use Figtree, bundled in
assets/fonts/(SIL Open Font License). To use another font, add its files there, list them underfonts:inpubspec.yamland setAppText.familyin the theme file.
The web app has its own colours; most of it follows Super-admin → Settings → Branding without a rebuild (chapter 27).
Deep links
- Back from Stripe: after paying (or cancelling), Stripe sends the shopper to
APP_URL/pay/return?order=…. That page says how the payment went and has an Open the app button forbasketrun://order/<id>(basketrun://walletafter a top-up), with a plain line for when the app does not open. The app also reloads the order when it comes back to the front. The rename script changes the scheme there too; by hand, change it inapps/frontend/src/pages/public/states/PayReturn.tsx, then rebuild the server. - Notifications: tapping a push opens the right screen (the order, the offer, the new order).
- Links out: the apps open phone calls, email, Google Maps and Apple Maps (driver navigation) and web pages.
17Build release files
Use one settings file per app (for example .env.shopper) with API_BASE_URL on your live server, DEMO_LOGINS=false and SAMPLE_DATA=false. The version shown in the stores is version: 1.0.0+1 in pubspec.yaml: the part after + is the build number, which must go up with every upload (or pass --build-number=2).
Android: sign, then build
- Make an upload key once (keep the file and its passwords safe and backed up; one key can sign all three apps):
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload - Create
basketrun_mobile_flutter/android/key.properties(it is ignored by Git and never shipped):
Without this file, release builds are signed with the debug key, which the stores refuse.storePassword=the-store-password keyPassword=the-key-password keyAlias=upload storeFile=/full/path/to/upload-keystore.jks - Build an App Bundle for Google Play, or an APK to install by hand:
The files land influtter build appbundle --flavor shopper --dart-define-from-file=.env.shopper flutter build apk --flavor shopper --dart-define-from-file=.env.shopperbuild/app/outputs/bundle/shopperRelease/app-shopper-release.aabandbuild/app/outputs/flutter-apk/app-shopper-release.apk. Repeat withstoreanddriver.
iOS: archive and upload
- In your Apple Developer account, under Certificates, Identifiers & Profiles → Identifiers, register the three bundle ids with the Push Notifications capability. Xcode can do this for you with automatic signing.
- In App Store Connect, create the three apps (My Apps → + → New App) with those bundle ids.
- Build the archive and the IPA:
The IPA lands influtter build ipa --flavor shopper --dart-define-from-file=.env.shopperbuild/ios/ipa/. Upload it with Apple's Transporter app, or openbuild/ios/archive/Runner.xcarchivein Xcode and choose Distribute App. Repeat withstoreanddriver.
18Publish the three apps
Each app is published separately, under your own developer accounts and your own brand. Basketrun's demo names, ids and screenshots are not yours to publish.
Google Play
- In the Play Console, choose Create app three times (one per app).
- Fill in the store listing (name, descriptions, icon, screenshots), the content rating questionnaire, the target audience and the Data safety form. The apps use the location while open (address and driver position), the camera (barcode scan and delivery photo), photos the person picks, and name, email and phone for the account.
- Upload the
.aabto Internal testing first, then a closed test. New personal developer accounts must run a closed test with at least 12 testers for 14 days before Google lets them publish to production. - Let Google Play sign the release (Play App Signing, the default) and add its SHA-1 fingerprint to your Google Maps Android key if you use Google Maps.
App Store
- In App Store Connect, fill in each app's description, keywords, screenshots, support URL, privacy policy URL (your legal page
https://shop.yourbrand.com/legal/privacy) and the App Privacy answers. - The store and driver apps have no sign-up: Apple's review needs a working account. Make a test store with a picker and an approved test driver, and give both sign-ins under App Review Information. Explain in the review notes that the three apps serve three different people (shoppers, store staff, drivers) of one marketplace.
- The shopper app lets people delete their account (Account → Delete account), as Apple requires for apps with sign-up.
- Submit each build for review.
Links to your apps
Once an app is live, paste its store addresses in Super-admin → Settings → App links: the App Store address (https://apps.apple.com/app/id…) and the Google Play address (https://play.google.com/store/apps/details?id=…) of each app. The public home page then shows the shopper app's App Store and Google Play badges, the store app on its "For stores" card and the driver app on "Apply to drive" (the shopper app's page while the driver app has none). An app with no address shows no badge, so leave the fields empty until the apps are published.
Run the marketplace
Who uses what: you and your staff use the super-admin on the web (/platform); store owners and managers use the store panel on the web (/app) and can also use the store app; pickers use the store app; drivers use the driver app; shoppers use the shopper app. Everyone signs in at /signin on the web, or in their app.
19How an order works
The rules below are checked by the server, so the apps and the web pages can never get around them. Each later chapter shows where they appear.
- Address and zone. The shopper sets a delivery address on the map. It is served when its point lies inside one of your zones. Outside every zone, the app offers "Tell me when you deliver here" and adds the shopper's email to your waitlist.
- One store per cart. The shopper picks a store that delivers to the zone and adds items. Adding an item from another store asks to start a new cart. For every item the shopper chooses what the picker does if it is out of stock: best match (the closest item on the shelf), a specific product they pick ahead, or refund me.
- Express or a slot. Express is offered when the zone and the store allow it and the store is open now. Its time range is the store's picking time plus the ride (counted at 18 km/h), kept within the zone's fastest and slowest promise. Otherwise the shopper picks a scheduled slot: today and the next six days, inside the store's opening hours, with a set number of orders per store in each slot. Booking a slot closes a set number of minutes before it starts, and a full slot is refused.
- Checkout. The zone's minimum order applies; delivery is free over the zone's threshold. A coupon, a tip and the platform's service fee are added. The shopper pays by card (Stripe Checkout), cash on delivery (if the platform, the zone and the store allow it, up to the zone's cash limit) or with wallet credit, which can cover part or all of it.
- Paid, then placed. A card order waits until Stripe confirms the payment; unpaid after about 30 minutes, it is cancelled and its slot, coupon, wallet credit and stock are released. Cash and wallet orders are placed at once.
- The store answers. The new order rings in the store app and on the store panel's board. The store accepts or declines; declining cancels the order and gives back any money paid. An express order nobody answers within 2 minutes is declined by itself, and the shopper is told where the money went. The shopper can cancel for free until the store accepts.
- A driver is found. For express orders as soon as the store accepts, for scheduled orders 30 minutes before the slot. The job is offered to the nearest online, approved, free driver of the zone for 30 seconds; declined or missed, it goes to the next driver.
- Picking and swaps. The picker scans each item. When an item is missing, the picker proposes a swap or marks it to refund. The shopper has 5 minutes to approve or refuse a swap; with no answer, their choice decides (best match or specific: approved; refund me: refused). Until the order is packed, the shopper can still add items.
- Packed and handed over. The picker marks the order ready with the number of bags and the shelf. The driver arrives, checks the bags and the store hands them over: the order is on its way, with the driver on the shopper's map.
- Delivered. The driver proves the delivery with the shopper's 4-digit delivery code or a photo, and on a cash order confirms the cash taken. The shopper can then rate the store and the driver, once per order.
The shopper pays the lower of the two prices. A cheaper swap gives the difference back at once; a refused swap or a missing item gives the whole line back.
Missing items, refused swaps, the difference of cheaper swaps and cancelled paid orders are refunded to the shopper's wallet at once (or to the card, if you choose that in Settings, chapter 8). The wallet only ever gets money from refunds and from top-ups the shopper paid by card ($5 to $200). It can never go below zero, and its credit is spent only on orders: it cannot be paid out.
Who earns what on a delivered order
| Party | What they get |
|---|---|
| Shopper pays | Items at their deal prices − coupon + delivery fee (free over the zone's threshold) + service fee + tip. |
| Store earns | Its item sales − the commission (default 15%, set per store) − refunds of its items. Delivery fees and tips never count as store sales. |
| Driver earns | The zone's driver pay per trip + 100% of the tip. |
| Platform keeps | Commission + delivery fee + service fee − driver pay − coupon discount. Coupons are paid for by the platform. |
On a cash order the driver holds the cash; the weekly payouts report takes it off what the driver is owed (chapter 26).
Order statuses
| Status | Meaning |
|---|---|
| Waiting for payment | A card order whose Stripe payment is not confirmed yet. Only the shopper sees it. |
| New | Placed and paid (or cash); waiting for the store to accept. |
| Accepted | The store took it; picking has not started. |
| Picking | A picker is filling the bags. |
| Ready | Packed, waiting for the driver. |
| On the way | The driver has the bags. |
| Delivered | Proved by code or photo. |
| Cancelled | By the shopper (before the store accepted), the store (declined), you, or because the card was never paid. Money paid comes back. |
Every change is pushed live to the shopper, the store and the driver, and sends a push notification where it matters.
20Super-admin
The super-admin is your side of the marketplace, under /platform. The install wizard makes you its first admin.
Overview
Orders, sales (GMV) and commission today, drivers online, the live orders, the late orders (running past their promised time), new store applications, today's figures per store and a needs attention list: applications to review, drivers waiting for approval, documents missing, failed background jobs and setup rows that need a look. The sidebar shows the count of applications, drivers waiting and late orders.
People
Everyone who can sign in: shoppers, drivers and store staff, with their stores and roles. From a person's menu you can:
- Make super-admin (can change every setting and store, and add other admins) or Make platform viewer (read-only: sees every store, shopper and driver, but changes nothing). Remove platform access takes it away again.
- Make a driver or make a shopper: the person then signs in to the other app. Useful when someone who signed up in the shopper app wants to drive.
- Suspend: they are signed out everywhere and cannot sign in until you restore them; their stores keep running.
21Zones and fees
A zone is an area on the map where you deliver, with its own fees and rules. Super-admin → Zones shows every zone on the map with its delivery fee, minimum order, stores and today's orders. Shoppers outside every zone can join the waitlist, which the same page shows under Outside every zone (with Export list), so you can see where to open next.
Draw a zone
- Choose New zone, name it and drag the corners over the streets you deliver to. A zone needs at least three corners; the page tells you whether it touches other zones. You can also paste GeoJSON (a Polygon, a Feature or a FeatureCollection; the first polygon is used).
- Set the fees and limits, express and slots below, and save. Changes apply to new orders; open orders keep the fee they were quoted.
| Setting | What it does |
|---|---|
| Delivery fee | What the shopper pays for delivery in this zone. |
| Free delivery over | Orders with items at or above this amount deliver free. Empty: never free. It cannot be lower than the minimum order. |
| Minimum order | The smallest basket the zone accepts ($0 for none). The cart tells the shopper how much more to add. |
| Driver pay per trip | What a driver earns for each delivery here, plus 100% of the tip. |
| Cash on delivery | Not allowed (card and wallet only), or allowed up to $50, $100 or $200 per order. |
| Express delivery | On or off, with the fastest and slowest promise in minutes (for example 15 to 30). |
| Scheduled slots | The slot length (30 minutes, 1 hour or 2 hours) and the orders per slot, per store. A store may lower its own number on short-staffed days. |
| Stores delivering here | The stores that serve the zone, with Add a store. |
Aisles
Aisles (Fruit and vegetables, Dairy and plant milk, Bakery…) are shared by every store: each product is filed under one, and they give the shopper app its aisle tiles and the pick list its order. A fresh install comes with ten standard aisles, the same ones the sample city uses. Super-admin → Aisles lists them in the order shoppers and pickers see them: add one, edit its name, its shorter pick-list name and its icon, move it up or down, or hide it. Deleting an aisle keeps its products, without an aisle, so move them to another aisle first.
22Stores and applications
Super-admin → Stores lists every store with its owner, zone, type, rating and this week's sales, commission and what is owed to it, with tabs for applications and suspended stores.
How a store joins
- It applies. The public page
/sell("Sell with us") takes the store's name, type, address, phone, website, the contact person, how they sell today, roughly how many products, their opening hours and their documents (licence and permit). The application shows under Applications. Open it to see the details and documents, then:- Approve: choose the commission (the platform default is filled in) and the zone. This creates the store and its owner's account and emails the owner a sign-in link to the store panel that works for 7 days.
- Ask for documents: the applicant gets an email asking for what is missing and can reply for 30 days.
- Decline: with a reason of at least a sentence, which is emailed to the applicant.
- You add it. Add a store takes the store's name, type, street address, zone, the owner's name, email and phone, and the commission, and emails the owner a sign-in link.
- It signs up on the web. Only while Settings → Sign-ups is open: each sign-up at
/signupcreates a store straight away. For a marketplace where you check every store, set Sign-ups to closed and let stores apply on/sellinstead.
Shoppers see a store once it is approved and has at least one product shown in the app. Before that, its owner should add the opening hours and invite a picker, or orders arrive with nobody to pick them.
A store's sheet
- Commission on item sales: this store's own rate, replacing the platform default. It applies to orders placed after you save.
- Payout schedule (weekly, every two weeks or monthly, on Fridays) and the bank account the store entered.
- The owner, address, zones, catalogue size, rating, team, documents and its last four weeks of payouts.
- Open as owner: a 30-minute session as the store's owner, to see exactly what they see when they ask for help. A banner with an Exit button stays on screen.
- Suspend with a reason the owner sees (for example "food permit expired"). Shoppers stop seeing the store at once; open orders still finish and are paid out as normal. Restore brings it back.
23Drivers
Super-admin → Drivers shows who delivers and what each driver is doing now: online and waiting for an offer, heading to a store, delivering, or late. Tabs: online now, approved, waiting for approval and suspended, with filters for zone and vehicle, and the cash each driver holds.
Add a driver
- Invite a driver with their email (and their zone). They get an email with a link to choose a password (it works for 7 days) and an account that waits for your approval. Someone who already has a shopper account can instead be switched in People → Make a driver.
- Open the driver's sheet when their documents are in. Ask for documents marks each missing one on their sheet and sends them an email and a notification.
- Approve them, and set their zone, vehicle and plate. Only approved drivers get offers. You can also reject an application.
Rules for drivers
- A driver gets offers only while online in the driver app and seen in the last 15 minutes, in their own zone, with no other offer or job.
- Each offer lasts 30 seconds. A driver who declines or lets it run out is not asked about that order again for 3 minutes; it goes to the next nearest driver.
- A driver can hand a job back before picking up the bags; it goes back to dispatch and counts against their acceptance, which the sheet shows over 30 days with their recent trips.
- Suspend: the driver goes offline at once and gets no more offers. A job not picked up yet goes back to dispatch; an order already in their car stays with them until it is delivered.
24Orders, refunds and customers
Orders
Super-admin → Orders holds every order across the stores, with tabs for today, open, late, delivered and cancelled, filters for store, zone, payment and date, search by order number, shopper or phone, and CSV export. Late orders are tinted red. The order sheet shows the lines and swaps, the money, the shopper, the driver, the card, the zone and each step with its time.
- Cancel any order that is not delivered yet, with a reason. Money paid goes back.
- Refund: tick the lines to refund (with a reason) and, if you like, the delivery fee, then choose to the wallet (at once; they can spend it on their next order) or to the card (Stripe sends it back in 5 to 10 working days).
The refund is marked first, then Stripe is asked. If Stripe refuses, nothing changes and you can try again or refund to the wallet instead. If Stripe cannot be reached, the refund stays marked and is sent again by itself with the same key, so it is never paid twice.
Customers
Super-admin → Customers lists every shopper with their orders, spend, last order, zone and wallet credit, with tabs for this month, this week and blocked. Block a shopper with a reason kept on their record (for example "2 chargebacks"): they are signed out everywhere and cannot place new orders; orders already placed still finish.
25Coupons
A coupon gives shoppers money off at checkout. The platform pays for it: the store still earns its full item sales. Super-admin → Coupons lists them with tabs for active, paused and ended, and this month's uses, discount given and the codes turned away at checkout with the top reason.
| Field | What it does |
|---|---|
| Code | Letters and numbers, 4 to 16 long. Shoppers type it at checkout; capitals don't matter. |
| Discount | Percent off the items (with an optional "up to" cap), amount off the items (never more than the items), or free delivery. |
| Minimum order | Items only, before delivery and tip. Below it, the shopper is told how much more to add ("Add $4.20 more to use SAVE5"). |
| Starts and Ends | Empty start: usable at once. Empty end: no end date. The end is 23:59 in the platform's time zone. |
| Total uses and Uses per shopper | Empty total: no limit. |
| First order only | Only for shoppers with no paid or delivered order yet. |
| Works at | Every store, or only the stores you pick. |
The server checks every rule again when the order is placed, so two shoppers using the last use at once cannot both get it. A cancelled order gives its coupon use back. Deleting a coupon nobody used removes it; a coupon that was used is ended instead, so its history stays.
26Payouts
Super-admin → Payouts shows what the platform owes each store and each driver for a week (Monday to Sunday in the platform's time zone), paid on the Friday after it.
| Who | How the amount is worked out |
|---|---|
| Each store | Its delivered orders' item sales − the commission on them − item refunds = owed. |
| Each driver | The zone fees of their deliveries + all their tips − the cash they collected on cash orders = owed. Below zero, the driver holds more cash than they earned and owes the platform the difference. |
- Pick the week. The cards show what is owed to stores and drivers, the commission kept and the cash drivers hold.
- Pay each store and driver yourself, for example by bank transfer to the account they entered.
- Tick the rows you paid and choose Mark as paid. Each row is recorded once per week; marking it again changes nothing. A driver's cash from a paid week no longer counts as held. For a driver who owes you, Mark as collected once they hand over the cash.
Card payments land in your own Stripe account. The payouts report tells you who to pay and how much; the transfers to stores and drivers are yours to make.
27Settings and legal pages
Super-admin → Settings applies to every store, shopper and driver on the platform.
| Section | What it sets |
|---|---|
| General | The platform name, support email, currency, time zone and default commission, with a summary of payments and email. |
| Payments (Stripe) | Stripe keys, the webhook, the service fee, cash on delivery and where refunds go (chapter 8). |
| Maps | OpenStreetMap, MapTiler or Google Maps, and their keys (chapter 11). |
| Push (FCM) | The Firebase service account (chapter 12). |
| Email (SMTP) | The mail server, a test email and the wording of each platform email (chapter 9). |
| Legal pages | The six legal pages (below). |
| Demo mode | Shows whether this server runs as a public demo. It is switched in .env only (chapter 35). |
| Branding | Product name, logo (square PNG, SVG or WebP, at least 256 × 256, up to 1 MB; also the favicon), brand colour (buttons, links, focus borders; the app works out the lighter and darker shades), support email, Documentation URL and Support URL. They show in the web app, the emails, the public site and the browser tab without a rebuild. The phone apps keep the colours built into them (chapter 16). |
| Storage | Where files are kept, the room per store and per person, and a test (chapter 10). |
| Sign-ups | Who can create a store on the web: open (anyone, each sign-up makes a store), invite (the sign-up page is hidden; people join only through a store's team invite) or closed. Shoppers always sign up in the shopper app; stores can always apply on /sell. |
| App links | The App Store and Google Play addresses of your three apps, for the badges on the public home page (chapter 18). |
| Maintenance | Shows the maintenance page with your message to everyone except super-admins; the background job counts and the last migration; and Remove demo data. |
Legal pages
Six pages in Markdown, each with a live preview, shown at /legal/terms, /legal/privacy, /legal/cookies, /legal/refunds, /legal/store-terms and /legal/driver-terms, and linked from the public site, the sign-up pages and the apps. Starter texts for all six are in apps/backend/seed/legal/; loading the sample city puts them in for you, or paste each file into its tab. They are written for the sample city: replace "Basketrun" and "Lakeport" with your own names, and have them checked by a lawyer for your country. They are your agreement with your shoppers, stores and drivers.
28Store panel: overview and live orders
The store panel at /app is where a store's owner and managers run their store. Pickers use the store app instead. What each role may do:
| Can | Picker | Manager | Owner |
|---|---|---|---|
| Pick, scan, offer swaps | Yes | Yes | Yes |
| Accept orders, pause the store | In the store app | Yes | Yes |
| Products, stock, CSV import | No | Yes | Yes |
| Hours, slots and express | No | Yes | Yes |
| Reports and sales | No | Yes | Yes |
| Staff, store settings, payouts | No | No | Yes |
Overview
Today's orders and sales, the on-time rate, swaps approved, orders by hour, what is selling fast, the pickers on shift and a Needs you list (new orders, low stock).
Live orders
The board has four columns: New (each with its answer countdown), Picking, Ready (packed, waiting for the driver) and Out for delivery, with a filter for express or scheduled orders and a search. New orders play a chime and show a browser notice (each browser can mute it). Opening an order shows:
- the delivery (express with its promised time, or the slot), the payment (card, wallet or cash to collect) and the timeline;
- Accept or Decline (with a reason; the shopper is told and refunded);
- the picker (change who picks it), the lines by aisle with swaps, a printable pick list;
- Mark ready with the number of bags and the shelf, once every line is picked and no swap waits;
- the driver, or "finding a driver" with how many were offered the job, and Find another driver before pickup.
A new express order must be answered within 2 minutes, which the countdown shows. With no answer it is declined by itself ("…didn't answer in time"), and the shopper's money goes back the usual way (wallet or card, as Settings → Payments says). Scheduled orders wait for an answer. Express orders are offered to drivers when the store accepts; scheduled orders 30 minutes before their slot.
29Store panel: catalogue, CSV import and stock
Products
Products holds everything shoppers can order, with tabs (all, low stock, out of stock, hidden), an aisle filter and a search by name or barcode. Add products one by one, import a spreadsheet, or export from a till (Square, Clover or Lightspeed) and import that. Each product has:
| Field | What it does |
|---|---|
| Name, unit label, aisle, description | What the shopper sees. The unit label shows under the name ("12 large eggs", "1 lb"). |
| Price and Was price | Fill the was price (higher than the price) to show the item as on sale. |
| Sold by weight | A price per pound; the picker types the weight at the shelf. |
| Barcode | EAN-13, UPC-A or a PLU. Pickers scan it to confirm the item. |
| Track stock, In stock, Warn me at | The count on the shelf and the level that puts it under Needs you. Off: always shown in stock; pickers mark it missing if the shelf is empty. |
| Allow swaps | When it runs out, pickers may offer a similar item. The shopper approves, and never pays more. |
| Show in the app | Off hides it from search and the aisle; open orders keep it. |
| Product photo | JPG, PNG or WebP, up to 5 MB. |
Import a spreadsheet (CSV)
Catalogue → Import updates prices and stock, or adds new products, from a CSV file (from Excel: Save as → CSV; files with ; between cells are read too). Up to 5,000 rows and 5 MB a file. Nothing changes until you press Import.
- Upload the file. The columns are matched by their header:
name,unit,aisle,price,was_price,qty,upcandphoto_url, and their usual names in tills and spreadsheets (product,category,retail_price,stock,barcode,ean,plu,image…). Change any match by hand. - Check the file. Every row is checked: a name, a price, an aisle that is one of the aisles, a stock count that is a whole number of 0 or more, a was price above the price, and no barcode used twice. Rows that need a fix are listed with the reason; Download the rows gives them back as a CSV with a
what_is_wrongcolumn to fix and upload again. - How rows match: a row is the same product when it has the same barcode, else the same name in the same aisle. Matches are updated (the page counts the price changes); the rest are added.
- Two options: Hide products that aren't in the file (shoppers stop seeing them until you show them again) and Set stock to 0 for rows with qty 0 (off: a qty of 0 leaves the stock as it is).
A starting file looks like this:
name,unit,aisle,price,was_price,qty,upc,photo_url
"Large brown eggs, 12 pcs",12 large eggs,Dairy and plant milk,4.29,4.99,24,072745060124,
Bananas,"bunch, about 1.1 kg",Fruit and vegetables,1.69,,64,PLU 4011,
Stock
Stock lists every product with its count, what sold in 7 days and whether it needs restocking. Type the new count and save; shoppers see it at once. The stock rules: Lower stock when an order is picked, Hide items at 0 (off: they stay in the app marked Out, and shoppers can pick a swap ahead) and a low-stock email at 7:00 to the owner and managers with the restock list. The page also lists today's swaps from empty shelves.
30Store panel: hours, team, reports and settings
Hours and slots
Shoppers can order while the store is open. Express needs the store open now; scheduled slots are made from these hours.
- Opening hours for each day of the week, or closed all day.
- Holidays and special hours: a name and a date, closed all day or other hours, with express on or off that day.
- Taking orders: Accepting orders (off: the app shows the store as closed until it is turned back on) and Cash on delivery (off: card or wallet only).
- Express delivery: on or off, the time to pick an average order (added to the drive time for the time the app shows) and pause express when this many wait (shoppers then see slots only; 0 never pauses).
- Slots: stop booking before a slot (pickers need time to pick before the driver comes) and the orders per slot for each zone, up to the zone's own limit, with how full the coming slots are.
Staff
Staff lists who works in the store, who is on shift now, orders picked today, the average pick time and swaps offered today. Invite someone by email as a manager or a picker (only the owner invites managers). Pickers get an email with a link to the store app; managers a link to this panel and the store app. Open invites show until they join, with resend and cancel. A store keeps at least one owner.
Reports
For this week so far, the last full week or the last 30 days: sales, orders, what the store keeps after commission and refunds, the on-time rate, sales by day, best sellers, the zones orders went to, refunds by reason, ratings and when the range is paid out.
Store settings
- Store profile: name, type (shoppers filter by it), about text (up to 400 characters) and the cover photo shown on the store page in the app (wide, at least 1200 × 600).
- Location and pickup: the address and its pin on the map (drag it if drivers end up at the wrong door; a change asks the platform to check the zone), the store's time zone (opening hours, slots and reports follow it), the phone for drivers and support, and pickup notes for drivers.
- Orders and payments: accept cash on delivery (up to the zone's limit), pickers may offer swaps (off: a missing item is refunded, never swapped) and ask before accepting big orders (orders over an amount ring for a manager to accept).
- Notifications: ring for new orders, a daily summary email after closing, the low-stock email.
- Bank and payouts: the bank account, the commission, the next payout and what was paid.
- Pause or close: pause new orders, or close the store for good (type its name to confirm). Shoppers can no longer order; open orders still finish; the team loses access; sales history is kept for 7 years and photos and files are removed after 30 days.
- Your profile: name, picture and password (changing it signs you out everywhere else).
31Shopper app
- Start: a welcome, then the delivery address: use the phone's location or search an address and set the pin. Outside every zone, the app offers the waitlist. Shoppers can browse without an account; adding to the cart asks them to sign in or sign up, then adds the item.
- Home: the express banner, aisles, the stores that deliver to the address, deals, "buy again" and the order on its way.
- Stores, aisles and search: a list and a map of stores with their rating, delivery time and fee; a store page with its aisles, deals, popular items and next slot; search across stores with recent and popular searches.
- Product page: photos, price and deal, origin and storage, similar items, a heart to save it, and the swap to pick ahead.
- Cart: one store at a time, each line with its swap choice, the minimum order, how far to free delivery, the coupons that work for the basket and the totals.
- Checkout: the address, the delivery time (express or a slot), a coupon, a tip for the driver, a note for the picker and the payment: card (Stripe Checkout opens, then the app comes back), cash on delivery or wallet credit.
- After ordering: live progress (accepted, items picked so far, packed), swap requests to approve, refuse or change with the 5-minute countdown, "add items" while the order is being picked, the driver on the map with the arrival time, the 4-digit delivery code to show the driver, a chat with the store and the driver (open until 2 hours after delivery), the receipt and the rating.
- Account: orders with reorder, the wallet (balance, refunds and top-ups; top up $5 to $200 by card), saved addresses, notifications, the default swap choice, which updates send a push, and deleting the account (the password is asked; the account goes for good after 30 days).
32Store app (pickers)
- Orders board: new orders that ring until someone answers (an express order within 2 minutes, or it is declined by itself), orders being picked, packed orders waiting for the driver and swaps waiting for the shopper. Pause new orders shows the store as busy to shoppers; orders already taken stay on the board.
- New order: the items, the delivery (express or the slot) and the pick-by time, with Accept order or decline (with a short note for the platform; the shopper is told and refunded).
- Pick list: the lines by aisle with the shopper's note. Scan opens the camera, which reads each barcode by itself: a match ticks one unit, a wrong item says what was scanned and changes nothing. A code that will not scan can be typed, or the line ticked by hand after a check.
- Missing item: offer a swap from the store's own in-stock items (the shopper pays the lower price) or refund the line. While a swap waits, the picker can message the shopper; a refused swap is left out and refunded.
- Ready: the bag count and the shelf, then wait for the driver. When the driver comes, check them and hand over the bags; if the driver is late, ask for another.
- Today: orders done, items picked and the average pick time. Store: the accepting-orders switch; hours, stock, prices and the team are managed in the store panel.
33Driver app
- Home: offline, it shows the driver's zone, vehicle and how busy the zone is; online, it shows the zone, the nearest open store and the next offer when it rings. While online, the app sends the driver's position every few seconds, so offers come from stores nearby. "Ring loud for offers" plays even when the phone is on silent. The zone and the vehicle are changed by the platform (Drivers in the super-admin).
- Offer: 30 seconds to accept, with the pay (the delivery fee plus the whole tip), the store, the drop-off area (the full address shows after accepting), the distance and, on a cash order, the cash to collect at the door.
- Job, in three steps: pick up (navigate to the store, tap arrived, say the order number at the counter), check the bags (the count the store packed), and deliver (navigate to the door, chat with or call the shopper through a masked number, follow their note). The job can be handed back before the pickup.
- Proof: the shopper's 4-digit delivery code (three tries; after that, a photo) or a photo of the bags at the door. On a cash order, the driver types the cash taken, and the app shows the change to give back.
- Earnings: today and this week, fees, tips, cash collected, cash held (taken off the next payout), the next payout and every trip, with a CSV download.
The sample city
34Lakeport, the sample city
Lakeport is a small lakeside town with everything a marketplace needs, so you can try every screen before you add your own stores. Its zones, store pins and addresses sit on the real street grid of Lakeport, California (map data © OpenStreetMap contributors).
- Three zones: Harbor and Old Town ($1.99 delivery, free over $35, express and scheduled slots) and North Hills ($4.99, free over $50, scheduled slots only).
- Three stores with their hours, teams and pictures: Harbor Fresh Market (full grocery), Green Basket Organics (organic grocery) and Corner Pantry 24/7 (convenience).
- Ten aisles and 182 products with prices, deals, barcodes and stock, with a few items out of stock, one of them there to show a swap.
- Seven coupons (for example
SAVE5,FIRST5,FREEDELandHARBOR10), store applications and a waitlist. - People: Ava the shopper, Nora who owns Harbor Fresh Market, Maya who picks there, Leo the driver, Owen the read-only platform admin, eight more store staff, seven more drivers and about 55 more shoppers.
- Orders: eight weeks of delivered history (with a few cancellations, refunds and swaps, ratings and driver earnings) and today's live orders at every step, so the reports, payouts and boards have something to show.
- The six starter legal texts, when you have saved none yet.
Load it
docker compose exec app basketrun seed-demo --confirm
It answers seeded: {…} with what it added. Every row it adds is marked as sample data. --confirm is needed once your install has a real account (the super-admin the wizard made); without real accounts the command runs without it. Running it a second time changes nothing. As the super-admin you see the sample stores, drivers, orders and payouts at once; Open as owner on a store's sheet shows its store panel.
The sample people have no passwords, so nobody can sign in as them outside demo mode, and the sample orders do not move on their own outside demo mode. Load the sample city on a test copy to explore, or remove it before you open to the public. To try the three apps with it, use a test copy in demo mode (next chapter).
Remove it
Super-admin → Settings → Maintenance → Remove demo data. Only rows marked as sample data are deleted: the sample stores, people, zones, coupons, applications, waitlist, orders and their files. It stops if a sample store has a real payment. It cannot be undone. Two things stay: the aisles (they suit any store) and the legal pages (they are your settings; edit them in Settings → Legal pages).
Photos
The download comes without the sample photos: the sample products, stores and aisles show a plain placeholder in the apps and on the web. To show pictures, put your own in apps/backend/seed/photos/ with products/, stores/ and aisles/ inside, named as in apps/backend/seed/lakeport.json (for example products/hass-avocados.webp). Then rebuild with docker compose up -d --build, remove the sample data and load it again. A missing picture is simply skipped. To change the sample city itself, edit lakeport.json (or point DEMO_CATALOG at your own file of the same shape, and DEMO_PHOTOS at its pictures).
35Demo mode and the seed commands
Demo mode
DEMO_MODE="true" in .env turns an install into a public demo, like the item's live preview. Never turn it on for a real marketplace; the shipped file has it "false". With it on:
- The sample city is loaded at start and removed and loaded again every night at 03:00 UTC.
- The sign-in pages show one-click sign-ins: on the web the store owner, the picker and the read-only platform admin; in each app (built with
DEMO_LOGINS=true) that app's people: the shopper, the store team or the driver. One address can use them 60 times an hour. - Simulated drivers stay online in Lakeport, take offers after a few seconds, ride along real streets to the store and the door and deliver with the shopper's code, so the maps always move. A driver someone is using in the driver app is left alone.
- Payments go through the test checkout page instead of Stripe, no push notifications are sent, the install wizard is off, secrets show only as set or not set, and the platform admin can look but not change anything.
Settings → Demo mode shows whether it is on. To turn it off, set DEMO_MODE="false" and restart the app (docker compose up -d); the sample data stays until you remove it.
Seed commands
| Command | What it does |
|---|---|
docker compose exec app basketrun seed-demo | Adds the sample city, every row marked as sample data. It only adds rows and never deletes anything. It refuses a database with any real account or store; --confirm adds the sample city next to real data anyway. |
docker compose exec app basketrun reset-demo | Removes the sample data and adds it again. It refuses to run when the database holds any real account or store, with no way round it. |
| Super-admin → Settings → Maintenance → Remove demo data | Deletes only rows marked as sample data (see above). |
docker compose exec app basketrun migrate | Applies the database migrations and stops (the server also does this on every start). |
Real accounts, stores, orders and payments are never marked as sample data, so no seed or reset command can touch them.
Security
36Security notes
What the server checks and limits, so you can answer your stores' and shoppers' questions and know what to keep safe.
Stores and people are kept apart
- The current store always comes from the signed-in session, never from the request. Every query is filtered by it, and another store's order or product answers "not found".
- Roles (owner, manager, picker; super-admin, viewer; shopper, driver) are checked by the server on every request; the screens only hide what a role cannot use. Each app accepts only its own kind of account.
- Drivers see only the store and the drop-off area (the street without its number) before they accept, and the full address after. Drivers and shoppers see each other's phone number only as its last four digits, and talk in the order chat. In orders, drivers and stores, the read-only viewer sees shoppers' and drivers' names, emails, phones and street numbers masked.
Accounts and sessions
- Passwords (at least 10 characters) are hashed with Argon2id. A password change or reset signs the person out on every other device.
- On the web, the
br_sessioncookie is HttpOnly, Secure on https and SameSite=Lax; it lasts 30 days and is renewed while in use, or only until the browser closes when "keep me signed in" is off. Every change made with the cookie must carry the headerx-basketrun: 1, which other sites cannot add, so they cannot act for a signed-in person. - The apps sign in with a token sent as
Authorization: Bearer. It lasts 90 days, is renewed while the app is used, and is kept in the phone's secure storage (the iOS Keychain, the Android Keystore). - Session tokens, reset links and invitations are stored only as SHA-256 hashes.
- The secrets you save in the super-admin (Stripe, SMTP, storage, the Firebase service account) are encrypted with AES-256-GCM, with a key derived from
APP_SECRET. KeepAPP_SECRETand your backups safe, and never change it after the install. - "Open as owner" sessions last 30 minutes and show a banner with an Exit button.
- Deleted accounts and closed stores are removed for good after 30 days. Orders stay for the books, with the personal details of a deleted account blanked.
Money
- Card orders, add-ons and top-ups are confirmed only by Stripe events with a valid signature and timestamp, each applied once. Refunds go to Stripe with an idempotency key, so a retry never pays twice.
- The wallet changes only in one guarded database update with a unique key per movement: a refund or a spend tried twice counts once, and the balance can never go below zero.
- Slots, coupons and stock are checked again inside the transaction that places the order, with locks, so two shoppers can never take the last slot place, the last coupon use or the last item together. Accepting and declining one order at once, approving one swap twice or two drivers accepting one job: exactly one goes through.
Rate limits
These limits are kept in PostgreSQL, so they hold across restarts and several copies of the server. They are keyed by a keyed hash of the account or the visitor address (taken only from trusted proxies, chapter 5), never by a plain address:
| Limit | Allowed | What it protects |
|---|---|---|
| Sign-in, per address | 20 per 15 minutes | Sign-in attempts from one address |
| Sign-in, per account | 5 per 15 minutes | Wrong passwords for one account; after five the account waits, even for the right password |
| Sign-up, per address | 5 per hour | New accounts from one address |
| Password reset, per address | 5 per hour | Password reset emails asked for from one address |
| Password reset, per account | 3 per hour | Password reset emails sent to one account |
| Reset and invite links, per address | 20 per hour | Tries at a reset or invite link from one address |
| Demo sign-in, per address | 60 per hour | Public demo sign-ins from one address |
| Invites, per store | 50 per hour | Invites sent by one store |
Every other API call takes from short-term allowances in memory: each signed-in person may make 240 calls at once and then 20 a second, and all calls from one visitor address together (counted only behind a trusted proxy) 1,200 at once and then 60 a second. The Stripe webhook is never limited. A refused call answers 429 with a Retry-After header.
Uploads and files
- Uploads are checked by their content, not their name (chapter 10), and count against the room of their store or person. The logo may be PNG, WebP or SVG; an SVG with scripts is refused.
- Product, store and aisle pictures are public (shoppers see them before signing in). Delivery photos, profile pictures and application documents are served only to whoever they belong to and to the platform staff.
What loads from other servers
The web app's fonts and icons are part of the build. Map tiles load from the map provider you chose (OpenStreetMap, MapTiler or Google in the apps), which sees the visitor's address like any map. Address searches go through your server, so the provider sees your server, not the shopper. Stripe Checkout opens on Stripe's own pages. Push notifications go through Firebase.
Keep it safe
- Use https (chapter 5), long unique passwords and two-factor sign-in on your Stripe, Firebase, Apple, Google, email and server accounts.
- Keep
.env, the apps'.envfiles,android/key.properties, the upload keystore, the Firebase service account file and your backups private. - Install Basketrun updates; security fixes are marked as such in the changelog.
For developers
37Every server key, explained
Every setting in the server's .env. The outside-service keys can also be set in Super-admin → Settings, which takes precedence. This table is generated from .env.example and the server's own settings code when the release is built. The apps' keys are in chapter 15.
| Key | Required | What it does |
|---|---|---|
| Required | ||
APP_URL | Yes | The public address of the app, without a trailing slash, for example https://shop.example.com. Links in emails, the Stripe webhook address and secure cookies come from it. Use https on a public server. |
APP_SECRET | Yes | A long random string of at least 32 characters (openssl rand -hex 32). It encrypts saved keys and keys the hashed visitor addresses of the rate limits. Never change it after the install: saved keys could no longer be read. |
POSTGRES_DB | No | The name of the database the stack creates. Default basketrun. |
POSTGRES_USER | No | The database user the stack creates. Default basketrun. |
POSTGRES_PASSWORD | Yes | The database password. Letters and digits only, because it goes into a connection address. |
DATABASE_URL | Outside Docker | The database address, only when you run the server without Docker. Leave it empty with Docker: the stack builds its own from the three keys above. |
INSTALL_TOKEN | No | The token the install wizard asks for. Empty: a new one is printed in the app's log on first start. |
| File storage (product photos, store pictures, profile photos, logo) | ||
STORAGE_DRIVER | No | s3 (the bundled MinIO, AWS S3 or Cloudflare R2) or local (files in a Docker volume). Default in Docker s3. |
S3_ENDPOINT | With s3 | The storage address. The bundled MinIO is http://minio:9000; for R2 use your account's S3 address; for AWS S3 leave it empty. |
S3_REGION | No | The bucket's region. Default us-east-1; R2 uses auto. |
S3_BUCKET | No | The bucket name. Default basketrun; the stack creates it in MinIO. |
S3_ACCESS_KEY_ID | With s3 | The storage access key. With the bundled MinIO this is also its admin user. |
S3_SECRET_ACCESS_KEY | Yes | The storage secret, at least 8 characters. With the bundled MinIO this is also its admin password, so Docker refuses to start without it. |
LOCAL_STORAGE_DIR | Set by Docker | The folder for files with STORAGE_DRIVER=local (/app/storage in Docker, a volume). |
| Payments (Stripe; empty = card payments off) | ||
STRIPE_SECRET_KEY | For card payments | Your platform's Stripe secret key (sk_live_…, or sk_test_… while testing). Empty: card payments are off. |
STRIPE_WEBHOOK_SECRET | For card payments | The signing secret (whsec_…) of the webhook endpoint you add in Stripe for APP_URL/api/v1/webhooks/stripe. |
STRIPE_PUBLISHABLE_KEY | For card payments | Your Stripe publishable key (pk_live_… or pk_test_…), for Stripe's card form at checkout. |
| Maps (default: OpenStreetMap, no key) | ||
MAP_PROVIDER | No | Which map the apps and the web pages draw: osm (free, no key, light use only), maptiler or google. MapTiler and Google charge after a free monthly allowance (see the docs, "Maps"). These keys are public: they ship in the web pages, and the server uses them for address search. If you restrict a key in the provider's console, allow your domain AND your server's IP address, or address search stops working. |
MAPTILER_KEY | No | Your MapTiler key (cloud.maptiler.com → Account → Keys), used when the provider is maptiler: map tiles in the apps and web pages, and address search on the server. It is public: it ships in the apps and the web pages. Super-admin → Settings → Maps takes precedence. |
GOOGLE_MAPS_KEY | No | Your Google Maps server key, used when the provider is google: address search (Geocoding API) on the server. Restrict it to the Geocoding API and your server's IP address. The apps take their own Android and iOS keys in their .env. Super-admin → Settings → Maps takes precedence. |
| Push messages (Firebase Cloud Messaging; empty = push off) | ||
FCM_PROJECT_ID | No | Your Firebase project id and its service account key (Firebase console → Project settings → Service accounts → Generate new private key), pasted as one line of JSON. You can paste the file in Super-admin → Settings instead. |
FCM_SERVICE_ACCOUNT_JSON | No | Your Firebase service account key (Firebase console → Project settings → Service accounts → Generate new private key) as one line of JSON, with FCM_PROJECT_ID. Empty: no push messages. Easier: paste the file in Super-admin → Settings → Push, which takes precedence and stores it encrypted. |
| Email (SMTP; empty = emails are written to the app's log) | ||
SMTP_HOST | For email | Your email provider's SMTP server. Empty: emails are written to the app's log instead of being sent. |
SMTP_PORT | No | The SMTP port. Default 587. |
SMTP_USERNAME | For email | The SMTP user name. |
SMTP_PASSWORD | For email | The SMTP password or API key. |
SMTP_SECURE | No | starttls (port 587, the default), tls (port 465) or none. |
SMTP_FROM | For email | The sender, for example Basketrun <hello@example.com>. Use an address on a domain your provider has verified. |
| Network | ||
APP_PORT | No | The port on this server where the app answers. Default 8080. |
APP_BIND | No | Which address the port is open on. Default 127.0.0.1: this server only, so visitors come in through Caddy or your own proxy. Use 0.0.0.0 only with TRUSTED_PROXY_HOPS=0 or a firewall that lets only your proxy reach the port. |
APP_DOMAIN | With Caddy | The domain Caddy gets an HTTPS certificate for: the host of APP_URL, for example shop.example.com. |
TRUSTED_PROXY_HOPS | No | How many reverse proxies in front of the app add the visitor's address to X-Forwarded-For. 1 = the bundled Caddy (the default in Docker); 0 = trust no proxy. Never set it higher than the proxies really in front of the app. |
| Advanced | ||
COMPOSE_PROJECT_NAME | No | Only for a second copy on the same server (for example staging): give each copy its own name, so their containers, database, files, network, image and build cache stay apart. Empty = the name of the Basketrun folder. |
SEARCH_INDEXING | No | on (the default): search engines may index the public pages (home, legal, sign-in), never the app or the API. off, for a staging copy: /robots.txt closes every page and every answer carries X-Robots-Tag: noindex, nofollow. |
JOB_WORKERS | No | Background job workers in this server, 1 to 32. Default 4. |
DRAIN_SECS | No | For zero-downtime deploys: seconds a stopping server reports itself unhealthy, so a proxy moves visitors to the new copy, before it exits. Default 0. |
DEMO_MODE | No | Only for a public demo: "true" adds the sample store and one-click sign-ins for every role, makes sign-ups demo accounts and resets the data every night. Keep "false" on a live site. |
DEMO_PAYMENTS | No | "true" lets checkout and wallet top-ups finish without Stripe (paid at once, labelled DEMO). Only for a private test copy; never on a live site. DEMO_MODE turns it on as well. |
DEMO_CATALOG | No | The sample city file that basketrun seed-demo loads. The Docker image already points at its own copy of apps/backend/seed/lakeport.json; set it only to load your own file of the same shape. Remove the sample data in Super-admin → Settings → Maintenance. |
DEMO_PHOTOS | No | The folder of sample photos (products/, stores/ and aisles/ inside, named as in the sample city file). Default: photos/ next to the sample city file. The download has no sample photos, so the sample city shows placeholders; a missing picture is skipped. |
RUST_LOG | No | How much the server logs: info (the default), warn, error or debug. |
| Set by Docker, or for development | ||
ASSET_ARCHIVE | No | For your own zero-downtime deploys: a folder that keeps older builds' files, so pages still open in a browser keep working. |
BIND | No | The address the server listens on. Default 0.0.0.0: plus PORT. |
BUILD_TARGET | No | How Docker gets the program: built (the default, built on this server) or prebuilt (uses prebuilt/basketrun, built elsewhere). |
PORT | Set by Docker | The port the server listens on inside its container (8080). |
READY_FILE | No | For your own zero-downtime deploys: the health check passes only once this file exists. |
STRIPE_API_URL | No | For tests only: another address for Stripe's API. Default https://api.stripe.com. |
WEB_DIST | Set by Docker | Where the built web app is, when it is not packed into the program. |
38File structure
Server and web app
basketrun/
├── apps/
│ ├── backend/ the Rust server (Axum): crate basketrun-server, program "basketrun"
│ │ ├── src/main.rs the commands: serve, migrate, health, seed-demo, reset-demo, pack
│ │ ├── src/lib.rs the HTTP app: /api/health, /api/v1, the web app, middleware
│ │ ├── src/api/ one file per area: public, auth, me, catalog (shopping), shopper (cart,
│ │ │ checkout, orders, wallet), store, store_catalog, store_orders, driver,
│ │ │ delivery (tracking, chat, ratings), media, events, webhooks, admin*
│ │ ├── src/catalog.rs zones, opening hours, express rules, store cards, products, stock
│ │ ├── src/cart.rs the cart, slots, coupons and the price quote
│ │ ├── src/orders.rs placing orders, the status flow, cancelling, adding items
│ │ ├── src/picking.rs accept, pick, barcode checks, missing items, swaps, ready
│ │ ├── src/dispatch.rs job offers, job steps, proof of delivery, cash, driver earnings
│ │ ├── src/payments.rs Stripe Checkout, the webhook rules, refunds, the test checkout
│ │ ├── src/wallet.rs wallet credit and spending
│ │ ├── src/payouts.rs the weekly payouts report
│ │ ├── src/tracking.rs driver positions, live tracking, chat and ratings
│ │ ├── src/push.rs push notifications (Firebase Cloud Messaging) and the in-app list
│ │ ├── src/geo.rs address search through OpenStreetMap, MapTiler or Google
│ │ ├── src/settings.rs super-admin settings over .env
│ │ ├── src/setup_check.rs the setup check rows and live tests
│ │ ├── src/demo.rs the sample city, demo sign-ins, the nightly reset (sim.rs: drivers)
│ │ ├── seed/ lakeport.json (the sample city) and legal/ (starter legal texts)
│ │ ├── tests/ server tests (need a PostgreSQL, see chapter 39)
│ │ └── README.md every module of the server, for developers
│ └── frontend/ the web app (React Router 7, Vite, Tailwind CSS 4)
│ ├── src/routes.ts every page: URL → file (lists in src/routes/)
│ ├── src/pages/ platform/ (super-admin), store/ (store panel), public/, auth/, install/
│ ├── src/ui/, src/components/ui/ shared parts and shadcn/ui components
│ ├── src/layout/ the app shell, sidebar and sign-in guards
│ ├── src/api/ the API client and types
│ ├── src/styles.css colours, fonts and sizes (design tokens)
│ ├── e2e/ browser tests (Playwright)
│ └── README.md the web app's stack, scripts, folders and build
├── migrations/ the database schema (applied on start)
├── docker/ Dockerfile, docker-compose.yml, Caddyfile
├── compose.yaml "docker compose up" from this folder
├── tools/rename.mjs renames and rebrands the apps and the web defaults (chapter 16)
├── Cargo.toml, Cargo.lock the Rust workspace
├── .env.example every server setting
└── docs/ this guide (HTML and PDF) and the third-party licences
The Flutter apps
basketrun_mobile_flutter/
├── lib/
│ ├── main.dart, app.dart start-up and the app root
│ ├── core/
│ │ ├── constants/ app_env.dart (every .env key), app_role.dart (the three apps)
│ │ ├── theme/app_theme.dart colours, sizes and type, light and dark
│ │ ├── router/ the routes of each app, deep links, the tab bars
│ │ ├── providers/ app state (Riverpod): session, shopper, store, driver, push, theme
│ │ ├── services/api/ the API client (token, errors, offline cache); sample/ = sample mode
│ │ ├── services/data/ the data each app reads and writes
│ │ ├── services/firebase/ Firebase start-up and push
│ │ └── services/general/ the secure token store and app preferences
│ ├── domain/models/ the JSON the API answers, as Dart classes
│ ├── components/ shared widgets: bars, controls, commerce, feedback, map, tracking
│ └── features/ common/ (sign-in), shopper/, store/, driver/: the screens
├── android/ app/build.gradle.kts (flavours, ids, names, signing),
│ app/src/<flavour>/google-services.json
├── ios/ Runner (schemes shopper, store, driver), config/<flavour>/GoogleService-Info.plist
├── assets/fonts/ Figtree
├── assets/icon/ shopper.png, store.png, driver.png: the app icon sources
├── flutter_launcher_icons-*.yaml the icon settings of each app (dart run flutter_launcher_icons)
├── test/ unit, widget, flow and screenshot tests; test/live/ against a server
├── pubspec.yaml packages, fonts and the app version
└── .env.example every app setting
39Customise, test and rebuild
Run it for development
- Start a PostgreSQL (your own, or
docker compose up -d postgreswithports: ["127.0.0.1:5432:5432"]added to the postgres service in acompose.override.yaml) and setDATABASE_URLin.env. For development setSTORAGE_DRIVER=local. - Start the server from
apps/backend:cargo run -- serve(it reads.envfrom the folder or the ones above it and listens on port 8080). - Start the web app from
apps/frontend:pnpm install, thenpnpm dev, and openhttp://localhost:5173. Calls to/apigo to the server on port 8080 (API_ORIGINchanges that). Screens reload as you save. - Run an app against it:
API_BASE_URL=http://10.0.2.2:8080in the app.envfor the Android emulator, thenflutter run --flavor shopper --dart-define-from-file=.env. Flutter's hot reload works as usual.
Tests
| Part | Command | What it covers |
|---|---|---|
| Server | cargo test --workspace | Unit tests, and the API tests against a real PostgreSQL: the whole order flow to the cent, payments with a stand-in Stripe, refunds, wallet, coupons, slots, dispatch and the races that must let exactly one through. The API tests need a PostgreSQL login that may create databases: TEST_DATABASE_URL=postgres://user:password@127.0.0.1:5432/postgres cargo test -p basketrun-server (each test gets a fresh database). Without it they say so and pass. |
| Server lints | cargo clippy --workspace --all-targets -- -D warnings | Kept clean; cargo deny check checks advisories and licences. |
| Web app | pnpm test | Unit tests (Vitest), run in apps/frontend. Also pnpm typecheck, pnpm lint (Biome) and pnpm e2e (Playwright). |
| Flutter apps | flutter test | Unit, widget and flow tests of the three apps on the sample data, run in basketrun_mobile_flutter. flutter analyze checks the code. flutter test test/live --dart-define=LIVE_API=http://127.0.0.1:8080 runs the apps' calls against a server in demo mode; --dart-define=SCREEN_SHOTS=/full/path/to/folder also writes screenshots of every screen. |
Change the server
- Each area of the API is one file in
apps/backend/src/api/; itsroutes()function lists the addresses. The business rules (zones, slots, coupons, swaps, refunds, dispatch) are in the modules named after them;apps/backend/README.mdlists every module. - A database change is a new file in
migrations/namedYYYYMMDDHHMMSS_what.sql. Never edit a migration that has already run: the server checks them.
Change the web app
apps/frontend/README.mdexplains its stack, scripts, folders and the production build.- Colours, fonts and sizes are CSS variables in
apps/frontend/src/styles.css; the brand colour from Settings → Branding overrides--brandat run time. - Pages are in
apps/frontend/src/pages/;src/routes.tsmaps each URL to its file. The public home issrc/pages/public/home/and the store applicationsrc/pages/public/sell/.
Change the apps
- Screens are in
lib/features/<app>/, each app's routes in its*_routes.dartfile, and the shared widgets inlib/components/. - Every API call goes through
lib/core/services/api/; sample mode answers the same calls fromlib/core/services/api/sample/, so a new call needs both. - A new setting goes into
.env.exampleand is read inlib/core/constants/app_env.dart, never written into the code.
Rebuild and deploy your changes
docker compose up -d --build # or with --profile https on your server
Docker rebuilds only what changed; a change to the web app alone reuses the compiled server and is quicker still. Rebuild the apps with the commands in chapter 17. Keep your changes in a Git repository, so you can compare them with each new Basketrun version.
40API reference
The web app, the three apps and your own integrations use the same /api/v1 API. These 193 addresses are generated from the server code when the release is built.
- JSON in and out with camelCase keys; times in ISO 8601 UTC; money in whole cents of the platform currency (
…Cents); ids are UUIDs, and orders also have a number such asBR-10482. - Errors:
{"error": {"code": "…", "message": "…"}}with the HTTP status, for exampleother_store,slot_full,out_of_stock,not_enough_stock,cannot_cancel,swap_decided(409),swap_expired,offer_expired(410),wrong_code,proof_required,cash_required(422),wrong_app,demo_locked(403) andrate_limited(429). The message is written to be shown to people as it is. - The web app signs in with the
br_sessioncookie and sendsx-basketrun: 1on every change. The apps send"client": "app"and their"role"(shopper,storeordriver) to/auth/loginand get a token back, then sendAuthorization: Bearer <token>. - Live updates:
GET /api/v1/eventsis a Server-Sent Events stream for the signed-in person and their store;GET /api/v1/orders/{id}/eventsstreams one order's tracking.
| Method | Address | Who may call it | What it does |
|---|---|---|---|
| System | |||
GET | / | Anyone | 200 while the server runs, 503 while it hands over to a new copy during a deploy |
GET | / | Anyone | The running build's version; open pages compare it with their own to offer a reload after a deploy |
GET | / | Anyone | Tells search engines which pages they may index: the public pages, or none with SEARCH_INDEXING=off |
| Public pages, install and inbound webhooks | |||
GET | / | Anyone | The brand, store sign-up mode, demo sign-ins and what the web app and the apps need before sign-in (installed: false sends every page of the web app to the install wizard) |
GET | / | Anyone | One legal page, with when the legal pages were last saved |
GET | / | Anyone, until the install is done (install token) | Whether the install wizard has run |
POST | / | Anyone, until the install is done (install token) | Checks the install token and the setup before the wizard's last step |
POST | / | Anyone, until the install is done (install token) | Finishes the install: the super-admin and the brand (runs once) |
GET | / | Anyone | A store picture, without sign-in (the file name holds its hash, so it is cached for a year) |
GET | / | Anyone | The uploaded brand logo (no sign-in; long cache, the name changes with the file) |
POST | / | Anyone | The "Sell on Basketrun" form (multipart from the web, JSON from the apps): storeName, kind, address, phone, website, contactName, email, role, mobile, productsEstimate, hours, productList, agreedToTerms, message, lat, lng and the licence and permit documents |
GET | / | Anyone | A catalogue picture (a product's, a store's cover or an aisle's), with no sign-in |
GET | / | Anyone | What the public web pages show: the city, the zones on the map, the live stores with their hours and ETA, the platform's figures, the partner terms and the app links |
POST | / | Stripe (signed webhook) | Stripe's signed events for the platform account; each is applied once (checkout paid or expired for orders, add-ons and top-ups) |
| Sign-in and account | |||
POST | / | Anyone | Creates an account: from the web, a store owner with their first store (while store sign-ups are open; the store waits for a super-admin's approval before shoppers see it); from an app ("client": "app"), a shopper or a driver (drivers wait for approval) with a session token |
POST | / | Anyone | Signs in with email and password; "client": "app" (with role: shopper, store or driver) answers a session token for the apps instead of a cookie |
POST | / | Signed in | Signs out of this browser or app (the session and its push token go) |
GET | / | Signed in | The signed-in user, their stores, role and capabilities |
GET | / | Anyone | The signed-in person like /auth/me, or { me: null } when signed out (always 200) |
POST | / | Signed in | Makes another of the user's stores the current one |
POST | / | Signed in | Creates another store owned by the user (it waits for the platform's approval, as a sign-up does, unless the user is a super-admin) |
POST | / | Anyone | Emails a password reset link when the email belongs to an account |
POST | / | Anyone | Sets a new password with a reset link and signs in (each link works once) |
GET | / | Anyone | Whose link this is (404 when it expired or was used) |
POST | / | Signed in | Ends an "open as owner" session and goes back to the super-admin's own |
GET | / | Anyone | What an invitation link is for (store, role, email) |
POST | / | Anyone | Accepts an invitation, signing in or creating the account |
PATCH | / | Signed in | Changes the person's name, phone or picture |
POST | / | Signed in | Changes the password (the current one is asked for); other sessions end |
POST | / | Anyone, public demo only | One-click demo sign-in as owner, manager, picker, shopper, driver or the read-only super-admin; "client": "app" answers a session token |
POST | / | Signed in | Saves this device's push token (token, platform: android, ios or web, app: shopper, store or driver), one per session |
DELETE | / | Signed in | Stops push messages to this device (the person turned them off) |
GET | / | Signed in | The signed-in person's profile: name, email, phone, photo, push choices (notifications: {orderUpdates, swaps, chat, offers}) and defaultSubstitutionPref |
PATCH | / | Signed in | Changes any of name, phone, avatarUrl, notifications (booleans per kind) and defaultSubstitutionPref (best_match, specific or refund); answers the profile |
DELETE | / | Signed in | Deletes the person's own account (password asked); it signs out everywhere and is purged after 30 days |
GET | / | Signed in | The shopper's saved products, newest first (hidden ones left out) |
PUT | / | Signed in | Saves a product (the heart; saving twice is fine) |
DELETE | / | Signed in | Removes a saved product |
| Shopping (shopper app) | |||
GET | / | Anyone | The zone that delivers to a point, or the nearest zone (name, polygon and distance) when none does |
POST | / | Anyone | { email, lat?, lng? }, asks to hear when delivery reaches a point outside every zone, or anywhere new with the email alone (no point: the area stays empty) |
GET | / | Anyone | The shopper home: the zone and address, promo banners, aisles, the stores that deliver here, deals, and for a signed-in shopper "buy again" and the order on its way |
GET | / | Anyone | The stores that deliver to a point (every store without a point), open ones first, then the nearest |
GET | / | Anyone | A store's page by slug or id: its card, address and map point, about text, aisles with their counts, deals and popular items, and the first scheduled slot |
GET | / | Anyone | One page of a store's products (20), filtered by aisle (id or slug), text or tag; sort = price_asc, price_desc, deals or name |
GET | / | Anyone | The product page: the product with its photos, origin, storage and deal end, its store and aisle, similar items and the swaps a shopper may pick in advance (saved for a signed-in shopper) |
GET | / | Anyone | Every active aisle with how many products shoppers can see in it |
GET | / | Anyone | Products matching a text, grouped by store (the store scope first, even with no match), with suggestions when little matches |
GET | / | Anyone | Places matching an address or city (through the server's geocoding provider) |
GET | / | Anyone | The address at a map point (result null when the provider knows none) |
GET | / | The order's shopper, store team or driver | The order's map (status, ETA, the driver's position, store, drop-off, route) for its shopper, store, driver or platform staff |
GET | / | The order's shopper, store team or driver | The order's live stream (SSE): order.updated with a fresh map on every change and driver ping, order.message for chat, a ping every 25 seconds |
GET | / | The order's shopper, store team or driver | The order's chat (oldest first) and who takes part, for its shopper, store, driver or platform staff |
POST | / | The order's shopper, store team or driver | Sends {body} to the order's chat as its shopper, store or driver |
POST | / | The order's shopper, store team or driver | The shopper rates a delivered order once ({storeStars, driverStars, comment}; 409 already_rated); answers the order |
GET | / | Signed in | The signed-in person's notifications, newest first, with the unread count |
POST | / | Signed in | Marks {ids} read (all without ids); answers the unread count |
GET | / | Shopper | The cart with its prices, deal savings, fees, coupon and coupon offers |
DELETE | / | Shopper | Empties the cart ("Start a new cart") |
PUT | / | Shopper | { productId, qty, substitutionPref?, substituteProductId? } sets a line (qty 0 removes it); another store's item is 409 other_store |
DELETE | / | Shopper | Removes a line |
GET | / | Shopper | Express now (or why not) and the scheduled slots for the next 7 days with the places left |
POST | / | Shopper | { code } checks a coupon against the cart and keeps it (refusals say why, e.g. "Add $4.20 more to use SAVE5") |
DELETE | / | Shopper | Takes the coupon off the cart |
POST | / | Shopper | The price summary for the cart with these checkout choices, with warnings |
GET | / | Shopper | The shopper's orders, newest first |
POST | / | Shopper | Places the cart (idempotencyKey makes a retry answer the same order) |
GET | / | Shopper | One order with its lines, swaps, totals, driver and timeline |
POST | / | Shopper | { reason? } cancels until the store accepts (then 409 cannot_cancel); paid money comes back at once |
POST | / | Shopper | Puts the order's lines back in the cart |
POST | / | Shopper | { lines } adds lines to an open order until it is packed |
POST | / | Shopper | { decision: "approve" | "reject", productId? } answers a swap |
GET | / | Shopper | The balance and the latest entries (cursor pages older ones) |
POST | / | Shopper | { amountCents } ($5–$200) opens a Checkout page; the wallet is credited once the payment is confirmed |
GET | / | Shopper | The shopper's saved addresses, the default first |
POST | / | Shopper | { label, line1, line2, city, notes, lat, lng, isDefault } saves an address (its delivery zone comes from the point) |
PATCH | / | Shopper | Changes an address (fields left out stay) |
DELETE | / | Shopper | Removes an address (the next one becomes the default) |
GET | / | Anyone | The demo checkout page (public demo or DEMO_PAYMENTS only): a test card form that pays with 4242 4242 4242 4242 and declines 4000 0000 0000 0002 |
POST | / | Anyone | { card } pays a demo checkout with a test card (402 card_declined for the declined card) |
| Driver app | |||
GET | / | Driver (approved) | The driver's shift (online, approval, zone, vehicle, today's pay, cash held, how busy the zone is, the nearest store, the open offer and job) |
PATCH | / | Driver (approved) | Changes the driver's zone (zoneId), vehicle (vehicle, plate), position (lat, lng, heading) and online switch (online); answers the status |
POST | / | Driver (approved) | Goes online or offline ({online}; offline with a job is 409 job_open); answers the status |
POST | / | Driver (approved) | The driver's position ping (lat, lng, heading), which moves them on every open map of their order |
GET | / | Driver (approved) | The job offered to the driver now (30 seconds to answer), or null |
POST | / | Driver (approved) | Takes the job (410 offer_expired after 30 seconds, 410 offer_gone when another driver has it); answers the job |
POST | / | Driver (approved) | Passes on the offer; it goes to the next driver |
POST | / | Driver (approved) | The same as decline |
GET | / | Driver (approved) | The accepted job (stage, store, shopper, bags, pay, cash, route), or null |
POST | / | Driver (approved) | The driver is at the store; answers the job |
POST | / | Driver (approved) | The driver has the bags ({bags?}; 409 not_ready while the store is still packing) and the order is on the way; answers the job |
POST | / | Driver (approved) | The driver is at the door (the shopper hears it); answers the job |
POST | / | Driver (approved) | Delivers with the shopper's code or a proof photo ({code | proofMediaId, cashCollectedCents}; 422 wrong_code with triesLeft, 422 cash_required); answers the trip |
POST | / | Driver (approved) | Hands the job back before pickup (409 picked_up after); it goes to the next driver |
GET | / | Driver (approved) | Fees, tips, trips and online time for today or this week (?range=week), the cash held and the next payout |
GET | / | Driver (approved) | The driver's deliveries, newest first (?cursor pages on) |
| Store, team and files | |||
GET | / | Signed in | Live updates (Server-Sent Events) for the person's store and account: ready, a ping every 25 seconds and refetch when a screen fell behind |
GET | / | Store member | The current store |
PATCH | / | Store owner or manager | Changes the store name, time zone, opening hours or its grocery profile |
DELETE | / | Store owner | Closes the store (the owner types its name to confirm); its team loses access and it is purged after 30 days |
POST | / | Store owner or manager | Uploads the store picture (PNG, JPEG or WebP up to 1 MB), shown in the store panel and the shopper app |
DELETE | / | Store owner or manager | Removes the store picture (and its file) |
GET | / | Store member | The members, each with what they are doing now and their day (see [SHIFT_SQL] for "on shift"), the open invitations (for managers) and stats, the store's day at a glance |
POST | / | Store owner or manager | Invites someone by email as a manager or picker (only the owner invites managers) |
POST | / | Store owner or manager | Sends an invitation again with a new link |
DELETE | / | Store owner or manager | Withdraws an invitation |
PATCH | / | Store owner or manager | Changes a member's role (managers move pickers; a store keeps at least one owner) |
DELETE | / | Store owner or manager | Removes a member (managers remove pickers; never the last owner) |
POST | / | Signed in | Uploads a file (multipart file; typed by content, size limits per kind) |
GET | / | Signed in | A file, to the person it belongs to, to members of the store it belongs to, or to platform staff |
GET | / | Store member | One page of the catalogue with the tab counts and the aisles (tab = all, low, out or hidden; q matches the name or barcode) |
POST | / | Store owner or manager | Adds a product (name, unit, aisle, price and was-price, stock and its warning level, barcode, description, photo, swaps and weight options) |
GET | / | Store member | The whole catalogue in short (id, name, aisle with its id and pick name, barcode, price, shown) for the CSV check and the swap picker to match against (pages of up to 5000) |
POST | / | Store owner or manager | { ids, action: "in_stock" | "hide" | "show" | "delete" } on several products at once ("in stock" fills each to its warning level + 10) |
POST | / | Store owner or manager | { rows | csv, keepIds, hideMissing, zeroStock } |
GET | / | Store member | One product with every field |
PATCH | / | Store owner or manager | Changes any field of a product |
DELETE | / | Store owner or manager | Removes a product (past orders keep their lines) |
PATCH | / | Store member | { stock } sets a count, { delta } adds or takes some (one update that never goes below zero: 409 stock_short when there is not enough); note keeps a line for the team |
GET | / | Store member | Every tracked product with its count, warning level, week's sales, when it ran out and when it will at the recent pace; today's restocks, swap figures and the stock rules |
PATCH | / | Store owner or manager | { hideAtZero, lowStockEmail, lowerOnPick } (hide products at 0 from shoppers, the 7:00 low-stock email, lower stock as items are picked) |
GET | / | Store member | Opening hours, special days, express and slot rules, and the next week's slots |
PUT | / | Store owner or manager | { week, holidays, express: { on, prepMinutes, pauseWhenWaiting }, cutoffMinutes, accepting, acceptsCash, capacity: { zoneId: n } }, saves the hours page (each part optional; week and holidays replace what was saved) |
GET | / | Store member | Whether the store takes orders now (open, paused and until when, closing time, express, zone, pickers on shift) |
PATCH | / | Store member | Pauses or resumes new orders |
GET | / | Store member | The live board (open orders by default) with the store's status, today's delivered and cancelled counts |
GET | / | Store member | The pick list: the order with its lines by aisle (barcode, picked qty) and swaps |
PATCH | / | Store member | { pickerId } hands the order to another picker of the store |
POST | / | Store member | Takes a new order (409 not_new once anyone answered it) |
POST | / | Store member | { reason } turns a new order down; the shopper gets their money back |
POST | / | Store member | Starts picking an accepted order |
POST | / | Store member | { qty, byHand } counts units picked |
POST | / | Store member | { refund? } marks a line missing (refunded at once with the refund preference) |
POST | / | Store member | { barcode } checks the scanned item is the line's product and picks one unit when it is |
POST | / | Store member | { productId } proposes a swap (the shopper pays the lower price) |
POST | / | Store member | { bags, shelf } packed and waiting for the driver |
POST | / | Store member | The driver took the bags; the order is on the way |
POST | / | Store member | Asks for another driver before pickup |
GET | / | Store member | The store app's day: orders done, average pick time, items picked, swaps, the finished orders, pickers on shift and the same day last week |
GET | / | Store member | The shell badges: new orders, orders being picked, products low or out |
GET | / | Store member | Today at a glance: orders and sales against last week, on-time rate, swaps, orders by hour, what needs the team, pickers at work and what sells fast |
GET | / | Store member | Sales, orders, what the store keeps after commission and refunds (the orders delivered in the range, as its payouts count them), on-time rate, a bar per day, best sellers, zones, refunds by reason, ratings and when the range is paid out (payoutDue) |
| Super-admin | |||
GET | / | Super-admin (viewer reads) | The platform dashboard: today's orders, sales and drivers, late orders and new applications, plus stores, people, sign-ups per month and what needs attention |
GET | / | Super-admin (viewer reads) | The badges in the super-admin's menu: new store applications, stores from the sign-up waiting for approval, drivers waiting for approval and late open orders |
DELETE | / | Super-admin | Closes a store (purged after 30 days, like a store its owner closes) |
POST | / | Super-admin | "Open as owner": a 30-minute session as the store's owner |
GET | / | Super-admin (viewer reads) | Everyone who signs in (search, kind: shopper / driver / staff, platform staff, store role, status) |
PATCH | / | Super-admin | Changes a person's kind (shopper, driver, staff), platform role, status or name |
GET | / | Super-admin (viewer reads) | The platform settings (secrets masked), server facts and storage stats |
POST | / | Super-admin | The brand logo (PNG, SVG or WebP up to 1 MB, checked by content), served publicly as the logo and favicon |
PUT | / | Super-admin | Saves one settings section (secrets are sealed; an empty secret keeps .env) |
GET | / | Super-admin (viewer reads) | The platform emails with their built-in and saved wording, for the email editor |
GET | / | Super-admin (viewer reads) | The setup check rows |
POST | / | Super-admin | Tests one setup check row against the real service |
GET | / | Super-admin (viewer reads) | Background jobs (status and kind filters) with counts per status |
POST | / | Super-admin | Queues a failed job again |
POST | / | Super-admin | Removes the demo data (demo-marked rows only) |
GET | / | Super-admin (viewer reads) | Every zone with its figures, the city, and where the waitlist asks for delivery |
POST | / | Super-admin | Adds a zone (polygon = at least 3 points [lat, lng], with its fees and slots) |
GET | / | Super-admin (viewer reads) | Everyone waiting for delivery to reach them (Export list) |
GET | / | Super-admin (viewer reads) | One zone with its figures |
PATCH | / | Super-admin | Changes a zone (any field; open orders keep the fees they were quoted) |
DELETE | / | Super-admin | Removes a zone with no open orders (switching it off keeps its history) |
GET | / | Super-admin (viewer reads) | The store list: status = live (or active: approved and not suspended), suspended or pending (waiting for approval), a zone or kind filter, the tab counts and this week's figures |
POST | / | Super-admin | { name, kind, address, zoneId, owner: { name, email, phone }, commissionBps }, adds a store and emails its owner a sign-in link |
GET | / | Super-admin (viewer reads) | The store sheet: its row, team, files and the weeks not paid out yet |
PATCH | / | Super-admin | Approves or rejects a new store, suspends a store with a reason (its owner and managers are told) or restores it; also sets its commission, payout schedule, kind and zones |
GET | / | Super-admin (viewer reads) | Partner applications (new ones by default), newest first |
POST | / | Super-admin | { commissionBps?, zoneId? }, makes the store and its owner's account from the application and emails the owner a sign-in link (once: a second approve is a 409) |
POST | / | Super-admin | { reason } (10 characters at least), declines an application and emails the applicant the reason |
POST | / | Super-admin | { documents: ["Licence", …] }, emails the applicant for the missing documents (they show as asked for) |
GET | / | Super-admin (viewer reads) | A document sent with an application (licence or permit) |
GET | / | Super-admin (viewer reads) | Every aisle, in the shoppers' order |
POST | / | Super-admin | { name, icon, sort, pickName, active }, adds an aisle every store can use |
PATCH | / | Super-admin | Changes an aisle's name, icon, order, pick-list name or shown state |
DELETE | / | Super-admin | Removes an aisle (its products stay, without an aisle) |
GET | / | Super-admin (viewer reads) | One page of drivers for a tab (online, approved, pending, suspended) with zone, vehicle and search filters, the tab counts and the live figures |
POST | / | Super-admin | Invites a driver by email ({email, zoneId?, name?}): an account waiting for approval and an email with a link to choose a password (valid 7 days) |
GET | / | Super-admin (viewer reads) | One driver with today's figures, documents, acceptance over 30 days and recent trips |
PATCH | / | Super-admin | Approves, rejects, suspends (status: suspended; 409 on_delivery while they carry an order) or reinstates a driver, or changes their zone, vehicle and plate; the driver hears of a decision |
POST | / | Super-admin | Asks the driver for documents ({documents: [labels]}): each is marked missing on their sheet and they get an email and a notification |
GET | / | Super-admin (viewer reads) | The live map: zones with their open orders, stores, every online driver as a pin (delivering, heading to a store, waiting, or late with the minutes) and the counts (delivering and to_store count as the overview does: [dispatch::DELIVERING_SQL]) |
GET | / | Super-admin (viewer reads) | The week's payouts report (?period= any day of the week, default last week): stores (sales, commission, refunds, owed) and drivers (fees, tips, cash held, owed), with what was paid |
POST | / | Super-admin | Records the payouts of the ticked rows ({period, ids: [{party, id}]}) once each; answers how many were recorded |
GET | / | Super-admin (viewer reads) | One page of orders, the tab counts and today's GMV |
GET | / | Super-admin (viewer reads) | The order sheet: lines, swaps, money, customer, driver, card, zone, steps, the event log (timeline) and the store's commission (store.commissionBps) |
POST | / | Super-admin | { reason } cancels any order not delivered; paid money goes back |
POST | / | Super-admin | { items: [{ itemId, reason }], deliveryFee, to: "card" | "wallet" } |
GET | / | Super-admin (viewer reads) | Shoppers with their orders, spend and wallet, the tab counts and the stat cards |
PATCH | / | Super-admin | { status: "blocked" | "active", blockedReason } blocks a shopper (signed out everywhere, can't sign in) or lets them back |
GET | / | Super-admin (viewer reads) | Coupons, tab counts and this month's figures (uses, first-order share, discount given, codes turned away and the top reason) |
POST | / | Super-admin | Creates a coupon (code, kind, value, limits, storeIds, dates) |
PATCH | / | Super-admin | Changes a coupon (fields left out stay), e.g |
DELETE | / | Super-admin | Removes a coupon never redeemed; one with redemptions is ended instead (its history stays) |
41Database
PostgreSQL. The schema is in migrations/ and is applied by the server on start. Ids are UUIDs, times are UTC and money is in whole cents. Every store table carries store_id; orders, payments and refunds are kept when a shopper or a store is deleted. These 52 tables are generated from the migrations when the release is built.
| Table | What it holds | Keys | Points to |
|---|---|---|---|
| Accounts and sign-in | |||
users | Every person: shoppers, drivers and staff (store teams and the platform's own), with their super-admin role (none, admin or viewer) | primary key id; unique email (any case), when deleted_at is null | – |
sessions | Signed-in browsers and apps (only a hash of the cookie or Bearer token is stored), including super-admin impersonation | primary key id; unique token_hash | users, stores |
push_tokens | The push token of the device each app session runs on, removed with the session | primary key id; unique session_id; unique token | sessions, users |
password_resets | Password reset links (hashed, valid for one hour, used once) | primary key id; unique token_hash | users |
invites | Open invites to a store, with the role to join as (manager or picker) | primary key id; unique token_hash; unique email (any case) per store, when accepted_at is null | stores, users |
rate_limits | Fixed-window counters for sign-in, sign-up and password reset limits (keyed by a hash) | primary key key | – |
notifications | What each person sees under Notifications in the apps (every push is also kept here) | primary key id | users, orders |
| Stores and teams | |||
stores | The grocery stores on the marketplace (the tenants), with their status, time zone, opening hours and settings | primary key id; unique slug | users, zones, media |
store_members | Who works in a store and their role (owner, manager or picker) | primary key store_id + user_id | stores, users |
store_hours | Weekly opening hours; a weekday with no row is closed | primary key store_id + weekday | stores |
store_closures | Days a store is closed (holidays) | primary key store_id + day | stores |
store_zones | The zones a store delivers to | primary key store_id + zone_id | stores, zones |
store_applications | Public partner applications from the web site's "Sell on Basketrun" form | primary key id | stores, zones, users |
store_application_files | Documents sent with an application (business licence, food permit) | primary key application_id + kind; unique storage_key | store_applications |
audit_log | Actions taken by store owners, managers and the super-admin | primary key id | stores, users |
| Zones and places | |||
zones | Delivery zones: an address is served when its point is inside an active zone's polygon | primary key id; unique slug | – |
zone_waitlist | People who asked to hear when delivery reaches their address | primary key id; unique email | users |
addresses | Saved delivery addresses | primary key id; unique user_id, when is_default | users, zones |
geo_cache | Geocoding answers kept for 30 days (provider rate limits and cost) | primary key key | – |
| Catalogue | |||
categories | Platform-wide aisles (Fruit and vegetables, Dairy, …) | primary key id; unique slug | media |
products | A store's products | primary key id; unique barcode per store, when barcode is not null | stores, categories, media, users |
stock_moves | Every stock change made in the store panel (restock counts and "last restock") | primary key id | stores, products, users |
saved_products | A shopper's saved products (the heart on the product page) | primary key user_id + product_id | users, products |
| Cart, coupons and slots | |||
carts | One open cart per shopper, from one store | primary key user_id | users, stores |
cart_items | One line of a cart: the product, how many, and the shopper's swap choice for it | primary key user_id + product_id | carts, products |
coupons | Coupons, checked by the server at checkout | primary key id; unique code | stores |
coupon_stores | The stores a coupon works at (no rows, and no coupons.store_id: every store) | primary key coupon_id + store_id | coupons, stores |
coupon_redemptions | Redemptions, one per order | primary key order_id | orders, coupons, users |
coupon_refusals | Codes the server turned away at checkout, and why (the admin's "turned away" figure) | primary key id | users |
slot_bookings | Reserved delivery slots (capacity check under an advisory lock) | primary key order_id | orders, stores |
| Orders | |||
orders | Orders | primary key id; unique number; unique stripe_session_id; unique user_id + idempotency_key | users, stores, zones, coupons, media |
order_items | One line of an order: the product's name, unit and price when it was ordered, how many were picked, and its swap choice | primary key id | orders, products |
order_addons | Lines the shopper adds to an open card order: they join the order when their own Checkout Session is paid | primary key id; unique stripe_session_id | orders, users |
substitutions | A picker's proposed swap for a line the store could not find | primary key id; unique order_item_id, when status = 'proposed' | orders, order_items, products |
order_events | The order's timeline | primary key id | orders, users |
order_refunds | Every refund of an order | primary key id; unique idem_key | orders, users, order_items |
order_messages | Chat between the shopper, the driver and the store about one order | primary key id | orders, users |
order_ratings | One rating per delivered order | primary key order_id | orders, users |
| Drivers and delivery | |||
driver_profiles | Drivers (users of kind 'driver') | primary key user_id | users, zones |
driver_shifts | Each time a driver was online (the earnings screen's online minutes) | primary key id; unique driver_id, when ended_at is null | users |
dispatch_offers | Job offers to drivers | primary key id; unique order_id, when status = 'accepted'; unique driver_id, when status = 'offered' | orders, users |
order_track | The driver's trail while an order is on the way (for the shopper's map) | primary key id | orders |
driver_earnings | What a driver earned per delivered order | primary key order_id | orders, users |
| Wallet and payouts | |||
wallet_accounts | The shopper's wallet: credit only from refunds and paid top-ups | primary key user_id | users |
wallet_entries | Every change to a wallet: refunds and paid top-ups in, spending at checkout out, each with its order and a key so it is written once | primary key id; unique idem_key | users, orders |
wallet_topups | A wallet top-up paid through Stripe Checkout; the wallet is credited only when Stripe confirms the payment | primary key id; unique stripe_session_id | users |
payouts | Payouts the platform marked as paid to a store or a driver | primary key id; unique party + period_start per store | stores, users |
| Files | |||
media | Every uploaded file: a store's (product photos, the store picture) or a person's own (profile photo) | primary key id; unique storage_key | stores, users |
| Payments | |||
stripe_events | Every Stripe event already applied, so a repeated delivery changes nothing | primary key id | – |
| Platform | |||
platform_settings | The super-admin settings by section, which take precedence over .env (secrets stored encrypted) | primary key key | users |
email_notices | Platform emails already sent for a store and period, so each is sent once | primary key store_id + kind + period | stores |
jobs | The durable background job queue: the nightly housekeeping and purge, and the demo reset | primary key id; unique dedupe_key, when dedupe_key is not null and status in ('queued', 'running') | stores |
Help
42Updating and backups
Back up
docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' > backup-$(date +%F).sql
Run it in the Basketrun folder. It reads the database user and name from the postgres container, so it works whatever you set as POSTGRES_USER and POSTGRES_DB; -T keeps a terminal out of the dump.
Also keep a copy of .env (above all APP_SECRET, without which the saved keys cannot be read), of your files (the minio-data Docker volume, your own bucket or the app-storage volume), and of the apps' signing keys and .env files. Restore a database backup into an empty database with docker compose exec -T postgres sh -c 'psql -U "$POSTGRES_USER" "$POSTGRES_DB"' < backup.sql.
Update the server
Docker names the stack, and with it the database volume, after the folder unless COMPOSE_PROJECT_NAME is set. If you move or rename the folder, set COMPOSE_PROJECT_NAME to the old folder name first, or the app starts with an empty database. Your data isn't lost; it's under the old name, which docker volume ls shows before _postgres-data.
- Back up as above.
- From the folder that holds
basketrun/(not inside it), rununzip -o basketrun-x.y.z.zipwith the new version's file name. The zip has a top-levelbasketrun/folder, so it unpacks over your install and replaces every shipped file, also ones you changed in the web app or the mobile apps: keep your changes in Git (chapter 39) so you can see and re-apply them. Your.env,compose.override.yaml,prebuilt/and the apps'.envfiles andkey.propertiesare kept, because the zip doesn't contain them. - Compare your
.envwith the new.env.example; new keys are listed there and inCHANGELOG.md. This lists the keys of.env.examplethat your.envdoesn't have yet:cd basketrun for k in $(grep -oE '^#? ?[A-Z][A-Z0-9_]*=' .env.example | tr -d '# ='); do grep -q "^$k=" .env || echo "$k"; done - Run
docker compose up -d --build(with--profile httpson your server). The new version applies any new migrations when it starts; your data stays. - If disk is tight, run
docker builder pruneafterwards to free the build cache.
Update the apps
Copy your changes (names, ids, icons, theme) onto the new basketrun_mobile_flutter/, or compare with Git, then raise the build number in pubspec.yaml, build and upload as in chapter 17. Update the server first: new apps may need the new server, while the old apps keep working with it.
43Troubleshooting
The app says it cannot reach the server
- Open
API_BASE_URL/api/healthin the phone's browser: it must answer. On the Android emulator a server on your computer ishttp://10.0.2.2:8080, notlocalhost. API_BASE_URLis the server's root without/api/v1. The value is built into the app: after changing.env, run or build the app again.- A real phone needs an https address with a valid certificate.
"This account is for the … app"
Each account signs in only to its own app: shoppers to the shopper app, store teams to the store app, drivers to the driver app, platform staff to the web. Use the app it names, or change the account's kind in People.
Card orders stay "waiting for payment"
Stripe's webhook does not reach the server. Setup check → Stripe must show the webhook signing secret. In Stripe → Developers → Webhooks, the endpoint must be APP_URL/api/v1/webhooks/stripe with the three events of chapter 8; Stripe shows every delivery and the server's answer there. A signing secret from another endpoint (or from test mode on a live endpoint) is refused.
No push notifications
- Setup check → Push messages must be green (the service account is saved).
- The app was built with that app's own
FIREBASE_*keys, all of them filled in (chapter 12). With any of them missing, the app quietly leaves push off. - The phone is a real device, notifications are allowed for the app, and the person is signed in.
- For iOS, the APNs key is uploaded in Firebase (chapter 12).
No driver gets the offer
A job is offered only to drivers who are approved, online in the driver app, seen in the last 15 minutes, in the order's zone and without another job. Express orders go out when the store accepts; scheduled orders 30 minutes before their slot. Super-admin → Drivers → Online now shows who can take it.
Shoppers are told you don't deliver to them
Their address point is outside every zone, or the zone has no store delivering to it. Check the zone's corners and its "Stores delivering here" in Zones, and look at the waitlist for where people ask.
A store does not show in the shopper app
It must be approved, not suspended, have at least one product shown in the app and deliver to the shopper's zone. A store that is closed now, or has "Accepting orders" off, shows as closed.
Express is not offered
Express needs the zone's express on, the store's express on, the store open now, and fewer waiting orders than the store's "pause express" number.
The maps are blank or grey
MapTiler or Google is chosen without its key: the setup check's Maps row warns, and the maps fall back to OpenStreetMap. A key that is set but wrong, unpaid or limited to other apps gives empty or grey maps: check it in the provider's dashboard. Google Maps in the apps also needs the app's own key at build time (chapter 15).
The install wizard asks for a token I don't have
The app prints it in its log at every start until the install is finished, and each restart makes a new one, so use the last line of docker compose logs app | grep -i "install token". Or set INSTALL_TOKEN in .env and run docker compose up -d.
After an upgrade everything is empty
The folder was moved or renamed, so Docker started a new, empty stack (chapter 42). Stop it with docker compose down, set COMPOSE_PROJECT_NAME in .env to the name before _postgres-data in docker volume ls, and run docker compose up -d again.
The app does not start
docker compose logs app names the problem, for example "APP_SECRET must be at least 32 characters" or "DATABASE_URL is not set". docker compose ps shows whether PostgreSQL and MinIO are healthy.
The build stops with "killed" or "signal: 9"
The server ran out of memory while compiling. Add swap or build on another computer (chapter 5).
A Flutter build fails
Always pass --flavor and --dart-define-from-file. After changing packages or ids, run flutter clean and flutter pub get; on iOS also cd ios && pod install --repo-update. flutter doctor shows missing tools.
Emails don't arrive
Without SMTP, emails are written to docker compose logs app. With SMTP, send a test email from Settings → Email and check that the sender's domain is verified with your provider.
The orders board or the tracking map does not move
A proxy is buffering the live updates. With the bundled Caddy it works as is; with Nginx add proxy_buffering off;.
Too many sign-in attempts from everyone at once
TRUSTED_PROXY_HOPS is 0 behind a proxy, so every visitor shares one address. Set it to the number of proxies in front of the app (chapter 5).
44FAQ
Do I publish three apps?
Yes: the shopper app, the store app and the driver app are three listings on Google Play and three on the App Store, under your own developer accounts. They are built from one codebase.
Where does the money go?
Card payments land in your own Stripe account. The payouts report tells you each week what you owe each store and driver, and you pay them yourself. Stores and drivers need no Stripe account.
Can a shopper order from two stores at once?
No. A cart holds one store's items, so one picker packs it and one driver brings it.
Does it work without card payments?
Yes: cash on delivery and wallet credit from refunds work without Stripe. Wallet top-ups and card orders need Stripe.
Do I need Google Maps?
No. OpenStreetMap works with no key. Move to MapTiler or Google once the marketplace is busy (chapter 11).
Can I use another currency or country?
Set the currency and time zone in Settings → General; Stripe takes payments in it where your Stripe account allows. Product sizes are free text, so you write them in your own units. The apps and the web app are in English.
Is there a web shop for shoppers?
No. Shoppers order in the shopper app; the public site checks their address, shows the stores near them and links to the apps.
Do I need to know Rust or Flutter?
Not to install it, set it up or run it: Docker builds the server. Building the apps needs Flutter installed, and the commands in Part 03. Changing the screens needs Dart (apps) or React (web); changing the rules needs Rust.
Can I host it without Docker, or on shared hosting?
Without Docker yes: run the one basketrun program behind your own HTTPS proxy with PostgreSQL 15 or newer (chapter 5). Shared PHP hosting cannot run it.
Which licence do I need?
To take orders and payments from shoppers, the Envato Extended Licence. See chapter 47.
45Credits and licences
Basketrun is built with these open-source projects, each under its own licence:
- Server: Rust, Axum, Tokio, SQLx, reqwest, rustls, Lettre, RustCrypto (Argon2, AES-GCM, HMAC, HKDF, SHA-2), chrono-tz and mimalloc, under permissive licences (MIT, Apache 2.0, ISC or BSD).
- Web app: React, React Router, Vite, Tailwind CSS, shadcn/ui, Base UI, Radix UI, TanStack Query and Table, Sonner and React DayPicker (MIT); Leaflet (BSD 2-Clause) for the maps.
- Flutter apps: Flutter (BSD 3-Clause) and these packages from pub.dev: flutter_map (BSD 3-Clause) with latlong2 (Apache 2.0) for the OpenStreetMap and MapTiler maps; google_maps_flutter, firebase_core and firebase_messaging, go_router, mobile_scanner (barcode scanning; on Android it uses Google's ML Kit, on iOS Apple's Vision), flutter_secure_storage, flutter_local_notifications, image_picker, url_launcher, share_plus, shared_preferences, connectivity_plus, package_info_plus, hive_ce_flutter, http, intl and shimmer (BSD 3-Clause); flutter_riverpod, geolocator and lucide_icons_flutter (MIT); flutter_styled_toast (Apache 2.0). flutter_launcher_icons (MIT) makes the app icons and is used only while building.
- Icons: Lucide (ISC licence), in the web app and the apps (lucide_icons_flutter, MIT).
- Fonts: Figtree in the apps (its licence is in
assets/fonts/OFL.txt), Geist and JetBrains Mono in the web app (bundled through Fontsource), all under the SIL Open Font License 1.1. - Maps and places: map data © OpenStreetMap contributors, under the Open Database License, with the attribution shown on every map. Address search uses Nominatim by default. The sample city's zones, addresses and driver routes are made from OpenStreetMap data.
- Docker images: PostgreSQL (PostgreSQL Licence), MinIO (GNU AGPL 3.0, run unmodified as a separate service), Caddy (Apache 2.0), and the official Rust, Node.js and Debian images used to build and run the app.
Every server and web dependency
The Rust crates (from Cargo.lock) and the web app's npm packages, counted by licence when the release is built. docs/third-party-licenses.txt lists every package by name, version and licence; the Flutter packages and their versions are in basketrun_mobile_flutter/pubspec.lock.
| Licence | Rust crates | npm packages |
|---|---|---|
| MIT | 53 | 272 |
| Apache-2.0 OR MIT | 213 | 2 |
| Unicode-3.0 | 18 | – |
| ISC | 2 | 10 |
| Apache-2.0 | 1 | 10 |
| MIT OR Unlicense | 5 | – |
| (MIT OR Apache-2.0) AND Unicode-3.0 | 3 | – |
| Apache-2.0 OR MIT OR Zlib | 3 | – |
| Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT | 3 | – |
| BSD-2-Clause | – | 3 |
| BSD-3-Clause | 1 | 2 |
| 0BSD | 1 | 1 |
| Apache-2.0 OR BSD-2-Clause OR MIT | 2 | – |
| Apache-2.0 OR BSL-1.0 OR MIT | 2 | – |
| Apache-2.0 OR ISC OR MIT | 2 | – |
| Apache-2.0 OR LGPL-2.1-or-later OR MIT | 2 | – |
| CDLA-Permissive-2.0 | 2 | – |
| MPL-2.0 | – | 2 |
| OFL-1.1 | – | 2 |
| Zlib | 2 | – |
| (Apache-2.0 OR MIT) AND BSD-3-Clause | 1 | – |
| 0BSD OR Apache-2.0 OR MIT | 1 | – |
| Apache-2.0 AND ISC | 1 | – |
| Apache-2.0 OR BSL-1.0 | 1 | – |
| BlueOak-1.0.0 | – | 1 |
| CC-BY-4.0 | – | 1 |
| LicenseRef-Envato-Regular-or-Extended | 1 | – |
| MIT AND BSD-3-Clause | 1 | – |
| MIT-0 | – | 1 |
| Unlicense | – | 1 |
| Total | 321 | 308 |
Every licence above allows use in a commercial product. cargo deny check licenses checks the Rust crates against the allowed list.
Images
The public site comes with six photos in apps/frontend/public/images/site (the home page's main picture, the store cards and the "sell" and "drive" sections): replace them with pictures of your own city and stores. The sample city comes with placeholder pictures (chapter 34). The logo is an original SVG, and every image in this guide is a screenshot of the running apps.
46Changelog
1.0.0 (November 2026)
First release.
- Three Flutter apps from one codebase: the shopper app, the store app for pickers and the driver app, as three flavours with their own name, app id, icon and deep links; light and dark themes; a sample mode that runs every screen without a server.
- Shopping: delivery zones drawn on the map, stores near the shopper's address, aisles, search, deals, one store per cart, express delivery with a live time estimate or a scheduled slot for today and the next six days, coupons, a service fee, tips, and a swap choice for every item (best match, a chosen product or a refund).
- Paying: cards through Stripe Checkout with a signed webhook, cash on delivery with a cash limit per zone, and a wallet for refunds and top-ups that can never go below zero.
- Picking: new orders with an answer window, a pick list by aisle, barcode checks with the camera, missing items with swaps the shopper approves within five minutes (at the lower price), items added after ordering, bags and ready for pickup.
- Delivery: job offers to the nearest free driver in the zone, one at a time with a 30-second answer window, live tracking on the map for the shopper, chat, proof of delivery with a 4-digit code or a photo, cash handling, tips and ratings.
- Store panel (web): the live orders board, the catalogue with CSV import, stock, opening hours and special days, express settings, the team (owner, managers, pickers) with invitations, and reports.
- Super-admin (web): zones and fees, store applications and approval, commissions, drivers and their documents, orders and refunds to the card or the wallet, coupons, the weekly payouts report for stores and drivers, people, settings, branding, legal pages, a setup check that tests every outside service, and "open as owner" for support.
- Maps: OpenStreetMap with no key by default, or MapTiler or Google Maps; address search through the server.
- Push notifications through your own Firebase project, and an in-app list of notices.
- Install and hosting: an install wizard, one Docker Compose stack (PostgreSQL, MinIO, the app, optional Caddy HTTPS), any S3-compatible storage or a local folder, the Lakeport sample city with eight weeks of order history, and a public demo mode with one-click sign-ins, simulated drivers and a nightly reset.
- Security: Argon2id passwords, secure web sessions and app tokens, secrets encrypted at rest, rate limits kept in the database, uploads checked by their content, and every store's data kept apart on the server.
47Support and licence
Questions, bug reports and help with installation: use the Support tab on the item's page on the marketplace. Please include your Basketrun version, how you host it, which app and phone it is about, and what you see (a screenshot, or the lines from docker compose logs app). Never send your .env, keys, tokens, the Firebase service account or passwords.
Support covers questions about the item's features, help with bugs and help with installing it as described here. It does not cover custom changes to the code, publishing the apps in your developer accounts, or the setup and review of your accounts at Stripe, Google, Apple and other outside services, which are handled by those companies.
The Regular Licence lets you use Basketrun for one product whose end users are not charged. To take orders and payments from shoppers, you need the Envato Extended Licence. One licence covers one marketplace (one brand on one installation, with its three apps). The licences page at codecanyon.net/licenses/standard explains both licences in full.
Basketrun is not affiliated with, endorsed by or sponsored by Stripe, Google, Apple, Firebase or OpenStreetMap. Their names are trademarks of their owners.