Skip to content
samuelcsantanaPublic

About

Cygnus — children's health, organized: Brazil's PNI vaccine schedule, checkups, WHO growth charts, milestones and medications, shared across the family. React 19 + strict TypeScript. Try the live demo, no sign-up.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

214 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cygnus: vaccines, checkups and growth, all in one place. A laptop shows the dashboard of the demo family, and a phone shows the vaccine list in dark mode.

Try the live demo: no sign-up, a sample family that is deleted after 24 hours.
Design system · API repository · Coverage report · Releases

CI status Production deployment on Vercel Unit test line coverage Live app status
Live demo, no sign-up Design system on Storybook Accessibility: axe runs on every story and a violation fails CI Latest release MIT License
React 19 TypeScript strict Vite 8 Tailwind CSS 4 TanStack Query 5 Storybook 10

Cygnus

Cygnus is a mobile-first web app where parents keep their children's health record in one place: Brazil's National Immunization Program (PNI) schedule, with what was given and what is overdue; doctor visits; weight and height on the WHO growth charts; developmental milestones with photos; medications, professionals and health plans. A record can be shared with every person who helps care, so it does not live in one parent's drawer. Portuguese, English and Spanish; light and dark.

This repository is the frontend. The backend is cygnus-api. Both are a portfolio project, built the way a product is built: tests, an accessible design system, a public contract between the two halves, production deploys, privacy terms and observability.

Cygnus organizes information. It does not replace advice from healthcare professionals.

Screens

Taken from the live demo by scripts/render-readme-assets.mjs. They follow your GitHub theme.

The landing page: headline, the buttons to try the demo or create an account, and a preview of a child's vaccine card.

Landing page, which never waits for the API

The dashboard of the demo family: two children, upcoming appointments, vaccine progress, growth and milestones.

Dashboard for the whole family

The vaccine list: progress through the routine doses, filters by status, and an overdue dose at the top.

Vaccines on the PNI schedule

Weight and height charts over the WHO reference bands, with the recorded measurements below.

Growth over the WHO reference bands

The dashboard on a phone, light theme. The vaccine list on a phone, light theme. The dashboard on a phone, dark theme. The vaccine list on a phone, dark theme.

What is worth reading here

The decisions below are the ones a reviewer would ask about. Each names the file where it lives.

  • No token ever reaches JavaScript. Sessions are HttpOnly, SameSite=Strict cookies. Concurrent 401s share one silent POST /auth/refresh and retry once, and mutating requests echo the readable csrf_token cookie as X-CSRF-Token (double-submit). All three live in src/lib/http-client.ts and nowhere else. Strict cookies do not travel to a cross-site host, so production calls the API through a same-origin Vercel rewrite (vercel.json).
  • Every response is parsed at the boundary. Each *.api.ts fetches unknown and returns a Zod-parsed type, so a contract drift surfaces as a validation error with a path, not as a broken render three components later. In CI, npm run contract:check compares the mapped schemas with the openapi.json the API commits (scripts/).
  • Accessibility is a build gate, not a panel. Every Storybook story runs axe in the light and the dark theme, and a violation fails CI. There is no exception list. Four colour tokens in src/index.css deliberately differ from the design reference, because the reference values measured below WCAG AA; each says so where it is defined.
  • The landing page never waits for the API. The API runs on a free Render instance that sleeps and takes about a minute to wake. The session cookies are HttpOnly, so the readable csrf_token cookie is the hint: without it, / renders at once and sends no request (LandingRoute.tsx).
  • A demo without sign-up. "Try the demo" asks the API for a disposable account, pre-filled with a sample family and deleted after 24 hours. The demo skips the terms gate, and a banner says the data is fake and how to leave.
  • The schedule also ships outside the app. embed/ is a dependency-free web component in a shadow root (2.78 kB gzip, measured 2026-10-13), with an iframe variant and a versioned postMessage protocol. mf/ exposes the same schedule as a Module Federation remote that shares the host's React as a singleton. Both are published contracts with stable URLs.
  • Dates are calendar dates. A YYYY-MM-DD birth date is not a UTC instant. Vitest runs in America/Sao_Paulo, because in UTC (the CI default) that class of bug passes silently (src/lib/date.ts).
  • Motion that respects the reader. Page changes are View Transitions, and the scroll-driven effects sit behind @supports (animation-timeline: view()). Every effect is off under prefers-reduced-motion.

Architecture

flowchart TB
  subgraph Clients
    SPA["Cygnus app<br/>(React SPA)"]
    Site["Any website<br/>embed widget"]
    Host["Another React app<br/>Module Federation host"]
  end
  subgraph Vercel["Vercel · cygnus.samuelsantana.dev"]
    Static["Static build<br/>/ · /embed/* · /mf/*"]
    Proxy["Rewrite<br/>/api/* · /uploads/*"]
  end
  subgraph Render
    API["cygnus-api<br/>Fastify 5"]
    Redis[("Redis")]
  end
  Neon[("PostgreSQL<br/>Neon")]

  SPA --> Static
  SPA -- "same-origin, cookies" --> Proxy
  Site -- "GET /public/vaccine-schedule" --> Proxy
  Host -- "remoteEntry.js" --> Static
  Proxy --> API
  API --> Neon
  API --> Redis
Loading

The browser only ever talks to cygnus.samuelsantana.dev. GitHub Pages hosts the design system and the coverage report, and Sentry receives errors and Web Vitals.

Stack

Concern Choice
UI React 19, React Router 7, Tailwind CSS 4, shadcn/ui on Radix
Server state TanStack Query, with exported query-key factories
Forms and validation React Hook Form and Zod
UI state Zustand, for UI state only
Localization i18next: Brazilian Portuguese (default), English, Spanish
Build Vite 8, strict TypeScript, oxlint, Module Federation
Tests Vitest, Testing Library and MSW; Storybook 10 with axe; Playwright
Delivery Vercel, GitHub Pages, Docker with nginx, Sentry

Running locally

Use Node.js 24 and npm. Start the API first; it listens on http://localhost:3005 by default.

npm ci
npm run dev        # http://localhost:4205

To point at another API, create .env.local with VITE_API_BASE_URL. Every VITE_* variable is compiled into the public bundle, so never put a secret in one; the Google credentials belong to the API.

With Docker, nginx serves the production build on the same port, without hot reload:

docker compose up -d --build web

Rebuild after each change. Docker and Vite both use port 4205, so run one at a time. Compose does not start the API; pass VITE_API_BASE_URL as a build argument to change its origin.

Quality checks

Command What it checks
npm run lint oxlint
npx tsc -b Types for the app, stories, embed and Module Federation
npm test Unit and component tests in jsdom, with strict MSW
npm run test:coverage The same, with V8 coverage and a summary
npm run contract:check Mapped schemas against the API's published OpenAPI
npm run test:storybook Every story in Chromium: render, interactions and axe
npm run test:e2e Playwright journeys against a running stack
npm run build Typecheck, then the app, the embed and the remote, in that order

CI runs lint, types, the contract check, coverage and the build in one job, and the Storybook suite in another. The Storybook suite needs npx playwright install chromium. The E2E suite is not in CI, because it needs a checkout of the API with PostgreSQL and Redis; the E2E instructions explain how to run it. The contract check covers an explicit map of endpoints, and axe does not replace a manual accessibility review.

The coverage report counts every TypeScript module in src/, embed/ and mf/, imported by a test or not, and excludes declarations, tests, stories and test infrastructure. Storybook and E2E runs do not add to it. CI fails below a floor set in vitest.config.ts: 89% of lines, 87% of statements, 83% of functions and 80% of branches.

Project layout

Path What lives there
src/app/ Router, providers, layouts and the session gate
src/features/<domain>/ One folder per domain: api/ (fetch, Zod schemas, hooks), components/, routes/
src/components/ui/ shadcn/ui primitives, without business logic
src/shared/, src/hooks/, src/lib/ Cross-feature components and infrastructure: HTTP client, query client, i18n, dates
src/locales/ Copy in the three languages
src/docs/ Storybook pages
embed/, mf/ The widget and the federated remote
e2e/ Playwright journeys

Routes are lazy-loaded. Design tokens live in src/index.css, and stories sit beside their components.

Deployment

A merge to main deploys to Vercel and republishes the design system and the coverage report to GitHub Pages. One build produces three artifacts:

Artifact Public entry point Notes
The app / lazy routes; entry chunk 183.8 kB gzip (measured 2026-10-13)
Embed widget /embed/embed.js, /embed/iframe.html embed/README.md
Module Federation remote /mf/remoteEntry.js mf/README.md

Those three URLs are contracts: they live in other people's HTML and deployments, so they never change, and they are cached for ten minutes. Only hashed assets are immutable. Vercel and the Docker nginx keep separate header configurations, and one script checks either:

node scripts/check-static-serving.mjs            # headers, caching and 404s
node scripts/check-static-serving.mjs --browser  # plus the iframe, from another origin, in Chromium

It checks the Docker build on port 4205 by default; set STATIC_BASE_URL to check another target. The browser check calls the real API.

Terms and privacy

The Terms of Use and the Privacy Policy are versioned in src/shared/legal.ts, with the text in src/features/legal/content/. A new version asks every signed-in user to accept again, and the API records each acceptance.

License

MIT, © 2026 Samuel Santana. Dependencies and third-party material keep their own licenses.

Built by Samuel Santana: samuel.ssa89@gmail.com.

About

Cygnus — children's health, organized: Brazil's PNI vaccine schedule, checkups, WHO growth charts, milestones and medications, shared across the family. React 19 + strict TypeScript. Try the live demo, no sign-up.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages