MediaRecorder handling and the API call live in lib/, not in ui/, so
TreatmentDetailsEditor can stay presentational and take only a `voice` prop.
Container choice is made at record time and needs no transcode: Chrome and
Android give webm/opus, Safari and iPad give mp4/aac, and the transcription
endpoint accepts both. Safari's `audio/mp4` is sent as `m4a`, the name the
vendor's container list actually uses, so iPad recordings do not fail while
Chrome works. Older Safari shipped MediaRecorder without isTypeSupported, so
that path lets the browser choose rather than refusing outright.
From review of this commit:
- The auto-stop at maxMs guaranteed a 413. The client measures the final length
after the recorder has stopped, so a recording that runs to the cap always
reports slightly over it, and the server rejected exactly the recording the
auto-stop existed to save. The server now allows a documented 2s tolerance and
the client keeps reporting the true length, so telemetry stays honest.
- getUserMedia is async, so a permission granted after unmount installed a live
stream the cleanup effect had already run past — leaving the browser's
recording indicator lit with nothing listening. Guarded with a mounted ref.
- Client-side failures are now ApiError-shaped ({code, statusCode}) rather than
bare Errors, because getUserFacingError only resolves that shape; without it
errors.VOICE_MIC_DENIED was dead in all three locales.
Cancelling aborts the request, which closes the connection and aborts the
metered vendor call server-side rather than letting it settle unseen. The level
meter is best-effort: a blocked AudioContext costs the meter, not the recording.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Dyolink — Backend (NestJS)
Prerequisites
- Node.js 20+ and npm
- PostgreSQL reachable from your machine — either installed locally or run via Docker (see below)
First-time setup
-
Clone the monorepo and go to the backend app:
git clone <repository-url> dyolink cd dyolink/backend -
Install dependencies
npm install -
Environment
Copy
.env.exampleto.envand set at least:DATABASE_URL— PostgreSQL connection string for your dev databaseJWT_SECRET— strong secret for signing tokens
Do not commit.env.
-
Database for local dev
Option A — Postgres in Docker (no local install, e.g. Mac)
Frombackend/, with.envpresent (copy from.env.examplefirst):- Ensure
DATABASE_URLuseslocalhostas the host (notpostgres). Match user, password, and DB name toPOSTGRES_USER,POSTGRES_PASSWORD, andPOSTGRES_DBin the same file.
docker compose -f docker-compose.postgres.yml up -dWait until Postgres is healthy (
docker compose -f docker-compose.postgres.yml ps). The container creates the database on first start.To stop Postgres (data is kept in the named volume):
docker compose -f docker-compose.postgres.yml downOption B — Postgres installed on the machine
Create an empty database, then pointDATABASE_URLat it. - Ensure
-
Generate Prisma Client
npm run prisma:generate -
Apply migrations (creates/updates tables to match
prisma/schema.prisma)npm run prisma:migrateThis runs
prisma migrate dev. Use it during development when the schema changes. -
Seed (optional — reference data only)
npm run prisma:seedThis does not wipe your database. It only upserts lookup data: organization types (
CLINIC,LAB), subscription plans, and tab permissions. Existing users, organizations, memberships, patients, appointments, and links are left unchanged.To start from an empty database with fresh tables and reference data, see Reset database (clean slate) below.
Reset database (clean slate)
Use this when you want to delete all application data (users, organizations, patients, sessions, etc.) and rebuild the schema from migrations, then run the seed.
From backend/:
npx prisma migrate reset
Prisma will prompt for confirmation, drop the database, re-apply all migrations, and run prisma/seed.ts automatically.
What gets removed: everything in the database, including organizations and all related rows.
What the seed adds back: only reference data (types, plans, permissions) — not demo users or organizations. Register again or use your own test data after a reset.
Docker Postgres dev: if you also want to wipe the Docker volume (not only tables), stop the container and remove the volume:
docker compose -f docker-compose.postgres.yml down -v
docker compose -f docker-compose.postgres.yml up -d
npm run prisma:migrate
npm run prisma:seed
Do not run migrate reset against production or shared staging databases.
Run (development)
npm run start:dev
API listens on http://localhost:3000 by default (PORT in .env).
If the frontend runs on another origin (e.g. http://localhost:3001), set FRONTEND_URL in .env to that URL (CORS and invite links use it).
After pulling latest main
git pull
npm install
npm run prisma:generate
npm run prisma:migrate
If teammates added migrations, the migrate step above applies them. Resolve migration conflicts locally before pushing.
Useful commands
| Command | Purpose |
|---|---|
npm run prisma:generate |
Regenerate client after schema.prisma changes |
npm run prisma:migrate |
Dev migrations (migrate dev) |
npm run prisma:deploy |
Production-style apply (migrate deploy) — e.g. CI/containers |
npm run prisma:seed |
Upsert reference data only (does not clear existing rows) |
npx prisma migrate reset |
Drop DB, re-migrate, run seed — dev clean slate |
npm run build |
Compile Nest app |
npm run start:prod |
Run compiled app (node dist/main) |
Docker
| File | Purpose |
|---|---|
Dockerfile |
Production API image |
docker-compose.postgres.yml |
Local dev Postgres only (port mapped to host) |
For full-stack deployment and CI, see the repository root README.md.