REST API for Kibooz, a kindergarten app that tracks moods and rewards trash sorting
10K+
REST API for Kibooz, the kindergarten app that lets teachers record children's moods, lets parents follow them, and rewards trash sorting with points on a class leaderboard.
The source code, issues and documentation are on GitHub. The API reference, with every route, field, limit and error code, is at https://docs.kibooz.syafahadyan.com. The project is licensed under GPL-3.0.
Apps that call the API should read the client guide on the tokens, the device token and the rate limits.
| Tag | What it is |
|---|---|
latest | The newest build of the main branch |
x.y.z, x.y, x | A release, for example 0.4.0, 0.4 and 0. Pin x.y.z in production |
sha-<commit> | The build of one commit |
pr-<number> | The build of a pull request, for testing only |
linux/amd64 and linux/arm64, so it also runs on Apple silicon and ARM servers. Releases up to 0.3.0 are linux/amd64 only/healthz, which answers 200 when the database is up even if Redis is down/healthz reports degradedThe repository ships a production Compose stack with the API, PostgreSQL and Redis.
curl -O https://raw.githubusercontent.com/SyafaHadyan/kibooz-backend/main/compose.yml
curl -o .env https://raw.githubusercontent.com/SyafaHadyan/kibooz-backend/main/.env.example
# edit .env and set DB_NAME, DB_USERNAME, DB_PASSWORD, REDIS_PASSWORD, JWT_SECRET_KEY and S3_*
docker compose up -d
To run only the API against a PostgreSQL you already have, use this.
docker run -d --name kibooz-backend -p 8080:8080 \
-e DB_HOST=your-postgres-host -e DB_NAME=kibooz -e DB_USERNAME=kibooz -e DB_PASSWORD=change-me \
-e JWT_SECRET_KEY=at-least-32-random-characters \
syafa/kibooz-backend:latest
Every setting is an environment variable. The main ones are below, and the full list is in the README.
| Variable | Default | Purpose |
|---|---|---|
DB_HOST, DB_PORT | 127.0.0.1, 5432 | PostgreSQL address |
DB_NAME, DB_USERNAME, DB_PASSWORD | required | PostgreSQL database and credentials |
JWT_SECRET_KEY | required | Signing key, at least 32 characters |
REDIS_ADDRESS, REDIS_PORT, REDIS_PASSWORD | 127.0.0.1, 6379 | Optional Redis, set REDIS_TLS=true for hosted Redis that needs TLS |
S3_* | empty | Optional object storage for uploads |
APP_PORT | 8080 | HTTP port |
APP_TIMEZONE | Asia/Jakarta | School timezone used for "today" and the weekly chart |
USER_LIMITER_MAX, AUTH_LIMITER_MAX | 120, 10 | Requests per minute for each signed-in user and for each account on login, register, refresh and logout |
DEVICE_TOKEN_TTL_DAYS | 90 | Days that a device token from login stays valid, so a returning device keeps its own login limit |
Put a reverse proxy with TLS in front of the API. The API does not set Strict-Transport-Security, so enable it on the proxy. Rate limits count users and accounts and never IP addresses, so add a request limit on the proxy or CDN to protect the public auth routes from floods.
Content type
Image
Digest
sha256:7c1dc5be2…
Size
12.4 MB
Last updated
3 days ago
docker pull syafa/kibooz-backend