Skip to content

Healthcare SaaS · Hospital & Pharmacy Platform

Simple Green Solutions

I built Simple Green Solutions solo in about ten weeks as a client project at Alphinex: a multi-tenant healthcare platform for hospitals, pharmacies and patients, with tenant isolation, timezone-safe booking and a SuperAdmin panel.

  • Public landing page for hospitals, pharmacies and patients.
  • Hospital admin dashboard with appointment trends and quick actions. Shown with demo data.
  • Appointment management across the full clinic lifecycle, filterable by doctor, patient and nurse. Demo data.
  • PharmaStock: one public catalog across every approved pharmacy. Demo data with placeholder product art.
  • SuperAdmin product moderation with per-pharmacy auto-approve and bulk review. Demo data.
On this page

My role

Simple Green Solutions was a client project at Alphinex Solutions, and I built it alone in about ten weeks. I made the architecture decisions, wrote the application end to end and deployed it. The stack is Next.js 16 with the App Router and Server Actions, React 19, TypeScript and MongoDB. The pharmacy side of the platform is large enough to have its own page, the Pharmacy Inventory and PharmaStock case study, so I only summarise it here.

The problem

The client wanted hospitals, pharmacies and patients on one platform instead of three disconnected products. That sounds like one app but behaves like four: a hospital admin, a doctor, a patient and a pharmacy owner each need their own navigation and data, while sharing accounts and a medicine catalog. Because the data is medical, one hospital seeing another's patients would be an incident rather than a bug.

Key decisions and why

Three tables for identity instead of a tenant column

A single tenant field on the user would have broken the first time one person worked for two organizations. I split identity into a tenant-agnostic User, a Membership (user, organization and role, uniquely indexed) and an organization-scoped profile for things like licence number and session rate. A doctor can hold different roles in different places, and switching organization issues a new session with fresh tenant context. Organizations are typed as hospital, pharmacy or platform and have a lifecycle from pending to approved, suspended or banned.

Distrust the session token

Isolation had to be structural, so I enforce it in layers, each catching what the previous one cannot:

  • Edge middleware routes users by session claims. It is quick and knowingly a little stale.
  • Server layouts check organization approval against the database, so a suspension applies on the next render.
  • Server actions call authorize(permission) against a capability matrix for Admin, Doctor, Nurse and Patient.
  • Every query carries a mandatory organization filter, which closes the case of a valid ID from the wrong tenant.
  • Operator actions re-read the database on each call and ignore the token entirely.

The cost is more database reads than a token-only design.

Instants in storage, clinic time for rules

A doctor's availability is a weekly schedule in the clinic's timezone, while an appointment is a moment in time. I store appointments as UTC and convert the chosen date and time through a DST-safe resolver, work out the weekday in the clinic's zone, and then check interval overlap. "Delayed" is derived when read instead of stored, so it cannot go stale.

Ledger over counter for stock

For pharmacy stock I chose an append-only movement ledger rather than a quantity field, and I re-check stock inside a MongoDB transaction at checkout. The reasoning is in the PharmaStock case study. It was the decision I was most sure about on this project.

What I built

  • Clinical side: appointment booking and a lifecycle that mirrors a clinic (pending, waiting, checked in, ready, completed or cancelled). A patient rescheduling an approved visit sends it back for approval, a staff reschedule does not.
  • Prescribing: the doctor's medicine picker reads live approved pharmacy stock, de-duplicated by name and dosage, and a prescription names a medicine rather than a shop.
  • Operator control plane: a pharmacy approval queue, product moderation with mandatory rejection reasons, organization suspension and reactivation, and an append-only audit log with before and after state. Audit writes are best-effort so a logging failure cannot break the action.
  • Dashboards and messages: role-scoped Recharts dashboards, Resend email for verification, invitations and order updates, Cloudinary uploads and invitation-based onboarding.

The finished platform has 71 pages and 27 data models.

Results

  • Hospital, patient, pharmacy and operator experiences run from one codebase, one login system and one medicine catalog.
  • A missed check at any single layer no longer exposes another organization's patients.
  • The operator can onboard, moderate and suspend pharmacies without anyone touching the database.
  • The tenancy model took in a whole second business, pharmacy e-commerce, added after the clinical product, without changing identity or permissions.
All projects

Have a project in mind?

Whether it's an MVP, a dashboard, or a rescue mission on an existing codebase — let's talk about it.

Prefer to talk first? Book a free 30-min call (opens in a new tab)