CSE312 Software Architecture Principles and Practices

Pulse

A lifelong health record that the patient owns.

Shivansh Neekhra, Akshay VS, Bharadwaj B Chand, Srimoneyshankar Ajith

Indian Institute of Information Technology, Kottayam, Team 1

Guide: Dr. Dhakshayani J

A story

9:42 pm. Ravi, 34, is walking home.

Hit by a car. Unconscious. No ID.

  • Blood group?
  • Allergies?
  • Medicines?
  • Who to call?

Nobody can answer. The record is in three hospitals, and none of them are here.

At the hospital

The ambulance has no record. The phone does.

Ravi made an emergency card and put its QR on the back of his phone.

The paramedic scans it, signed in to the hospital system.

Only the card opens. His record stays closed.

Four seconds later

The doctor knows what to avoid.

  • No penicillin. Asthma inhaler on hand.
  • Wife called from the card.
  • Nothing else opened. The scan is logged and Ravi is notified.
Emergency card, Ravi Menon
Blood typeO+
AllergyPenicillin
ConditionAsthma
MedicationSalbutamol inhaler
Next of kinAsha Menon, wife
+91 90000 00000

A smaller moment

New city, new doctor. Priya forgets her tablets.

"Which medicines are you on?"
"A small white one, for sugar?"

No AI model. Fixed rules over her own record. Nothing she asks is stored.

Ask your record
What medicines am I taking?
Active medications
  • Metformin 500 mg, twice daily
  • Amlodipine 5 mg, once daily
Read from your entries through the consent filter. 2 entries. Logged.

Introduction

Pulse is a lifelong health record with a simple rule: the patient decides.

Patients

Own the record, grant and revoke consent, see every access.

Providers

File entries and documents, including for people who never registered.

Clinicians

Read only inside an active consent. The role alone grants nothing.

Administrators

Keep identities clean. Can never read clinical data.

Built for India: four languages, synthetic data only, never a real patient.

Problem statement

Health history is scattered, and the patient is the last to know who saw it.

  • Records sit in separate hospitals and on paper.
  • Emergency staff have nothing to go on.
  • Access is implied. Withdrawing it is not a thing.
  • Nobody can say who read what.

Objectives

  1. Own. One record that follows the patient for life.
  2. Consent. Enforced on every read, revoked immediately.
  3. Account. Every access recorded and visible to the patient.
  4. Reach. Four languages, an emergency path, mobile first.

Requirements

What it does

Accounts

Register, verify email, step-up password check for sensitive actions.

Timeline

Five entry kinds. Corrections add a new entry, never overwrite.

Filing

Provider staff file entries and documents, even for unregistered patients.

Consent

Scoped by entry type and date window, optional expiry, revoked at once.

Access log

Every read listed for the patient, with notifications.

Emergency card

Patient-written card, QR, 60-minute break-glass with a reason.

Analytics

Lab trends, medications, visits, computed at request time.

Ask your record

Plain questions answered by fixed rules, in four languages.

Requirements

What it must stay true to

Privacy

Consent filter on every clinical read. Denied reads are 404, not 403.

Auditability

Audit table is append-only by database GRANT.

Security

Argon2id, opaque Redis sessions, CSRF origin guard, default-deny routes.

Integrity

No in-place edits. No clinical values in JSONB.

Usability

Four locales, mobile-first, colour never carries meaning alone.

Maintainability

Modular monolith with import and SQL boundaries enforced in CI.

Testability

Integration tests on real PostgreSQL, negative tests first.

Deployability

docker compose up, 6 services, seeded.

System architecture

One origin, one backend, one database

BrowserPWA, 4 locales Caddysame origin /* /api/* Next.js 16screens, next-intl FastAPI, modular monolith authuserspatientsprovidersrecordsconsentauditnotificationsanalyticsadminask PostgreSQL 18all durable data Redis 8sessions only, never truth AdaptersStorageProviderNotificationProviderIdentityProvider

Inside a module

Each layer has one job, and one thing it may not do

Modules talk through service interfaces, never each other's tables. A CI lint fails the build if they do.

routes.pyHTTP onlyParse, validate, delegate. No business logic.
service.pyBusiness rulesConsent, permissions, transactions. No SQL, no framework.
repository.pyAll SQLOne query builder for clinical reads.
models + schemasShapeSQLAlchemy tables and the Pydantic API contract.

The rule everything rests on

Every clinical read starts from one function

  • The patient sees their own entries.
  • Provider staff see only what their provider authored.
  • A clinician sees what an active consent allows.
  • Anyone else gets false(). Default deny.
async def accessible_entries(session, actor, patient_id):
    if await actor_owns_patient(session, actor, patient_id):
        conditions.append(MedicalEntry.patient_id == patient_id)
    if provider_id is not None:
        conditions.append(and_(MedicalEntry.patient_id == patient_id,
            MedicalEntry.source_provider_id == provider_id))
    if actor.role is Role.CLINICIAN:
        conditions.append(and_(..., clinical_access_predicate(
            patient_id, actor.user_id, entry_type, occurred_at)))
    if not conditions:
        conditions.append(false())
    return select(MedicalEntry).where(or_(*conditions))

Consent engine

Revoking is one tap, and the next read is refused

1

Patient grants

Password re-check. Scoped to entry types and a date window.

Consent active
2

Clinician reads

The filter passes. The access is logged once.

200, entries
3

Patient revokes

No password prompt. The permission row is deleted in the same transaction.

Consent revoked
4

Same clinician reads

Nothing cached, so the very next query denies it.

404, not 403

A 403 would confirm the person is a patient here. A 404 says nothing.

Decisions, 18 recorded

We chose, and wrote down what we gave up

ADRChosenOverBecause
0003Opaque Redis sessionsJWTLogout and role changes apply server-side, at once.
0006One query builder for consentPer-endpoint checksA filter cannot be forgotten in sixty places.
0007Administrators read no clinical dataA superuser roleThe audit log is safe for admins to see.
0008Append-only audit by GRANTConventionThe app role cannot update or delete history.
0001Joined-table entry inheritanceOne wide table or JSONBTyped columns, no clinical JSON.
0018Rule-based ask-your-recordA language modelEvery answer passes the consent filter.

Patterns and practices

Architecture the build enforces

Modular monolith

11 modules, one deployable, one database.

Layered, repository

routes, service, repository. SQL lives in one place.

Ports and adapters

Storage, notification, identity behind interfaces.

Contract first

OpenAPI generates the TypeScript types. Stubs before code.

Fitness functions

Route coverage plus 4 lints fail the build on a violated rule.

Negative tests first

Revoked, expired, wrong scope, admin: each must return nothing.

A rule that only lives in a document gets broken by accident. These live in CI.

Verification

The risk is one missed filter, so that is what we test

0

backend tests on real PostgreSQL

0

browser tests, plus 1 live run on the real stack

0

endpoints, every one declares a permission

0

modules with enforced boundaries

0

decision records with alternatives

0

interface strings in each of 4 languages

FAQ

Questions we expect

Why not JWT?

Opaque Redis sessions are checked on the server, so logout and role changes take effect at once.

Why a monolith, not microservices?

One laptop-scale deployment with no scaling need. Module boundaries are linted as if extraction were coming.

Why 404 instead of 403?

A 403 confirms the record exists, which reveals that a person is a patient here at all.

Is there an AI chatbot?

No model. Fixed rules map a question to a query that goes through the same consent filter.

Why not translate diagnoses?

The interface is localised, clinical text is not. Translating it would invent a medical claim.

Is any data real?

None. Synthea plus an Indian overlay gives 125 synthetic patients, committed to the repo.

Pulse

Patients own their history. Clinicians read it with consent. Every access is recorded.

Shivansh Neekhra, Akshay VS, Bharadwaj B Chand, Srimoneyshankar Ajith

Indian Institute of Information Technology, Kottayam, Team 1. Guide: Dr. Dhakshayani J

github.com/moneytosms/Pulse