Why doctors switch. Why investors lean in.
One system that serves the doctor, the clinic, the patient and the business
The product is built around a single record, the issued prescription, and each party gets something different from it. Everything below is a capability that exists in the code today, apart from the items marked as planned.
A fast prescription that never waits for the network
- Works offline. Drug search, drafts and issuing run on the device and sync later.
- Quick to write. Type-ahead over the full drug catalogue, reusable templates (kits), repeat the previous prescription.
- Prints on the doctor's own pad. A4, A5 or 80 mm slip, millimetre margins, letterhead or pre-printed pad, Bangla or English.
- Legitimate by design. Number, BM&DC registration and signature are frozen into every issued prescription.
- Follow-ups. A due list shows who should return, with a call and one-tap check-in.
Many doctors, one workplace, clear control
- Roles. Manager, doctor, front desk and compounder each see only what their job needs.
- Doctors keep their identity. One login works in every workplace; a doctor invited by email accepts with their BM&DC details.
- Pay per doctor. The clinic buys doctor seats; inviting a doctor beyond the paid seats is refused.
- Managers do not read clinical notes. A manager is not a doctor unless they choose to practise and take a seat.
- Vetted. A clinic or centre is reviewed by an operator before anyone can open it.
The prescription in hand, and control over who sees the history
- SMS link. The patient receives a Bangla SMS with a short link, valid for 30 days, with no medical detail in the message.
- Phone check. The page opens only after the last four digits of the patient's phone; repeated wrong guesses lock it.
- One identity, many doctors. A new doctor can see earlier prescriptions only after the patient reads out a one-time code.
- Patient page. No account needed: a code to the phone shows who has access and who looked, and lets the patient remove access.
Recurring revenue with low operating effort
- Revenue per doctor seat. Clinics already buy seats per doctor; a chamber is one seat. Feature tiers on top of the seat are proposed, billed per 30-day period.
- Prices are data. Operators change prices, limits and availability in a console; no release needed.
- Lapse handling is automatic. Trial, grace and read-only follow dates, so no sweeper job can unlock or lock a customer by mistake.
- Clean data trail. Subscriptions, payments and issued prescriptions are separate tables, so revenue and usage metrics can be queried directly.
- Compliance built in. Encrypted patient data, audit rows, BM&DC verification and operator two-factor sign-in.
Why the design is hard to copy
Identity that follows the patient
A thin global person record links each doctor's own chart. One printed barcode works at every doctor, and history sharing is consent-based. This is a data advantage that grows with each doctor who joins.
Built for Bangladesh conditions
Offline-first writes, Bangla print with calibrated printer profiles, a DGDA drug catalogue, bKash and Nagad payments, Greenweb SMS and Dhaka-time queue dates.
Safe to scale
Two isolation walls between workplaces (application filter and database row-level security), encrypted fields, and an event outbox so side effects never get lost or doubled.
One record. Zero chaos.
A workplace owns charts, queues and prescriptions; a person owns their identity
Reference data (drugs, tests, plans) is global. Everything clinical belongs to one workplace and carries its id. The only record that crosses workplaces is a thin person identity, and reading another doctor's history needs the patient's consent.
Roles
Four workplace roles (manager, doctor, front desk, compounder) and one platform role for operators, who never see patient data.
Immutable output
An issued prescription cannot be edited. Corrections create a linked new draft; the original stays valid and printable.
Everything is a row
Plans, prices, limits, approvals, consents and payments are data. Business changes do not need a code release.
Everything a chamber needs, already built.
What the product does today, and what it does not yet
A complete list of capabilities by area. "Built" means the code, the API and the screen exist. "Not started" means nothing exists yet; section "Where we improve" explains how each gap would be closed.
| Capability | Used by | What it includes | Status |
|---|---|---|---|
| Accounts and sign-in | Everyone | Email sign-up with emailed code and password; sign-in by email or mobile; password reset; login lockout; refresh sessions that rotate and detect reuse | Built |
| Workplace registration | Doctor, manager, operator | Private chamber (instant), clinic and diagnostic centre (operator approval), doctor invitations, doctor seats | Built |
| Doctor profile | Doctor | BM&DC number, qualifications, specialties, chamber details, signature image; verification by operator | Built |
| Patient registration and search | Desk, doctor, manager, compounder | Register with client-minted id, search by exact mobile, barcode or patient number, barcode scan check-in, audited reads | Built |
| Daily queue | Desk, doctor | Server-assigned serial per doctor and Dhaka date, vitals and fee, Waiting → In consultation → Completed or Cancelled | Built |
| Prescription editor | Doctor | Complaints, diagnoses, drugs with dose and duration, tests, advice, next-visit date; autosaved drafts; repeat previous; history panel | Built |
| Templates (kits) | Doctor | Save from the editor, one-tap merge, offline create and edit; enforced limit per plan | Built |
| Issue, amend, void, revoke | Doctor | Numbered RX-nnnnnn, frozen print snapshot, linked amendment, void with reason, revoke patient link | Built |
| Print pad | Doctor, manager | A4, A5 and 80 mm slip; margins; letterhead or pre-printed pad; footer; Bangla, English or mixed; per-device printer calibration | Built |
| Patient share link | Patient | Short code, last-4 phone gate, lockout with growing delays, same 404 for unknown, expired, revoked and voided | Built |
| SMS notification | Patient | Bangla template through Greenweb on issue, via transactional outbox and queue; no medical detail in the text | Built |
| Patient channels: WhatsApp and email | Patient | Second and third delivery channels after SMS, with a per-patient preference and fallback | Not started |
| Global patient identity and consent | Doctor, patient | Masked lookup, code sent to the patient, 12-month consent, cross-workplace history, access log, patient page to revoke | Built |
| Follow-up list | Doctor, desk | Patients whose next-visit date has come and who have not returned | Built |
| Drug and test catalogues | All, operator | Delta feed with tombstones, type-ahead search, operator create, update and deactivate, CSV and XLSX import | Built |
| Offline mode | All | Outbox with ordered replay, conflict parking, service worker app shell, local drug search, wipe on sign-out | Built |
| Billing and entitlements | Manager, operator | Plans as data, derived trial, grace and read-only, manual bKash and Nagad payments with operator approval, limits enforced for prescriptions, templates and doctor seats | Built |
| Operator console | Operator | Payment review, BM&DC queue, clinic approval, suspend and reactivate, plan pricing, support override; authenticator-app second factor | Built |
| Online payment gateway | Manager | Automatic card or wallet collection, recurring charges | Not started |
| Invoices and tax documents | Manager | Numbered invoices, VAT, receipts | Not started |
| Reports and analytics | Doctor, manager, operator | Practice reports, business metrics dashboard | Not started |
| Diagnostic centre workflow | Centre | Test orders, sample tracking, result entry and routing to the prescriber. Today a centre is treated like a clinic | Not started |
| WhatsApp share, server PDF, data export | Doctor, patient | Alternative channels and documents | Not started |
| Server-driven forms and pads | Doctor | Custom fields and a pad designer without a release (a hook exists in patient custom fields) | Not started |
Screens in the web app: sign-in and sign-up, queue, check-in, prescribe, follow-ups, settings (profile, print pad, templates, team, billing), the public prescription page, the patient access page, and the operator console (payments, doctors, workplaces, plans).
Sign up in minutes. Prescribe the same day.
Three ways in, one account, many workplaces
Every person first creates one account with an email address. From there a doctor opens a private chamber in minutes, while a clinic or diagnostic centre is reviewed by an operator first. A doctor can later join clinics with the same login and keep the private chamber.
The three paths side by side
| Question | Individual doctor | Clinic | Diagnostic centre |
|---|---|---|---|
| Who signs up | The doctor, for themselves | A manager or owner of the clinic | A manager or owner of the centre |
| Details asked | Full name, BM&DC number, qualifications, optional chamber name | Name, address, phone of the place, trade or health-facility licence number | Same as a clinic, with type set to diagnostic centre |
| Review | None for the workplace; the BM&DC number goes to the operator queue | Operator checks the licence, approves or rejects (a rejection needs a note) | Same as a clinic |
| Before approval | Not applicable | Shows as "waiting for approval"; opening it is refused | Same as a clinic |
| Limits on sign-up | One private chamber per person | A cap on requests waiting for approval per person | Same cap |
| Trial | 30 days from the day the chamber is created | 30 days from approval | 30 days from approval |
| Who is the manager | The doctor is owner and practises automatically | Signer becomes manager; not a doctor unless they choose to practise and take a seat | Same as a clinic |
| Members allowed | One assistant (compounder) | Doctors (must accept), front desk, compounders | Same as a clinic |
| Plan audience | Solo plans | Clinic plans, priced per doctor | Clinic plans, priced per doctor |
| Issuing prescriptions | Allowed once BM&DC is verified, or for 7 days after submitting it | Each doctor needs a seat and the same BM&DC rule | Same as a clinic |
Account rules
- Email is mandatory. Mobile number is optional and not verified by us.
- Codes are single use. Hashed, with an attempt counter that counts before it compares, and a resend cooldown.
- Guessing is slowed. Repeated wrong passwords lock password sign-in for a while.
- Invited before signing up. A clinic can invite an email address that has no account yet; the person claims it with an emailed code.
What a rejected or pending workplace sees
- Pending. Sign-in works, but opening the workplace answers "waiting for approval".
- Rejected. Opening is refused and the operator's note is kept on the record.
- Suspended. Members cannot open it again; a token they already hold works until it expires (15 minutes).
Data touched at each registration step
| Step | Reads from | Writes to | Route and rule |
|---|---|---|---|
| Request sign-up code | none | otp_challenges | POST /auth/signup/request; throttled, cooldown, hourly cap; refused if the email exists |
| Create account | otp_challenges | usersotp_challengesrefresh_sessions | POST /auth/signup; attempts counted before comparing; password stored as bcrypt hash |
| Individual: create chamber | users | users (BM&DC, qualifications)tenants (SOLO_DOCTOR, approved)tenant_members (manager who practises)audit_logsoutbox_messages | POST /workspaces; trial subscription appears the first time it is needed, dated from creation |
| Clinic or centre: sign up | users | tenants (pending, licence, address)tenant_members (manager)audit_logsoutbox_messages | POST /workspaces/facility |
| Operator approves | tenants | tenants (approval, reviewer, note)subscriptionsaudit_logs | POST /admin/tenants/:id/approval; decided once; trial starts here |
| Invite a member | userssubscriptions | users (created by email if new)tenant_members (invited or active)audit_logs | POST /workspaces/current/members; doctor invitations hold a seat; email sent best effort |
| Doctor accepts | userssubscriptionstenant_members | users (BM&DC if first time)tenant_members (active)audit_logs | POST /workspaces/invitations/:id/accept; seat re-checked |
| Operator verifies BM&DC | users | users (bmdc_status, checker, note)audit_logs | POST /admin/doctors/:id/bmdc; rejection needs a reason |
A packed waiting room, without the paperwork.
From the patient walking in to a prescription in their phone
The same flow serves a private chamber and a clinic. The front desk and the doctor work on the same queue; the server hands out serials and prescription numbers so two devices can never clash.
Data touched at each step
| # | Step | Reads from | Writes to | Note |
|---|---|---|---|---|
| 1 | Arrives | none | none | |
| 2 | Find or register | patientspersons | patients (new chart)persons (new global id)outbox_messagesaudit_logs | Phone found by blind index, so no clear-text number is stored |
| 3 | Check in | patientsusers | queue_serials (serial)number_sequencesoutbox_messagesaudit_logs | Same client id replayed gives the same entry |
| 4 | Record vitals and fee | queue_serials | queue_serials (bp, pulse, weight, sugar, temp, SpO2, fee) | Optimistic lock by version |
| 5 | Start consultation | queue_serials | queue_serials (IN_CONSULTATION) | Doctor only |
| 6 | Write prescription | patientsprescription_templatesprescriptionsdrug_master (local copy) | prescriptions (DRAFT)prescription_itemsprescribed_tests | Draft saved on device first, then synced; update conflicts answer 409 |
| 7 | Issue | userssubscriptionspatients | prescriptions (ISSUED, rx_no, snapshot)number_sequencesprescription_accessqueue_serials (COMPLETED)outbox_messagesaudit_logs | Owning doctor with BM&DC standing and a writable subscription |
| 8 | Print and SMS | prescription_accesspatientsnotification_templates | notification_requestsnotification_messages | Message holds rx number, doctor name and link only |
| 9 | Patient opens link | prescription_accessprescriptions | prescription_access (attempts, lock)audit_logs (shared view) | Wrong guesses are reserved before comparing |
| 10 | Follow-up | prescriptionsqueue_serials | none | Next-visit date in range and no return yet |
Screens the doctor and patient use
Simplified views of the real screens. All names and numbers are example data.
Queue
Prescription
Patient page
Locked once issued. Trusted for good.
A prescription is written freely, then locked when issued
Clinical integrity comes from three rules: an issued prescription never changes, drug and test names are copied into it so catalogue edits cannot rewrite history, and the doctor's and patient's identity are frozen into a print snapshot at the moment of issue.
What each action does
| Action | Who | Rule | Writes to |
|---|---|---|---|
| Save draft | Doctor | Create or update by client id; updates carry the expected version | prescriptionsprescription_itemsprescribed_tests |
| Issue | Owning doctor | BM&DC verified, or unverified for up to 7 days after submitting; subscription not read-only; limit on prescriptions per month if the plan has one; replay returns the same result | prescriptionsnumber_sequencesprescription_accessqueue_serialsoutbox_messagesaudit_logs |
| Amend | Owning doctor | Copies an issued prescription into a new draft; only one open amendment at a time | prescriptionsprescription_itemsprescribed_tests |
| Void | Owning doctor | Reason required; patient link stops working | prescriptionsaudit_logs |
| Revoke link | Owning doctor | Closes the patient's short link only | prescription_accessaudit_logs |
| Patient views | Patient | Short code plus last four phone digits; unknown, expired, revoked and voided look identical | prescription_accessaudit_logs |
No signal? Keep prescribing.
The doctor keeps working when the connection drops
Writes go to a local database first, then a sync engine replays them in order when the network returns. The server never needs to merge two versions of a record: ids are created on the device and updates carry a version number.
| Situation | What happens |
|---|---|
| No internet while writing | Draft saved on the device on every change. Drug search runs on the local catalogue. |
| Same save sent twice | The client id makes it idempotent: the second send returns the existing record, with no second serial and no second number. |
| Two devices edit one record | The second update carries an old version and is answered 409. The app parks it for the user instead of overwriting. |
| Issuing while offline | The prescription waits as pending; the number is assigned by the server on sync. Printing the draft sheet remains possible. |
| Subscription runs out while offline | Work created before writing stopped is accepted when it syncs. The device clock is trusted for at most 7 days back and never into the future. |
| Sign-out on a shared computer | Cached patient data is removed; unsent work is kept until it syncs. |
| Catalogue updated | The device asks only for changes since its last version, including removals. |
One patient. Every doctor. Their consent.
One person, many doctors, shared only with consent
Each doctor keeps their own chart. A thin global person record ties the charts together without holding any personal data itself. A new doctor sees earlier prescriptions only after the patient reads out a code sent to the phone already on file.
How we reach the patient
Most patients in Bangladesh are reached by mobile number, so SMS comes first. WhatsApp is second and email third. Staff accounts are different: sign-up, sign-in and password codes for doctors, managers and desk staff go to their email address.
| Order | Channel | Used for | Status |
|---|---|---|---|
| 1 | SMS to mobile | Used for prescription links, consent codes and patient page codes. This is the main channel. | Built |
| 2 | Same messages through a WhatsApp business channel, for patients who use it more than SMS. | Planned | |
| 3 | For patients who give an address. Today a patient chart has no email field; it would be stored encrypted like the phone. | Planned |
Who can read what
| Reader | Own records | Other doctors, same patient | Other clinical |
|---|---|---|---|
| Doctor with an active seat | Yes, in every workplace | Yes, with active consent | No |
| Doctor removed by a clinic | Read yes; write needs a seat again (not built yet) | Existing consents apply | No |
| Front desk | Reads and prints issued prescriptions of the workplace | No | No |
| Compounder | No prescription access | No | No |
| Clinic manager | No clinical content | No | No |
| Platform operator | No | No | No |
Privacy rules in the code
- Masked lookup. Only initials, age and gender; throttled per IP and capped per doctor per hour.
- Access log. Every view of another doctor's records is written; the patient page shows it.
- Cross-workplace reads are read-only. Issued prescriptions only; drafts stay private; writes across workplaces are refused by the database.
- Household phones. Family members who share a phone see each other's list on the patient page, by the same rule as the code.
Data touched
| Step | Reads from | Writes to |
|---|---|---|
| Masked lookup | patientspersons | none |
| Send code to patient | personspatients | person_consent_requestsnotification_messages |
| Verify code | person_consent_requests | person_consentspatients (own chart, same barcode)person_access_log |
| Read history | person_consentsprescriptions | person_access_log |
| Patient page sign-in | patients | patient_portal_requests |
| Patient removes access | person_consents | person_consents (revoked_at) |
Built for chambers, clinics and centres.
Who may do what inside a chamber, clinic or centre
A role is checked at the door of every route, and finer rules (only the owning doctor writes a prescription) are checked inside the use case. A person can hold different roles in different workplaces.
| Action | Manager | Doctor | Front desk | Compounder |
|---|---|---|---|---|
| Manage team and invitations | ✓ | — | — | — |
| Register patients and check in | ✓ | ✓ | ✓ | ✓ |
| Start a consultation, write, issue | — | ✓ | — | — |
| Complete or cancel a queue entry | ✓ | ✓ | — | — |
| Read and print prescriptions | — | ✓ | ✓ | — |
| Void or revoke link | — | ✓ | — | — |
| Templates and consent lookup | — | ✓ | — | — |
| Print pad settings (change) | ✓ | ✓ | — | — |
| See the subscription | ✓ | ✓ | ✓ | ✓ |
| Pay, report a payment | ✓ | — | — | — |
Reading prescriptions and printing is open to doctors and front desk. A manager who also sees patients chooses to practise and takes a doctor seat. Platform operators work outside workplaces and see no patient data.
Private chamber
The doctor is the owner and the only clinician. One assistant (compounder) can be added by email.
Clinic
A manager invites doctors, desk staff and compounders. Doctors must accept, and each doctor holds a paid seat, counted from the invitation.
Diagnostic centre
Registered and approved like a clinic. Test orders, samples and results are not built; today the centre runs the same patient, queue and prescription flow.
Pay per doctor. Grow by feature.
Trial, paid period, grace, read-only: access follows dates
Every workplace has one subscription. Revenue is per doctor seat. Customers pay by bKash or Nagad and report the transaction; an operator confirms it against the real transaction and approves. Nothing is charged automatically yet, which keeps launch simple and trustworthy while volumes are small.
What read-only blocks
| Create patient, queue entry or draft | Refused (402) |
|---|---|
| Issue or amend a prescription | Refused (402) |
| Read, print, share, void, revoke | Allowed |
| Settings, templates, paying | Allowed |
| Work created offline before the lock | Accepted when it syncs, up to 7 days back |
Manual payment rules
- Transaction id is cleaned (6 to 20 letters and digits) and unique per method; another workplace using it gets 409.
- Amount must cover price × seats, in whole paisa. The date cannot be in the future or older than 60 days.
- Approval renews one period from the end of a running period, or from now if lapsed. A decision is made once.
- Clinics pay per doctor; adding a doctor mid-period means renewing early at the new size, with no proration.
Manual payment flow
Plans, as stored today
Plans are rows an operator edits. The paid plans are seeded inactive at price 0 with placeholder limits, because prices are to be set from pilot data. Activating a paid plan without a price is refused.
| Plan | For | State | Period | Rx / month | SMS / month | Templates | Compounders | Doctors |
|---|---|---|---|---|---|---|---|---|
| Free trial | All | Active | 30 days | null | 50 | 10 | 0 | 3 (clinic placeholder) |
| Solo Basic | Solo | Inactive, price 0 | 30 days | null | 100 | 20 | 0 | 1 |
| Solo Pro | Solo | Inactive, price 0 | 30 days | null | 300 | unlimited | 1 | 1 |
| Clinic, per doctor | Clinic and centre | Inactive, price 0 | 30 days | null | 300 | unlimited | 5 | bought per doctor |
Which limits are enforced
| Limit | Enforced | Note |
|---|---|---|
| Prescriptions per month | Yes | Counted per calendar month in Dhaka time; replays are never blocked |
| Templates | Yes | A replay of an existing template is not a new one |
| Doctor seats (clinic, centre) | Yes | Inviting or accepting beyond paid seats answers 402 |
| Compounder seats | No | Stored and shown; the one-assistant rule for chambers is hard-coded |
| SMS per month | No | Stored and shown, not counted yet |
Proposed pricing model: per doctor seat, packaged by feature
Revenue follows the number of doctors, and what each doctor gets depends on a feature tier. Seats are already real in the code: a clinic buys doctor seats and a chamber is one seat. Feature tiers are not yet built: a plan stores a list of feature names, but no screen or rule is gated by it today. The tier names, the packaging below and every price are proposals for the product owner.
| Feature or limit | Core | Plus | Pro | Today in code |
|---|---|---|---|---|
| Queue, prescribe, print, patient SMS link, offline | ✓ | ✓ | ✓ | Built |
| Prescriptions per month | Capped | Unlimited | Unlimited | Limit enforced |
| Templates (kits) | Few | More | Unlimited | Limit enforced |
| SMS included per month | Small | Medium | Medium + packs | Stored, not counted |
| Assistant (compounder) seats | 0 | 1 | 5 | Stored, not enforced |
| Cross-doctor history with consent | ✓ | ✓ | ✓ | Built |
| Practice reports | — | ✓ | ✓ | Feature name seeded; reports not built |
| WhatsApp and email to patients | — | Add-on | ✓ | Planned |
| Multi-doctor workplace, roles, front desk | — | — | ✓ | Built (clinic plan) |
| Diagnostic centre orders and results | — | — | Add-on | Planned |
| Extra SMS pack, extra assistant seat | Add-on | Add-on | Add-on | Not built |
Why per doctor
A clinic with more doctors earns more for DPMS, and a doctor who works in two places holds a seat in each. The seat check already blocks inviting past the paid number.
Why feature tiers
A solo doctor can start on Core and move up when reports or patient channels matter, with no new sales cycle. A tier change is a plan row, not a release.
What must be built
Check a plan's feature list at the point of use, add a tier column to the plan, enforce SMS and assistant limits, and price add-ons. Seats, limits, approval and payment already exist.
Revenue illustrator
Change the example numbers to see monthly recurring revenue from seats by tier plus add-ons. These are not DPMS prices and not a forecast; real prices are set by operators in the console.
Monthly recurring revenue
Patient data, locked down by design.
Seven gates before data is touched, and two walls between workplaces
A health product is judged by what happens when something goes wrong. Isolation does not rely on one filter: the application filters every query by workplace and the database itself refuses rows from other workplaces.
Protected data
| Data | What | How |
|---|---|---|
| Patient | name, phone, address, custom fields | AES-256-GCM, phone also as keyed hash for lookup |
| Prescription | complaints, diagnoses, advice, drugs and tests text, print snapshot | AES-256-GCM bound to workplace, row and column |
| Operator login | authenticator secret | Encrypted, bound to the user, one use per code |
| Passwords | user password | bcrypt hash; sign-in lockout after repeated failures |
| Events, logs, SMS | ids and rx number only | No clear patient data leaves the database |
Controls worth naming
- Row-level security, forced. Enabled on patients, queue, prescriptions, templates, print layouts, share links and memberships. The app connects as a role that cannot bypass it. No workplace in scope means no rows.
- Short-lived, rotating sessions. Refresh tokens are hashed and rotate on every use; replaying an old one revokes the device family.
- Patient link hardening. Random 10-character code, last-four gate, attempts reserved before comparing, lockout that grows to 24 hours, identical 404 for all dead links, no medical data in the URL or SMS.
- Operator access. Granted only from a trusted shell, never through the API, and protected by an authenticator code in deployed environments. Operators see subscriptions and payments, not patients.
- Fail-closed deployment. The service refuses to start in a deployed environment with weak secrets, dev code echo, console SMS or header-trust tenancy.
Run a platform with a small team.
The operator console, and the numbers the same tables can answer
A small team can run the platform because approvals, pricing and support actions are screens, not scripts. The tables that bill customers and record prescriptions hold the figures investors ask for. No metrics dashboard exists yet, so these are queries today.
Console screens
- Payments. Review reported bKash and Nagad payments; approve to renew or reject with a reason
- Doctors (BM&DC). Queue of unverified numbers, oldest first; verify or reject with a reason
- Workplaces. Find workplaces, approve or reject new clinics and centres, suspend, reactivate, override a subscription with a reason
- Plans. Set price, period, limits and availability; edits are version-checked
- Catalogue (API). Create, update and deactivate drugs and tests; bulk import from CSV or XLSX
Why operations stay light
- Every action is audited. Reject, suspend and override each need a written reason.
- Decisions happen once. A payment or an approval cannot be decided twice.
- Prices and limits are data. No release is needed to change a plan.
- Support can override safely. Put a workplace on a plan until a date, with a reason and a record.
Metrics and where each comes from
| Metric | Definition | Source tables | Availability |
|---|---|---|---|
| Paying workplaces | Workplaces with status active, by plan and type | subscriptionstenants | Query today |
| Monthly recurring revenue | Approved payments per 30-day period; clinic amounts divided by seats | payment_recordssubscriptions | Query today |
| Trial to paid | Workplaces with an approved payment ÷ trials started, by start month | subscriptionspayment_recordstenants | Query today |
| Prescriptions issued | Issued per day, month, doctor and workplace | prescriptions | Query today |
| Active doctors | Doctors with at least one issued prescription in the month | prescriptionstenant_members | Query today |
| Churn | Workplaces moving to read-only without a later payment | subscriptions | Query today |
| Verification backlog | Doctors waiting for BM&DC review and for how long | users | Query today |
| SMS delivered | Messages sent and failed by day | notification_messages | Query today |
| Patients and repeat visits | New charts, returning patients, consented cross-doctor reads | patientsqueue_serialsperson_consents | Query today |
| Expansion revenue | Seat growth and plan upgrades | payment_recordssubscriptions | Needs history of plan changes |
Simple to run. Ready to scale.
A modular monolith with clear seams, built to split later
One deployable service keeps the team small and the system simple. Modules talk through ports, and lint rules fail the build if a business module reaches into another module's internals or into infrastructure. If one part needs to scale or be owned separately, it can be cut out along an existing seam.
Stack
| Frontend | Next.js 15 (App Router), React 19, TypeScript strict, Tailwind v4, TanStack Query, Dexie, service worker, Zustand |
|---|---|
| Backend | NestJS 11 on Fastify, TypeScript strict, Zod validation, Prisma 7 |
| Data | PostgreSQL 16 with a read-replica option, Redis, RabbitMQ |
| Messaging | Transactional outbox, BullMQ notification pipeline, Greenweb SMS, Resend email |
| Contract | OpenAPI document exported from the API; frontend types generated from it |
| Quality | Architecture boundaries enforced by lint, about 570 test cases in the backend and 126 in the frontend, two database integration suites, two black-box flow tests, CI on every change |
| Operations | Liveness and readiness endpoints, Prometheus metrics, Sentry, structured logs without patient data |
Design rules that protect the product
- Business never imports infrastructure. Raw database, queue and cache clients live only in infrastructure and platform code.
- One path to change data. Aggregates enforce rules; a use case saves, writes the event and writes the audit row in one transaction.
- Client-minted ids and versions. Make offline replays safe and conflicts visible.
- Idempotent background work. Claims use database locks and leases; every state change is guarded, so redelivery never double-applies.
- Scaling path. Stateless API nodes, a read replica for queries, more queue workers, monthly partitions for the outbox and audit tables when volume grows.
The SMS chain after a prescription is issued
A data model you can audit.
48 models, grouped so each part can change on its own
These diagrams show the business tables and their key columns. Fields ending in _enc are encrypted. A further set of platform tables (scheduler, recurring, batch, import, webhook, locking, idempotency, inbox) exists as shared capability and is not drawn.
Accounts, workplaces and money
Patients, queue and prescriptions
Consent, messages and platform records
Rules the database enforces
| Table | Rule |
|---|---|
| patients | Unique chart number and barcode per workplace; phone lookup by keyed hash; row-level security forced |
| persons | Barcode unique across all workplaces |
| queue_serials | Unique (workplace, doctor, date, serial) is the safety net behind the numbering service |
| prescriptions | Unique (workplace, rx number); client id as primary key makes create idempotent; versioned updates |
| prescription_access | Short code unique; holds no patient data; attempt and lock state lives here |
| subscriptions | One per workplace; status is a listing hint, access is recomputed from dates |
| payment_records | Unique (method, transaction id), so one real payment cannot renew two workplaces |
| person_consents | Locked to the doctor they belong to; the patient page may only set revoked_at |
| audit_logs, person_access_log | Append-only for the application role |
| Prices and limits | Stored in plans as data; activating a paid plan without a price is refused |
Where we go next, ranked.
Twenty-one gaps, ranked, across business, product, technology and compliance
The clinical core is built and working. What stands between it and a paying pilot is mostly the business shell: prices, reminders, invoicing and operations. Priority P0 blocks a pilot, P1 should land in the first paid release, P2 follows once usage proves the need.
| Area | Where we are | Improvement | Why it matters | Priority |
|---|---|---|---|---|
| Business | Prices not set; every paid plan inactive at 0 | Set prices from 3 to 5 pilot workplaces, activate Solo and Clinic plans, decide trial rules | No revenue until priced | P0 |
| Business | Payments are manual: the manager sends money and reports the transaction | Add an online gateway (bKash, Nagad or an aggregator) with webhook verification and automatic renewal; keep manual as a fallback | Removes operator effort and delay at scale | P1 |
| Business | No invoices, receipts or VAT documents | Numbered invoice and receipt per payment, tax fields, downloadable | Needed by clinics and for audit | P1 |
| Business | No renewal, trial-ending or failed-payment messages (only an in-app banner) | Trial day 23, day 27 and expiry notices; grace and read-only messages by email, SMS and WhatsApp | Largest lever for conversion and recovery | P0 |
| Business | Plans store a features list but nothing checks it; no tiers | Seat plus feature-tier packaging: gate reports, patient channels and centre tools by the plan, add a tier column, price add-ons | Turns one seat price into a ladder | P1 |
| Business | Plan limits: SMS per month and compounder seats stored but not enforced; no add-ons, coupons or proration | Enforce all limits; add add-ons, coupons, seat proration and upgrade preview | Plans must mean what they say | P1 |
| Product | Patient reached by SMS only; patient has no email field | Channel order SMS, then WhatsApp, then email: per-patient preference, encrypted email, delivery fallback, delivery receipts | Higher delivery and lower SMS cost | P1 |
| Product | Name search impossible because names are encrypted | Search by phone, barcode and patient number plus a client-side name search over cached recent patients | Daily friction at the front desk | P1 |
| Product | No standalone patient profile page; reports and analytics missing | Patient profile with history and files; doctor and clinic reports; metrics dashboard for operators | Retention and clinic value | P1 |
| Product | Diagnostic centre treated like a clinic | Test orders from prescriptions, sample tracking, result entry, results back to the prescriber and patient | Makes the centre a distinct product | P2 |
| Product | UI text is English only; Bangla only on print | Translation scaffolding (Bangla and English) before more screens are added | Harder to retrofit later | P1 |
| Product | Queue is polled, not live; no allergy or dose warnings; no merge of duplicate persons | Live queue for clinics, advisory warnings, tool to merge duplicate people | Clinic mode and safety | P2 |
| Technology | Backups and point-in-time restore not drilled; no alert on stalled outbox | Backup and restore drill, alerts on dead-letter and stalled queues, runbooks | Release checklist item before pilot | P0 |
| Technology | No measured performance numbers (search time, bundle size, load) | Set budgets and measure on a low-end phone; load test at expected volume | Claims need evidence | P1 |
| Technology | Browser tests are scripts, not part of CI; no print snapshot tests | Commit offline and print tests to CI with golden images, including Bangla conjuncts | Catches regressions that unit tests cannot | P1 |
| Technology | Webhook and recurring services listen on a path that no longer receives events; several platform services have no consumer | Move them to the live event bus or remove them; keep the codebase honest | Dead code hides real behaviour | P2 |
| Technology | One process runs web, workers and the dispatcher; RabbitMQ has no recorded decision | Split workers when load needs it; write the decision record for RabbitMQ or drop it | Operational simplicity | P2 |
| Security and compliance | BM&DC rule is verified-or-7-days; policy confirmation pending | Confirm the policy with counsel and the council; add automated checks if a source exists | Legal validity of prescriptions | P0 |
| Security and compliance | Bangladesh health-data and consent obligations not yet legally reviewed; consent wording open | Legal review; final Bangla and English consent text; data residency decision | Required before launch | P0 |
| Security and compliance | SMS cost abuse limits are partial; Greenweb contract unverified; metrics endpoint public unless a token is set | Country allow-list and per-account SMS budget; confirm the live gateway contract; protect metrics at the gateway | Cost and exposure | P1 |
| Security and compliance | Audit coverage incomplete (catalogue imports, some views); no recovery codes for operator second factor | Complete audit coverage; recovery codes and lockout for operators; per-workplace encryption keys | Trust and recoverability | P1 |
Sources: the product gap report kept in the backend documentation, checked against the current code. Priorities are a recommendation for the product owner to confirm.
Three releases to revenue.
Three releases, and ten decisions to settle first
Release 1 makes the product safe to put in front of paying pilot doctors. Release 2 turns pilots into a billing business. Release 3 widens the product for clinics, centres and patients.
Safe and priced
- Set and activate plan prices
- Trial and renewal reminders by email and SMS
- Backup drill, stall alerts, runbooks
- Legal review and consent wording
- BM&DC policy confirmed
- Print tests on real printers, Bangla included
Automate money
- Online payment gateway and automatic renewal
- Invoices, receipts, VAT
- Enforce SMS and assistant limits
- Seat plus feature tiers and add-ons
- Operator metrics dashboard
- WhatsApp then email for patients
- Bangla and English interface
Clinics, centres, patients
- Diagnostic centre orders and results
- Live queue and shared visibility rules for clinics
- Reports for doctors and managers
- Add-ons, coupons, partner pricing
- Server PDF and data export
- Pad designer and custom fields