Skip to main content
Web ApplicationCompleted

Clinic Manager: Web-Based Clinic Management System

A web app for small and mid-sized clinics that need to track patients, appointments, doctors, and departments without paper records, built on React and Supabase.

DeveloperMustafa Kürşad Başer
Started: Oct 2024Completed: Dec 2024
Clinic Manager: Web-Based Clinic Management System

Clinic Manager handles the front-desk side of running a clinic: patient records, staff, appointments, departments, and a dashboard that shows where the day stands. It is built for small and mid-sized clinics that have outgrown spreadsheets but do not need the weight of a full hospital information system. It is a React single-page app that talks to Supabase directly through supabase-js, with no API layer of its own, and its interface is in Turkish.

The data model: Four tables from one schema script, plus a numbered migration and a rollback script that add the overlap rule below to an existing database.

  • patients: name, phone, and the 11-digit national ID (TCKN), unique at the database level
  • staff: name, department, phone and email. Doctors are picked from this list
  • departments: a name, created when an appointment first uses it
  • appointments: a patient, a doctor and a department tied to a timestamp, with a status of Bekliyor (pending), Tamamlandı (completed) or İptal (cancelled)

No double booking: An appointment stores only its start time and is treated as a 30-minute slot. The rule that a doctor cannot be booked for overlapping times is enforced by Postgres rather than by the form:

  • An exclusion constraint, built on btree_gist, rejects any appointment whose doctor matches another and whose slot overlaps it. Cancelled appointments are left out of the constraint, so a cancelled slot can be booked again
  • The slot comes from a small SQL function returning a half-open timestamp range. An exclusion constraint needs it to be IMMUTABLE, which holds because adding a fixed interval does not depend on the session time zone
  • Before inserting, the service runs the same check as a query so the receptionist gets a plain Turkish message. The constraint covers what the query cannot, two bookings saved at the same moment, and its error code is mapped to the same message
  • The migration that adds it counts existing overlaps first and stops without changing anything if it finds any

Patients:

  • Create, edit and delete. The form strips anything that is not a digit from the TCKN and phone fields, then requires 11 digits for the TCKN and 10 or 11 for the phone
  • The list shows each patient's appointment count and last appointment date, from appointments embedded in the same query
  • Search matches part of a name, ignoring case, or an exact TCKN
  • A patient with appointments cannot be deleted: the schema would cascade, so the service layer checks first

Appointments: The form picks a patient, shown with name and TCKN, and a doctor, shown with name and department, and fills the department in from the doctor's record. The picked local date and time are stored as an absolute timestamp, and the day filter uses local day boundaries, so a 09:00 booking is listed at 09:00. The list filters by day, by status, and by part of a patient's name or the start of a TCKN, through an inner join so the filter narrows the appointments rather than only the embedded patient. Each row can be switched between pending and completed, or deleted after a confirmation.

Dashboard: Six counts, the five most recent appointments, and appointments per department over the last 30 days, refreshed every 30 to 60 seconds through React Query's refetch interval.

Stack: React 18 on Vite, Tailwind CSS and React Router; React Query over thin hooks and service modules that own the Supabase queries; date-fns with Turkish formatting and React Hot Toast; a small Express server that serves the build with a fallback to index.html.

Not built yet: There is no sign-in screen, the schema defines no row-level security policies, and staff have no roles. Nothing in the interface marks an appointment as cancelled, although the filter and the constraint both know the status, and deleting a staff member removes their appointments through the cascade.

Tech Stack

ReactTailwind CSSReact QuerySupabaseReact RouterNode.jsPostgreSQL