Kvrt
✦ ✦ ✦
Case study · Nº 01 · Public health

Fibro+

A platform that turns scattered fibromyalgia care into structured follow-up, an official document and indicators for public health. It started at a hackathon and is now in production in a municipal health network.

I · The problem

A pain that doesn’t show up on scans.

Fibromyalgia brings widespread pain, fatigue, poor sleep and brain fog, and it does not show up on imaging. Follow-up happens on paper, over WhatsApp and from memory. Information gets lost along the way, and three groups pay for it.

Who suffers · 1patient

The patient forgets

Between appointments she forgets how she felt and which medication she took. She hears that she “doesn’t look sick”. And she does not own her own data.

Who suffers · 2clinician

The doctor can’t see progress

Reports arrive incomplete and without history. There is no way to tell whether the patient got better or worse since the last visit.

Who suffers · 3public health

The city doesn’t know the scale

There are no indicators to plan with: the city does not know how many residents live with fibromyalgia or how they are doing.

Why now: Brazilian federal law 15.176/2025 recognises that fibromyalgia may qualify as a disability, based on a biopsychosocial assessment. That puts an obligation on cities: enrol, assess and follow up. On the city side the users are health staff, not IT people; on the patient side, people living with fatigue and brain fog. Screens had to be simple, with few steps.

II · What I built

Four capabilities, one system.

The idea started as AlgiaAnalysis, which won 1st place at the 1st TechWeek. It became a Laravel API and an Angular dashboard, now in production in a municipal health network. This is what exists today.

Capability 1enrollment

Enrollment

  • Patient self-signup, or a spreadsheet import by the city
  • Document upload (medical report, biopsychosocial assessment, photo) with human review
  • Staff decision: approve, ask for changes or reject, with a support level from 1 to 3
Capability 2ID card

Digital ID card with QR

  • Card with number, expiry date and photo, batch-printed to PDF
  • Encrypted QR that gives a doctor read-only access for 25 minutes, no login, revocable
  • Public page to check whether a printed card is authentic
Capability 3follow-up

Monitoring

  • Symptom diary with a body map and a medication log
  • Versioned clinical questionnaires: FIQR, PSQI and PHQ-9
  • Clinical alerts for staff, with an acknowledgement record
Capability 4indicators

Indicators for public health

  • Aggregates per city, computed every night
  • No breakdown with fewer than 5 people (k ≥ 5), so nobody can be singled out
  • Underneath it all: 6 access levels, an audit trail for every action and LGPD data protection
Fig. 1 · Public page at fibromais.com.br: what the platform does and who it is for.
Fig. 2 · Enrollment review: uploaded documents, decision and support level. Fictional data.
Fig. 3 · The clinical record only opens with a stated reason. Who read what, and when, is logged, and access lasts 30 minutes. Fictional data.
Fig. 4 · Audit trail: who did what, when, on which record. Clinical content never shows here. Fictional data.
III · Architecture decisions

Every choice has a price.

Very few people maintain this system, and much of the code is written with AI. So the rules had to be executable: when someone (or an agent) breaks one, a test fails.

  1. Decision 01

    A modular monolith, with boundaries enforced in CI

    Why

    One deploy and seven modules with clear owners. A module cannot import another module’s classes: it talks through a contract, an event or a read model. An architecture test fails the build if anyone crosses the line.

    The trade-off

    More ceremony for simple things: even a permission check outside the access module has to go through the core.

  2. Decision 02

    One customer = one entity, filtered automatically

    Why

    The customer is a city or an inter-city consortium. Every row carries its entity, and a global scope adds the filter to every query. Leaking data between cities cannot depend on someone remembering a where.

    The trade-off

    The platform admin has no entity. That role needed its own rule, which works out the entity from the record being touched.

  3. Decision 03

    Personal data encrypted at rest, searched by blind index

    Why

    National ID (CPF), health card number, phones, birth date and free clinical text are encrypted. Exact CPF lookup uses an HMAC of the digits. Uploaded files are encrypted too.

    The trade-off

    There is no partial CPF search, and sorting by CPF falls back to name order. Losing the app key means losing the data, so it is backed up off the server.

  4. Decision 04

    Nothing is ever really deleted

    Why

    Health data has a legal retention period and needs a trail. Deleting is a cascading soft delete with a preview of everything that goes with it, and the admin can restore it.

    The trade-off

    Postgres unique indexes do not skip soft-deleted rows. Re-registering a deleted CPF used to throw a 500; it now returns a clear message.

  5. Decision 05

    Doctors get in through the QR, not an account

    Why

    A doctor outside the network has no login. The patient shows the QR and the doctor reads the clinical summary. The token is encrypted, lasts 25 minutes and can be revoked.

    The trade-off

    Access is read-only and expires. To look again, the patient generates a new QR. Every read is logged.

IV · What went wrong

Four real problems and what they left behind.

None of these were business-rule bugs. Every one sat on a seam: the server, the database, the bundle or the contract between front end and API.

Case 01infrastructure

Deploys took the site down

Symptom
After some deploys the site answered 504 or 404, and CI ended with Run Command Timeout.
Cause
Production and staging share one VPS with 4 GB of RAM, 1 CPU and no swap. Two front-end builds at once ran it out of memory.
Fix
2 GB of swap; builds go to a fresh folder and swap in atomically, with memory and time limits; a health check rolls back to the previous version on failure; and a lock queues front and back deploys from both environments.

LessonThe code was fine. The box lacked capacity, and the deploy had to learn to fail without taking the site down.

Case 02database

A transaction poisoned by the audit log

Symptom
Running all migrations from scratch on an empty Postgres failed inside an old migration that had nothing wrong with it.
Cause
The audit observer wrote to a column that only appeared in a later migration. A try/catch swallowed the error, but Postgres had already aborted the transaction (25P02), so everything after it failed.
Fix
The foreign-key migration now skips tables and columns that do not exist yet, and a new database is built from the restore dump. A clean from-scratch migrate on Postgres is still an open item.

LessonIn Postgres, swallowing an exception does not save the transaction. Errors inside a transaction have to bubble up.

Case 03front end · bundle

The ID-card PDF only broke in production

Symptom
Batch export worked on the dev server and failed on the live site.
Cause
The qrcode library is CommonJS. In the production bundle the default import arrived in a different shape than in dev.
Fix
Every import is now const { default: QRCode } = await import('qrcode'). Exports are tested against the production build with a real download in Playwright.

LessonThe dev server hides bundle differences. Anything that produces a file gets tested on the production build.

Case 04front-end × API contract

The doctor silently vanished for months

Symptom
When approving an enrollment, the name and licence of the responsible clinician never showed up after saving.
Cause
The form sent professional_name and professional_license; the API validated doctor_name and doctor_license. Unknown keys are ignored, so nothing ever errored.
Fix
The payload now has a type with the API’s exact keys. When a value “gets ignored”, the first check is front-end keys against the Action’s validation rules.

LessonNo error is not proof that it worked. A front-end/API contract needs types on both sides.

V · Numbers

What you can check.

Only numbers taken from the code, the test runs or the project docs. No patient data.

1,329automated tests, all passing802 Pest on the API + 527 Vitest on the front end · run on Dec 2, 2026
5,134assertions in the API suitePest output · Dec 2, 2026
7modules in the APIapp-modules folder in the repository
6access levels with fine-grained permissionsproject CLAUDE.md
3clinical instruments: FIQR, PSQI, PHQ-9docs/dominio/QUESTIONARIOS.md
25minlifetime of the doctor’s QRCLAUDE.md · ID card
k ≥ 5minimum group size for any indicatorindicator anonymisation rule
368commits: 223 API, 145 front endgit log · Jul to Dec 2026

The main page says “1300+ tests”; the count above is from the day this case study was written.