Personal project
City Healer
One platform where patients, doctors, hospitals and admins coordinate care in real time.
- Roles
- Patients, doctors, hospitals, admins
- API
- 36 Express routes, authenticated by default
- Auth
- Custom JWT, bcrypt, ownership from the token
- Security
- Audited; IDOR, escalation and open endpoints closed
- Deploy
- Railway — public URL currently offline
- Source
- Public repositorygithub.com/Raghav-prog-max/city-healer
The problem
Care coordination fails in the gaps between parties. A patient does not know which hospital has a free bed; a hospital does not know a consultation happened elsewhere; a doctor writes a prescription the pharmacy never sees. City Healer models all four parties — patients, doctors, hospitals, admins — in one system so those handoffs are records rather than phone calls.
That design decision is also what makes it a genuinely hard security problem, which turned out to be the most useful thing about building it.
Migrating off Firebase
It started on Firebase with Firestore. I moved it to SQLite behind an Express API with my own JWT auth, because the access rules I needed were relational: a doctor may read a patient's records if an appointment links them. Expressing that in security rules over documents meant duplicating relationships into every document and keeping the copies honest. In SQL it is a join.
The migration is the reason the authorisation model below can be written as a query rather than a pile of role checks — and the reason a doctor with no links sees nothing rather than everything.
What I got wrong
An audit found nine ways to read another patient's records.
This is the part worth reading. I audited the finished build and found nine blocking issues. Every one was reproduced against the running server before the fix and re-tested after.
The authentication middleware called next() when the Authorization header was absent. Not on failure — on absence. All 36 API routes were reachable with no credentials at all. It now returns 401 unless the route is on an explicit public allowlist, and that allowlist carries no patient data: registration, login, health, and the public hospital, doctor and medicine catalogues that make the landing page's bed census work without a session.
Any patient could make themselves an admin. PUT /api/users/:uid accepted a role field from any caller. Role changes now require ADMIN and are validated against an allowed set.
The records endpoint ran SELECT * with no filter. Every patient record, to anyone who asked. It is now scoped in SQL from the verified token: patients see their own, doctors see only patients they are linked to by an appointment, admins see all. Appointments, the queue and medicine orders had the same hole and the same fix. Emergency alerts — which carry name, phone and GPS — are now restricted to hospitals and admins, and chat requires being a party to that consultation.
There were guest-identity fallbacks throughout. An unverifiable token silently became a PATIENT; endpoints accepted patientId from the request body; strings like "guest-patient" and "anonymous-sos" stood in for real ownership. All removed. Ownership is now always derived from the verified token, never from request input. Anonymous access is opt-in behind DEMO_MODE, which defaults to false and binds the caller to a synthetic uid that matches no real patient, so ownership-scoped queries return nothing belonging to a real person.
The lesson
Every one of those nine findings had the same shape: the interface enforced a rule the API had never been told about. The pages showed patients only their own records, so the system looked correct from the outside while the endpoints underneath were wide open.
Two habits came out of it that I now apply by default. Authorisation that lives only in the component tree is not authorisation — the server is the enforcement point and the client is a convenience. And access control should fail closed: a doctor account with no links sees zero records, which is the correct default for a system holding medical data.
AI, kept server-side
Diagnostic suggestions run through Google's GenAI SDK on the server. The browser receives generated text and never a credential — the API key is not in the bundle, not in an environment variable prefixed for the client, and not retrievable by reading the network tab. Offline and failure paths fall back to canned responses rather than crashing the consultation view.
Need an application like this?
Multi-user products with roles, real logic and an admin panel start at ₹60,000 and take three to six weeks.