Skip to content
insidebooksprojectPublic

About

Modern React frontend for Inside Books Project - inmate lookup and request tracking

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ibp-frontend

The web UI for the Inside Books Project (IBP) database. Volunteers use it to look up inmates (TDCJ and federal), log book requests, print package labels, add comments, manage prison units and shipping settings, and view metrics. It is a React + TypeScript single-page app built with Vite; all data comes from the FastAPI backend (insidebooksproject/backend) under /api/.

The header search takes a name, an inmate ID, or the request number printed on an old package label, but only numbers 264807-270049 (labels from roughly the six months before the 2026-11-02 cutover). Older request numbers look like 6-digit TDCJ inmate IDs, so they are searched as inmate IDs only. A number in the range is also searched as an inmate ID, and if that finds a different inmate, both are listed instead of redirecting. The range is set in src/lib/legacyRequest.ts and matches scan.js in book-portal-extension.

Error reports

The app reports unexpected errors to the backend's POST /api/client-errors (src/lib/errorReporting.ts), which appends them to client-errors.jsonl on ibp-server for the weekly error digest (design: docs/error-reporting.md in the IBP meta repo). Reported: uncaught errors (window error events), unhandled promise rejections, errors an ErrorBoundary catches, and React Query errors (the global QueryCache and MutationCache handlers in src/lib/queryClient.ts) that are a 5xx answer or a response that failed to parse. Network failures (the server can't be reached to take them) and 4xx answers, which the pages handle, are not. Each report is one event (level, app frontend, version, logger, msg, exc with the stack, and data.url, the page path without its query string); the backend adds ts and host. The same message goes at most once a minute per tab, with fetch(..., {keepalive: true}) so a report sent as the page closes still arrives. A report that fails is dropped, never reported. Nothing changes on the page.

version is VITE_APP_VERSION, set by the Docker build from its IBP_VERSION build argument (vX.Y.Z for a release, sha-<commit> for a build of main), and dev otherwise.

Development

Requires Node.js 20.19+ or 22.12+, as Vite 7 does (CI and the Docker build use Node 24).

npm ci
npm run dev

The dev server (http://localhost:5173) proxies /api to a backend on http://localhost:8000 (see server.proxy in vite.config.ts), so start the backend first (uv run fastapi dev ibp in a backend checkout).

Optional build-time environment variables (copy .env.example to .env.local):

Variable Default Purpose
VITE_API_BASE_URL /api Backend base URL; leave unset to go through the proxy (set it only for a backend at another origin with [server] cors_origins)
VITE_PRINT_SERVER_URL http://localhost:40121 Intake station's ibp-print-server (part of ibp-printing)

Checks

npm run lint         # ESLint
npm run typecheck    # tsc -b
npm run format:check # Prettier
npm run test:run     # Vitest, once
npm test             # Vitest, watch mode

Tests run in Vitest browser mode on headless Firefox via Playwright; install the browser once with npx playwright install firefox.

CI (.github/workflows/ci.yml) runs lint, format check, build and tests on every push and pull request to main.

Build

npm run build   # tsc -b && vite build, output in dist/
npm run preview # serve dist/ locally

Deployment

.github/workflows/docker.yml builds the Docker image (Dockerfile: a Node build stage, then nginx serving dist/) for amd64 and arm64 and publishes it to GHCR:

  • ghcr.io/insidebooksproject/frontend:main and :sha-<sha> for each push to main
  • ghcr.io/insidebooksproject/frontend:vX.Y.Z for each v* tag

Releases up to v1.0.19 were published as ghcr.io/jonkensta/ibp-frontend, before the repo moved to the organisation.

Production (ibp-server, a Raspberry Pi 4) runs a pinned release tag in the Docker Compose stack in the backend repo's deploy/pi/: set IBP_TAG in /srv/ibp/.env, then docker compose pull && docker compose up -d. IBP_TAG pins the backend and frontend images alike, so a release needs the same vX.Y.Z tag in both repos. See that directory's README for details.

nginx serves the app with an SPA fallback and proxies /api/ to the backend. The image's nginx.conf is HTTP only on port 80 and needs no certificates; it proxies to ibp-backend:8000, the backend's service name in the Pi stack, resolved through Docker's DNS at request time, so run the backend under that name on the same user-defined network. nginx starts without the backend and answers /api/ with 502 until it is up. The Pi stack mounts its own copy (deploy/pi/nginx.conf in the backend repo) over /etc/nginx/nginx.conf; keep the two files alike apart from their header comments.

About

Modern React frontend for Inside Books Project - inmate lookup and request tracking

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages