Skip to content

Commit ece6038

Browse files
committed
UPDATE Document canonical palette.db build + runtime paths
Signed-off-by: ParleSec <mason@masonparle.com>
1 parent 6620576 commit ece6038

7 files changed

Lines changed: 83 additions & 3 deletions

File tree

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Run the smallest set that covers your change. CI may run additional checks, but
198198
| Docker or service topology | `cd docker && docker compose config` and, when practical, `docker compose up -d` |
199199
| OID4VCI/OID4VP protocol behavior | `cd backend && go test ./internal/protocols/oid4vci ./internal/protocols/oid4vp -count=1` |
200200
| Palette content (`content/**`) | `cd backend && go run ./cmd/content-validate -content ../content && go test ./internal/palette/...` |
201-
| Palette indexer or query service | `cd backend && go test ./internal/palette/... && go run ./cmd/palette-indexer -content ../content -out ../frontend/public/palette.db` |
201+
| Palette indexer or query service | `cd backend && go test ./internal/palette/... && go run ./cmd/palette-indexer -content ../content -out ./dist/palette.db` |
202202

203203
When Snyk or other security scans are skipped for forked PRs because repository secrets are unavailable, maintainers may rerun or review those checks after initial triage.
204204

@@ -298,15 +298,19 @@ A deploy-time Go binary builds the runtime SQLite file:
298298

299299
```bash
300300
cd backend
301-
go run ./cmd/palette-indexer -content ../content -out ../frontend/public/palette.db
301+
go run ./cmd/palette-indexer -content ../content -out ./dist/palette.db
302302
```
303303

304304
The build is idempotent — same input produces byte-identical output. Backed by SQLite FTS5 plus structured tables (`artefacts`, `axis_values`, `edges`, `aliases`).
305305

306+
**Canonical paths:** local and CI builds write `backend/dist/palette.db`. Production Docker images (`docker/Dockerfile.backend`, `docker/Dockerfile.fly`) run the indexer at image build time and copy the file to `/app/palette.db`, exposed via `SHOWCASE_PALETTE_DB=/app/palette.db`. Content changes require a backend image rebuild (or a mounted volume at that path for self-hosted monoliths).
307+
306308
### Query service
307309

308310
Mounted at `POST /api/palette/query`. Implementation lives in `backend/internal/palette/`. The pipeline is parse → candidates → rank → match-reason emission → refinement chips. P99 latency budget is 20ms in-process. Tunable weights live in `rank.go`.
309311

312+
Production requires `SHOWCASE_PALETTE_DB` pointing at a readable index file; the server refuses to start in `SHOWCASE_ENV=production` if the path is missing or unreadable. Docker images built from `docker/Dockerfile.backend` and `docker/Dockerfile.fly` bake `/app/palette.db` and set the variable automatically. Verify with `GET /health` (`palette.loaded`) or `GET /api` (`endpoints.palette`).
313+
310314
### Frontend surfaces
311315

312316
Two mount points share one component (`frontend/src/components/palette/Palette.tsx`):

backend/cmd/palette-indexer/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
// content tree. The output file is deterministic for fixed input: running the
33
// indexer twice on the same tree produces a byte-identical database, which is
44
// what lets CI compare deploy artefacts.
5+
//
6+
// Canonical paths:
7+
// - Build-time output (local/CI): backend/dist/palette.db (-out ./dist/palette.db from backend/)
8+
// - Container build output: /app/palette.db (Dockerfile.backend / Dockerfile.fly)
9+
// - Runtime (containers): /app/palette.db (SHOWCASE_PALETTE_DB)
10+
//
11+
// The index is a backend artefact served by Go at POST /api/palette/query, not
12+
// a frontend static file.
513
package main
614

715
import (

docs/starlight/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export default defineConfig({
8888
{ slug: 'deploy/deployment-models' },
8989
{ slug: 'deploy/release-and-tag-policy' },
9090
{ slug: 'deploy/environment-variables' },
91+
{ slug: 'deploy/palette-index' },
9192
{
9293
label: 'Services',
9394
items: [

docs/starlight/src/content/docs/deploy/deployment-models.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ docker compose -f docker-compose.simple.yml up -d
6565

6666
**Best for:** Quick evaluation of core federation protocols without multi-service overhead.
6767

68+
The simple monolith image builds the [palette content index](/deploy/palette-index/) at image build time (`/app/palette.db`). Homepage search and cmd+K require that file and `SHOWCASE_PALETTE_DB`.
69+
6870
## Model 4: Custom Topology
6971

7072
Combine selected GHCR images with your own infrastructure.

docs/starlight/src/content/docs/deploy/environment-variables.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ All ProtocolSoup backend services share a common set of core variables. Individu
1717
| `SHOWCASE_ENV` | `demo` | Runtime environment. |
1818
| `SHOWCASE_MOCK_IDP` | `true` | Enable built-in mock identity provider with demo users and clients. |
1919
| `SHOWCASE_DEBUG` | `false` | Enable debug logging. |
20+
| `SHOWCASE_PALETTE_DB` | *(empty — palette disabled)* | Path to the prebuilt palette SQLite index. Required in `SHOWCASE_ENV=production` when palette search is enabled. Docker images built from `Dockerfile.backend` and `Dockerfile.fly` default to `/app/palette.db`. See [Palette content index](/deploy/palette-index/). |
2021

2122
## Gateway
2223

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: "Palette content index"
3+
description: "How monolith deployments ship and mount the palette SQLite index for homepage search and cmd+K."
4+
---
5+
6+
# Palette content index
7+
8+
The homepage search bar and global **cmd+K** palette query a prebuilt SQLite index (`palette.db`) produced from the repository `content/` tree. The index is a **backend artefact**: Go serves `POST /api/palette/query`; it is not bundled as a Next.js static file.
9+
10+
## Canonical paths
11+
12+
| Context | Path |
13+
|---------|------|
14+
| Local / CI build output | `backend/dist/palette.db` |
15+
| Baked into Docker images | `/app/palette.db` |
16+
| Runtime configuration | `SHOWCASE_PALETTE_DB=/app/palette.db` |
17+
18+
Build the index locally:
19+
20+
```bash
21+
cd backend
22+
go run ./cmd/palette-indexer -content ../content -out ./dist/palette.db
23+
```
24+
25+
## Baked into the image (recommended)
26+
27+
`docker/Dockerfile.backend` and `docker/Dockerfile.fly` compile `palette-indexer`, run it against `/content` at **image build time**, copy `/app/palette.db` into the runtime layer, and set `SHOWCASE_PALETTE_DB=/app/palette.db`.
28+
29+
**Implication:** changing `content/` requires rebuilding the backend (or monolith) image even when no Go source changed.
30+
31+
Verify after deploy:
32+
33+
```bash
34+
curl -s https://your-host/health | jq '.palette'
35+
curl -s https://your-host/api | jq '.endpoints.palette'
36+
curl -sf -X POST https://your-host/api/palette/query \
37+
-H 'content-type: application/json' \
38+
-d '{"q":"pkce"}' | jq '.results | length'
39+
```
40+
41+
In `SHOWCASE_ENV=production`, the server **refuses to start** if `SHOWCASE_PALETTE_DB` is unset or the file cannot be opened.
42+
43+
## Mounted as a volume (self-hosted)
44+
45+
For custom monolith deployments, build the index on a host or in CI and mount it at the canonical path:
46+
47+
```yaml
48+
services:
49+
backend:
50+
image: ghcr.io/parlesec/protocolsoup-federation:latest
51+
environment:
52+
SHOWCASE_ENV: production
53+
SHOWCASE_PALETTE_DB: /app/palette.db
54+
volumes:
55+
- ./backend/dist/palette.db:/app/palette.db:ro
56+
```
57+
58+
Rebuild the index whenever `content/` changes, then restart the backend.
59+
60+
## Related
61+
62+
- [Deployment models](/deploy/deployment-models/) — Model 3 (simple monolith) includes the baked index via `Dockerfile.backend`
63+
- [Environment variables](/deploy/environment-variables/) — `SHOWCASE_PALETTE_DB`
64+
- Contributor guide: palette section in the repository `CONTRIBUTING.md`

docs/starlight/src/content/docs/developers/development-setup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Run the smallest set that covers your change before requesting review.
7979
| Docker or service topology | `cd docker && docker compose config` |
8080
| OID4VCI/OID4VP conformance | `cd backend && go test ./internal/protocols/oid4vci ./internal/protocols/oid4vp -count=1` |
8181
| Palette content (`content/**`) | `cd backend && go run ./cmd/content-validate -content ../content && go test ./internal/palette/...` |
82-
| Palette indexer or query service | `cd backend && go test ./internal/palette/... && go run ./cmd/palette-indexer -content ../content -out ../frontend/public/palette.db` |
82+
| Palette indexer or query service | `cd backend && go test ./internal/palette/... && go run ./cmd/palette-indexer -content ../content -out ./dist/palette.db` |
8383

8484
The canonical contract for palette artefacts lives in [`content/SCHEMA.md`](https://github.com/ParleSec/ProtocolSoup/blob/master/content/SCHEMA.md). New axis values must be added to `content/taxonomy.yaml`, and synonyms to `content/aliases.yaml`. Both files are validated in CI by `cmd/content-validate`.
8585

0 commit comments

Comments
 (0)