@@ -42,6 +42,22 @@ The API is defined using [Smithy](https://smithy.io/) models under `model/`. A g
4242
4343## Dev Setup
4444
45+ ### First-time setup (TL;DR)
46+
47+ ``` bash
48+ git clone < repo-url> && cd purpose-bound-accounts
49+
50+ nix develop # 1. enter the dev shell (Rust, Postgres, TigerBeetle, just, ...)
51+ cp .env.example .env # 2. create your local config from the template
52+ just run # 3. start Postgres + TigerBeetle + the app
53+ ```
54+
55+ Then open the ** Admin Dashboard** at < http://localhost:3030/admin > .
56+
57+ The default ` .env ` runs with auth disabled (` AUTH_ENABLED=false ` ), so no
58+ Keycloak/OIDC provider is needed to get started. The sections below explain
59+ each piece in more detail.
60+
4561### Prerequisites
4662
4763The easiest way to get all dependencies is via [ Nix] ( https://nixos.org/ ) :
@@ -50,14 +66,35 @@ The easiest way to get all dependencies is via [Nix](https://nixos.org/):
5066nix develop
5167```
5268
53- This provides Rust, PostgreSQL 16, TigerBeetle, Zig 0.14, just, sqlx-cli, cargo-watch, and Smithy CLI.
69+ This provides Rust 1.94, PostgreSQL 16, TigerBeetle, Zig 0.14, just, sqlx-cli,
70+ cargo-watch, cocogitto, process-compose, and the Smithy CLI — no other system
71+ setup required.
72+
73+ If you use [ direnv] ( https://direnv.net/ ) , run ` direnv allow ` once; the dev
74+ shell and your ` .env ` then load automatically whenever you ` cd ` into the repo.
5475
55- Alternatively, install manually via Homebrew:
76+ Alternatively, install manually via Homebrew (macOS) :
5677
5778``` bash
5879just install-deps
5980```
6081
82+ > ** Docker is _ not_ required** for the default dev flow. It is only needed if
83+ > you opt in to running Keycloak — see [ Authentication] ( #authentication ) .
84+
85+ ### Configure your environment
86+
87+ The service reads configuration from a ` .env ` file. It is git-ignored, so each
88+ clone needs its own — create one from the template:
89+
90+ ``` bash
91+ cp .env.example .env
92+ ```
93+
94+ The defaults work out of the box for local development. The full list of
95+ variables is in [ Configuration] ( #configuration ) ; the key one for first-time
96+ setup is ` AUTH_ENABLED=false ` , which lets you run without an OIDC provider.
97+
6198### Development workflow
6299
63100** Start everything (Postgres + TigerBeetle + app):**
@@ -128,20 +165,46 @@ just smithy-build # regenerate the Rust client SDK
128165
129166## Authentication
130167
131- PBA uses Keycloak for authentication. ` just run ` starts Keycloak alongside other services.
168+ ** Local dev runs with auth disabled.** The ` .env.example ` template sets
169+ ` AUTH_ENABLED=false ` , and the dev stack does ** not** start an OIDC provider, so
170+ ` just run ` leaves the Admin UI and API open — just navigate to
171+ ` http://localhost:3030/admin ` .
172+
173+ ### Enabling Keycloak (optional)
174+
175+ Keycloak is ** not** bundled in the dev stack. To test the real OIDC login flow
176+ locally, run it standalone (requires Docker), then point the service at it:
132177
133- ** Admin UI:** Navigate to ` http://localhost:3030/admin ` — you'll be redirected to Keycloak to log in.
134- Default credentials: ` admin@pba.local ` / ` admin `
178+ 1 . Start Keycloak with the bundled realm:
135179
136- ** API access:** Use the ` Authorization ` header with a base64-encoded ` client_id:client_secret ` :
180+ ``` bash
181+ docker run --rm --name pba-keycloak \
182+ -p 8180:8080 -m 2g \
183+ -v " $( pwd) /keycloak/realm-export.json:/opt/keycloak/data/import/realm-export.json:ro" \
184+ -e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
185+ -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
186+ -e JAVA_OPTS_KC_HEAP=" -XX:MaxRAMPercentage=50 -Xms256m -Xmx1024m -XX:UseSVE=0" \
187+ quay.io/keycloak/keycloak:26.0 \
188+ start-dev --import-realm
189+ ```
190+
191+ > ` -XX:UseSVE=0 ` works around a JVM crash on Apple Silicon (M-series); the
192+ > heap flags and ` -m 2g ` keep Keycloak from starving the rest of the stack.
193+
194+ 2 . Set ` AUTH_ENABLED=true ` in your ` .env ` .
195+ 3 . ` just run ` (or ` just run-service ` ) — the service now uses Keycloak for auth.
196+
197+ ** Admin UI:** Navigate to ` http://localhost:3030/admin ` — you'll be redirected
198+ to Keycloak to log in. Default credentials: ` admin@pba.local ` / ` admin `
199+
200+ ** API access:** Use the ` Authorization ` header with a base64-encoded
201+ ` client_id:client_secret ` :
137202
138203``` bash
139204API_KEY=$( echo -n " pba-api:pba-api-secret" | base64)
140205curl -H " Authorization: ApiKey $API_KEY " http://localhost:3030/purpose-types
141206```
142207
143- ** Disable auth (development):** Set ` AUTH_ENABLED=false ` in your ` .env ` file.
144-
145208## Configuration
146209
147210Environment variables (loaded from ` .env ` ):
@@ -158,10 +221,10 @@ Environment variables (loaded from `.env`):
158221| ` HOST ` | ` 0.0.0.0 ` | Bind address |
159222| ` PORT ` | ` 3030 ` | HTTP port |
160223| ` RUST_LOG ` | ` pba_service=debug,tower_http=info ` | Log level (` tower_http=info ` enables per-request access logs) |
161- | ` OIDC_ISSUER_URL ` | ` http://localhost:8180/realms/pba ` | OIDC provider issuer URL (discovery via ` .well-known/openid-configuration ` ) |
162- | ` OIDC_CLIENT_ID ` | ` pba-admin ` | OIDC client ID for admin UI login flow |
224+ | ` OIDC_ISSUER_URL ` | ` http://localhost:8180/realms/pba ` | OIDC provider issuer URL (only used when ` AUTH_ENABLED=true ` ) |
225+ | ` OIDC_CLIENT_ID ` | ` pba-admin ` | OIDC client ID for admin UI login flow (only used when ` AUTH_ENABLED=true ` ) |
163226| ` COOKIE_SECRET ` | _ (dev default)_ | 32+ byte secret for session cookie signing |
164- | ` AUTH_ENABLED ` | ` true ` | Set to ` false ` to disable auth |
227+ | ` AUTH_ENABLED ` | ` true ` (code) / ` false ` (dev ` .env ` ) | Set to ` false ` to disable auth. ` .env.example ` ships with ` false ` for local dev |
165228| ` PATH_PREFIX ` | _ (empty)_ | URL prefix for reverse proxy / ingress (e.g., ` /pba ` ) |
166229
167230## Available just targets
0 commit comments