By Bilal Hijazi, freelance web developer in Dubai
How Clinic Desk Works: Sign-In and Permissions
A plain-English technical write-up of Clinic Desk, a live clinic app: how sign-in works, what visitors can and cannot do, how it is tested and where it runs.
Clinic Desk is a working appointment and follow-up app I built as a concept for a fictional aesthetics clinic. A fair question about a demo like this is whether it is a real application or a mock-up, and how it handles sign-in and who can change what. This write-up answers both, in plain English, with enough detail for a developer to check.
It uses fictional patients and fictional prices. It is a concept build, not client work.
What it is
Four screens behind a one-tap demo login: Today (the day’s appointments), Patients (a searchable list with notes), Follow-ups (who is due a repeat treatment, with a pre-written WhatsApp reminder) and Overview (bookings, no-show rate, revenue and top treatments). Sign in, change an appointment’s status, add a note, and it is saved.
What it is built with
- SvelteKit, a web framework, running on Cloudflare as a Workers project with static assets.
- Supabase, which provides the Postgres database, the sign-in system (Supabase Auth) and Row Level Security, the database feature that decides which rows each user may read or change.
- pg_cron, a Postgres scheduler, which resets the demo data every night at 00:05 Dubai time.
How sign-in works
The demo has one shared demo user. The “Try the demo” button sends a request to a server route, which signs in as that user and gives the visitor a session cookie. The demo user’s credentials are stored as runtime variables on the server and are never sent to the visitor’s browser.
Two settings are switched off on purpose: new sign-ups and anonymous sign-ins. So nobody can create an account on the demo, and nobody gets in without going through the demo login. A check run against the live project reads the project’s public auth settings to confirm sign-ups are off, and confirms that a logged-out anonymous sign-in attempt is refused.
What a visitor can and cannot do
The permissions are enforced by the database, not only by the screens. That matters because a browser session can be used to call the database directly, so the screens are not a security boundary. The database is.
| Who | Can | Cannot |
|---|---|---|
| Logged out | Nothing | Read any table, view or helper function |
| Signed-in demo visitor | Read the clinic data; change an appointment’s status; add a note of 1 to 500 characters | Edit prices, delete records, edit patients, back-date a note |
| Anyone except the database owner | Nothing | Run the nightly reset or read the snapshot it restores from |
How that is done:
- Row Level Security is switched on for every table, including the snapshot tables the nightly reset reads from. The clinic data lives in four: treatments, patients, appointments and patient notes.
- Every default permission is removed first, then only what the demo needs is granted back. The signed-in user may read the four tables, change only the status column of an appointment, and add a note with only a patient and a body.
- The logged-out role has no privileges at all.
- The note’s length limit is a database constraint, and the permission to add a note covers only the patient and the text, so a visitor cannot set a note’s date. Both hold even for a direct call.
How it is tested
- Database tests run against a local copy of the database. They check that a logged-out user is refused, that a signed-in user can change a status and add a note, that an empty note, an over-long note and a back-dated note are each refused, and that Row Level Security is on for every table.
- Unit tests cover the logic on the screens, such as dates, search, charts and the WhatsApp reminder text.
- A live probe runs against the deployed project through the real API, using the public key, once logged out and once as the demo user. It checks the exact error code for each refusal, so a missing function cannot pass as “refused”.
- Browser checks drive the screens.
How the nightly reset works
A scheduled job at 00:05 Dubai time runs a reset function. It restores the clinic data from a snapshot, with dates re-anchored to the current day, so the demo always looks current. The snapshot tables have Row Level Security on and no permissions granted, and the reset function cannot be run by a visitor. Only the database owner can run it.
How it is deployed
The app is built as a SvelteKit project and deployed to Cloudflare. It needs four runtime values: the database address, the public key, and the demo login’s email and password. The database’s administrative key is used only for a one-off setup script and is never set on Cloudflare. A written handover document covers setup, deployment and checks, so someone else can take it over.
What the demo leaves out on purpose
- Registration. There is one shared demo login, and sign-ups are off.
- Password reset.
- Multiple roles, such as admin, reception and clinician.
These are left out because it is a demo anyone can try, not because they cannot be built. For a client project, individual accounts, registration, password reset and roles are features I scope with you. Web apps are priced per feature, starting from AED 12,000 for a focused first version. See booking and follow-up systems for clinics.
What this means for a clinic
A tool for your team should not rely on its screens to keep your data safe. The permissions should live in the database, be tested, and be checked against the real deployment. Where patient information is stored matters too: health-data rules in the UAE can restrict where records are stored and processed, so I decide what is stored and where with you before building anything. For a client project, your domain, hosting, database and code are in your name from day one, with handover notes.
Go further
- Try Clinic Desk and change a status or add a note.
- Booking and follow-up systems for clinics.
- A follow-up list for repeat treatments, and WhatsApp booking for clinics.
- How I work, and what a clinic website costs in Dubai.
Want something like this for your clinic?
Tell me how your team works today and what you want to track, and I will send a fixed price. No obligation. Request a free quote.