Back to projects
Case study · Clínica Evest

Clínica Evest — Management System

A custom management system for Clínica Evest: patients, treatment protocols, appointment scheduling, batch- and expiry-aware inventory, finances and an AI assistant. I owned it end to end, from requirements gathering to the production deployment on AWS, and I'm still responsible for its evolution and support.

NestJSNext.jsTypeScriptMySQLAWS
Clínica Evest

Role

Full-stack developer — product, backend, frontend and infra

Period

Apr 2026 — present

Status

In production since Nov 2026, actively evolving

31

database entities

21

API modules

32

e2e test suites

600+

commits across 2 repos

The challenge

The clinic tracked appointments, treatment plans, inventory and cash flow in spreadsheets. Patient follow-ups slipped through the cracks, products expired on the shelf, and closing the month meant checking everything by hand.

The system was built together with the team: meetings with the clinic, a proposal, staff training and frequent releases driven by real day-to-day use. Every production release bumps the version and shows up on a What's New screen inside the app.

Screens

Appointments screen of the Clínica Evest system
Appointments grouped by day, with status and a shortcut to the patient's WhatsApp.
Patient record with history
Patient record: summary, upcoming follow-ups and a unified history of appointments and sales.
Gabi assistant panel
Gabi: daily digest with overdue follow-ups, expired batches and open appointments.

Screenshots use fictional data: no real patient data appears here.

Architecture

Client

BrowserMobile

Edge

Caddy · HTTPS

Application

web-clinic · Next.jsclinic-core · NestJS

Data

MySQL 8Redis

AWS services

CognitoS3 · backupsSNS · alarms

Frontend (web-clinic)

Next.js with shadcn/ui and Tailwind. Forms use React Hook Form + Zod, charts use Recharts, and a single Axios client handles automatic session refresh. Each screen only shows up for users holding the matching permission, and the UI works on mobile and in dark mode.

API (clinic-core)

Modular NestJS, one module per domain (patients, plans, appointments, inventory, finances, reminders...). DTOs validated with class-validator, OpenAPI docs, and a Unit of Work for operations spanning several tables: finishing an appointment deducts inventory and books the revenue in a single transaction.

Auth & permissions

Login through AWS Cognito, with tokens verified via JWKS and kept in HTTP-only cookies with silent refresh. Redis handles session caching and login throttling. Permissions are granted per user and per screen rather than by fixed roles.

Infra & delivery

Production runs on an EC2 instance in the clinic's own AWS account: Docker Compose with MySQL, Redis, API, web and Caddy (automatic HTTPS). There are daily backups to S3, SNS alarms and a monitored budget. GitHub Actions CI runs lint, unit tests, e2e against real MySQL/Redis and the build on every PR. I also designed an ECS Fargate + RDS architecture in Terraform for when the clinic outgrows a single box.

Data model

MySQL 8 modeled with TypeORM and versioned through migrations. There are 31 entities, grouped into five domains:

Patients & protocols

PatientPlanPlanDetailPlanDetailTaskPatientPlanPatientBalanceClosure

A Plan is a treatment protocol made of steps (PlanDetail), each listing its services. Assigning it to a patient (PatientPlan) generates the follow-up schedule and tracks progress.

Appointments

AppointmentAppointmentItemTask

An appointment moves through Scheduled → In progress → Finished/Cancelled. Each item is either a service (Task) or a product variation, with decimal quantity and an amount or percent discount.

Catalog & inventory

ProductProductVariationCategoryProductBatchProductInventoryInventoryHistoryPriceHistory

Inventory is tracked per batch (ProductBatch), with lot number, expiry date and unit cost. Stock is consumed FEFO: the batch that expires first goes out first.

Finances

TransactionTransactionItemSupplier

Purchases, sales, freight, discards and adjustments are typed transactions. A purchase creates batches and a sale consumes them, so inventory and cash always move together.

Platform

UserPermissionUserPermissionAuditLogReminderReminderTypeReminderTagNotificationDispatchClinicSettingAssistantAnswer

Users with fine-grained permissions, an audit trail (who changed what), reminders with types and tags, e-mail notifications and clinic settings.

Modeling decisions

  • Money stored as integer cents to avoid floating-point rounding errors in the books.
  • Quantities stored as decimals, because a vial can be partially used and the remainder becomes the patient's balance.
  • Price history and audit logs in their own tables: changing a price never rewrites past sales.
  • RESTRICT deletes and soft deactivation: a product or service that was already used never disappears from history.

Highlights

Protocols & follow-ups

Assigning a plan to a patient generates the follow-up schedule, and overdue visits get flagged.

Expiry-aware inventory

Batches, units of measure, logged discards and alerts for products close to expiring.

PDF receipts

Receipts are rendered server-side with pdfmake and e-mailed to the patient in one click.

AI assistant (Gabi)

Backend rules find what needs attention (follow-ups, expiries, pricing) and the LLM only writes the text. Patients are pseudonymized before any call, for LGPD (Brazil's GDPR) compliance.

Dashboards

Revenue, discounts, best-selling services and upcoming patients, filterable by period.

Help Center

50 in-app tutorials with screenshots. A CI script flags when the help mentions a button that no longer exists.

Stack

Backend

Node.js 22NestJS 11TypeScriptTypeORMclass-validatorSwaggerpdfmakeNodemailer

Frontend

Next.js 16React 19Tailwind CSS 4shadcn/uiReact Hook FormZodRecharts

Data

MySQL 8RedisTypeORM migrations

Cloud & DevOps

AWS EC2AWS CognitoAWS S3CloudWatch + SNSDocker ComposeCaddyGitHub ActionsTerraform

Quality

JestSupertestESLintSpecs por feature

What I learned

  • Writing a spec and plan before any code (docs/specs/<feature>) made conversations with the clinic far more focused.
  • Working with real data demands care: a backup before every migration, e2e tests against a real database and deploys only after business hours.
  • Software for a small client is still a product: training, a Help Center and release notes are what make the team actually adopt it.

Want to build something like this?

I build custom websites, APIs and systems, from discovery to deployment. Let's talk.

Get in touch
Clínica Evest — Sistema de Gestão — Patrick Meirelles