Education that saves lives. Nearly 3 million workers die from work-related causes every year, and 395 million more suffer non-fatal injuries (ILO, 2023). Education does not end at graduation: for the adults who build, manufacture, maintain, and research, workplace safety training is the education with the highest stakes of all — and it is proven to work.
Japan is the proof. Its workplace deaths fell from a peak of 6,712 in 1961 to 746 in 2024 — a reduction of nearly 90% — and its occupational fatality rate of roughly 1.3 per 100,000 workers is about one-third of the US rate of 3.5 (BLS, 2023). Behind that curve is a workplace training culture, and one of its pillars is KYT — Kiken Yochi Training, or Hazard Prediction Training — a participatory group practice born on Japanese factory floors in 1974 and repeated daily before work begins.
KYTLab brings that proven method beyond Japan as a collaborative English application. Facilitators prepare reusable work scenarios, generate realistic text-free illustrations, and guide teams from observable dangers to practical actions and a verifiable team commitment. AI coaches the reasoning without replacing it: AI proposes, people decide.
KYT Lab is being submitted to the OpenAI Build Week Education track. Watch the three-minute demo video. Its creator motivation, educational framing, GPT-5.6 design, and concrete Codex use cases are documented in the Build Week submission narrative.
New sessions use a guided workflow with two modes — Standard training and the short Daily one-danger practice — described in the novice worker workflow guide. Sessions recorded before this release keep their original four-round rules and reports.
The current build includes:
- the Field Guide product design across public, dashboard, preparation, library, session, reference, and report URLs;
- an optional, concise three-step setup guide that remembers when automatic guidance is disabled;
- streamlined two-field scenario creation with reusable templates and an existing-image starting point;
- ElysiaJS API and Better Auth email/password authentication;
- PostgreSQL persistence through Prisma and Redis-backed realtime presence/pub-sub;
- team membership, invitation links, participant/facilitator permissions, and read-only records;
- guided version-2 sessions: the cause-to-outcome danger sentence builder, one focus danger, structured who/what/when/how-confirmed practical actions, a generated team commitment, a
— CHECK!pointing call with a three-repeat team call, and deterministic strengths-first feedback; - full compatibility for version-1 sessions: all four rounds, three-vote limits, one-or-two key-hazard validation, the 3×3 risk matrix, controls, goals, primary goal selection, shared notes, and the closing team call;
- direct OpenAI Responses API Structured Outputs with
gpt-5.6-lunaand realistic Image API generation withgpt-image-2; - durable database-backed image jobs with retry/reconciliation, local file storage, and private file access;
- a browser-print report, English method guide, four worked scenarios, responsive layouts, dark mode, and an offline PWA shell.
Requirements: Bun 1.3+ and Docker. uv is only needed for the repository hooks, and an OpenAI API key is optional unless you want to use AI text or image generation.
From the repository root, run:
bun install
export BETTER_AUTH_SECRET="$(openssl rand -base64 48)"
export BETTER_AUTH_URL="http://127.0.0.1:3000"
bun run docker:up:app
docker compose --profile app exec -T api bun prisma/seed.tsOpen http://127.0.0.1:3000. The first startup builds the API and web images, applies database migrations, waits for PostgreSQL, Redis, and MinIO, and starts the full application. The seed command is idempotent and installs the seven worked scenarios.
To enable AI features, export OPENAI_API_KEY before starting the stack. Check the running services and API readiness with:
docker compose --profile app ps
curl --fail http://127.0.0.1:3000/readyzStop the app without deleting its database or object-storage volumes with:
docker compose --profile app downCopy the development environment once, replace BETTER_AUTH_SECRET with at least 32 random characters, and optionally set OPENAI_API_KEY:
bun install
cp .env.example .env
bun run docker:up
bun run db:deploy
bun run db:seed
bun run devOpen http://127.0.0.1:3000. Vite serves the web app on port 3000 and proxies the Elysia API on port 3001. Docker exposes PostgreSQL on 55432, Redis on 56379, MinIO on 59000, and the MinIO console on 59001. Hot-reload development uses local file storage unless S3 settings are added to .env.
bun run format:check
bun run lint
bun run typecheck
bun run build
bun run test
bun run e2eInstall and run the shared pre-commit checks with:
uvx --from pre-commit==4.6.0 pre-commit install
uvx --from pre-commit==4.6.0 pre-commit run --all-filesUseful data commands:
bun run db:generate
bun run db:migrate
bun run db:deploy
bun run db:seed # installs seven worked scenarios and their pre-generated images
bun run db:seed:images # optional; generates only custom scenarios that lack an image
bun run check:readyapps/web React 19 + Vite Field Guide interface and PWA shell
apps/api ElysiaJS, Better Auth, OpenAI, realtime, storage, image jobs
packages/shared workflow types, validation gates, terminology, risk matrix
prisma PostgreSQL schema, migrations, and seven English scenarios
Browser ── /api + /api/ws ──> Elysia ──> PostgreSQL
├─────> Redis pub/sub + presence
├─────> local/S3-compatible storage boundary
└─────> OpenAI Responses + Image APIs
Development uses Vite’s same-origin proxy. Production should route /api/* to Elysia and all other paths to the web service under one public origin so Better Auth cookies remain same-site.
Container builds, dependency topology, separate migration jobs, storage choices, probes, backup guidance, and release sequencing are documented in the deployment guide.
OPENAI_TEXT_MODEL=gpt-5.6-lunausesresponses.parsewith schemas generated from Zod.OPENAI_IMAGE_MODEL=gpt-image-2uses the direct Image API at a configurable supported landscape size.storeis false unlessOPENAI_STORE_RESPONSES=trueis explicitly selected after privacy review.- AI requests are rate limited; whole-round jobs use token-safe distributed locks.
- Suggestions are advisory and never silently applied. Per-item suggestions first populate an editable draft.
- Provider failures are logged internally and browsers receive a generic error with a correlation ID.
KYTLab supports facilitated safety training. It does not replace a task-specific risk assessment, safe work procedure, competent supervision, or applicable legal and organizational requirements. The team must verify all AI-generated content before use.