tpt-doctor

TypeScript

A HIPAA/GDPR-compliant medical practice management platform built as a TypeScript monorepo. Covers EHR, appointments, telemedicine, billing, prescriptions, lab orders, and a patient portal — with multi-country support (AU, NZ, UK, CA) and deployable to AWS, Azure, GCP, or on-premise.

0 stars0 forks0 watchersMIT License
dockerehrfhirgdprhealthcarehipaamedicalmonoreponextjspatient-portalpnpm-workspacespostgresqlprismaself-hostedtelemedicineterraformtypescript

Languages

TypeScript92.4%HCL4.3%CSS0.9%Shell0.7%PLpgSQL0.6%JavaScript0.5%Jinja0.3%Dockerfile0.2%HTML0.1%
README

TPT Doctor — Complete Medical Practice Platform

Open-source, HIPAA-compliant, multi-country medical practice management platform.
Manage patients, appointments, EHR, billing, prescriptions, lab orders, telemedicine, and more — all in one system.

License: MIT Node pnpm PostgreSQL TypeScript


Features

| Module | What it does | |--------|--------------| | Patient Management | Registration, demographics, insurance, search, merge, consent management | | Electronic Health Records | SOAP notes, vitals, medical history, problem lists, clinical timeline, document upload | | Appointment Scheduling | Calendar (day/week/month), booking, recurring, waitlist, reminders, check-in/out | | Staff Management | Roles, permissions, schedules, PTO, credentialing, performance metrics | | Patient Portal | Self-service login, medical records, lab results, appointment requests, messaging | | Secure Messaging | Inbox/outbox, threading, file attachments, read receipts, urgent flags | | Billing & Invoicing | Invoices, insurance claims, payment processing (Stripe/Airwallex), ERA/EOB, aging reports | | Prescriptions | ePrescribing, drug interactions, controlled substances (DEA), pharmacy directory | | Lab Orders | Order creation, specimen tracking, result entry, abnormal alerts, FHIR import | | Telemedicine | Video consults (WebRTC/Jitsi), waiting room, screen sharing, in-consult chat, recording | | Reporting | KPIs, clinical quality, financial, demographics, ad-hoc builder, export (CSV/JSON/PDF) | | Compliance | HIPAA, GDPR, Australia Privacy Act, NZ HISO, SOC2 — audit logging, encryption, breach notification | | Multi-Country | Australia (MBS/PBS/MHR), New Zealand (MOH/PHO/NHI), UK (NHS/GP Connect), Canada (provincial) | | FHIR R4 API | Patient, Observation, MedicationRequest, Appointment, Encounter, Bulk FHIR export | | Business Intelligence | Revenue analytics, appointment utilization, clinician productivity, demographics, referral analytics | | Inventory | Clinic supplies, vaccine cold chain, medication samples, retail product sales |


Quick Start (5 minutes)

Prerequisites

1. Clone and install

git clone https://github.com/PhillipC05/tpt-doctor.git
cd tpt-doctor
pnpm install

2. Configure authentication

  1. Go to Auth0 Dashboard → Create tenant
  2. Create an API with identifier https://api.tptdoctor.com
  3. Create a Single Page Application for the web app (note the Client ID)
  4. Create a Regular Web Application for the API (note the Client ID & Secret)

Edit .env.development:

AUTH0_DOMAIN=your-tenant.us.auth0.com
AUTH0_CLIENT_ID=your-api-client-id
AUTH0_CLIENT_SECRET=your-api-client-secret
AUTH0_AUDIENCE=https://api.tptdoctor.com

For the web app (apps/web/.env.development):

VITE_AUTH0_DOMAIN=your-tenant.us.auth0.com
VITE_AUTH0_CLIENT_ID=your-web-client-id
VITE_AUTH0_AUDIENCE=https://api.tptdoctor.com
VITE_API_URL=http://localhost:4000

3. Start the database

docker compose up -d

4. Run database migrations and seed

pnpm run db:generate
pnpm run db:migrate
pnpm run db:seed

5. Start development servers

pnpm run dev
  • API: http://localhost:4000/api/v1
  • Swagger Docs: http://localhost:4000/api/docs
  • Web App: http://localhost:5173
  • Patient Portal: http://localhost:5174

Deployment Options

🐳 Docker Compose (Self-Hosted — Recommended)

The simplest way to deploy for any single clinic on any VPS:

cp .env.production.example .env
# Edit .env with your values
docker compose -f infrastructure/on-premise/docker-compose.production.yml up -d

Works on any Linux VPS — see guide: docs/deployment/simple-vps.md

🚀 DigitalOcean

Two options — App Platform (no server management) or Droplet (full VPS):

# App Platform: Connect your GitHub repo → auto-deploys via Dockerfile
# Droplet: Full Docker Compose stack with monitoring, storage, telemedicine

Full guide: docs/deployment/digitalocean.md

📦 Any VPS (Linode, Vultr, Hetzner, etc.)

# Works on any Ubuntu VPS — just install Docker and run:
curl -fsSL https://get.docker.com | sh
docker compose -f infrastructure/on-premise/docker-compose.production.yml up -d

Full guide: docs/deployment/simple-vps.md

🤖 Automated (Ansible)

For bare metal or VM on-premise deployment with full automation:

ansible-playbook -i infrastructure/ansible/inventory/hosts.yml infrastructure/ansible/deploy.yml

☁️ Cloud Providers (AWS / Azure / GCP)

Terraform configurations also available for larger deployments:

| Cloud | Guide | Terraform | |-------|-------|-----------| | AWS | docs/deployment/cloud/deployment-guide.md | infrastructure/cloud/aws/ | | Azure | Same guide | infrastructure/cloud/azure/ | | GCP | Same guide | infrastructure/cloud/gcp/ |


Architecture

┌──────────────────────────────────────────────────────────┐
│                    Nginx (TLS termination)                │
├────────────────────┬──────────────────┬─────────────────┤
│  Web App (React)   │ Patient Portal   │  API (NestJS)   │
│  :3000             │ :3001            │  :4000           │
├────────────────────┴──────────────────┴─────────────────┤
│  PostgreSQL 16  │  Redis 7  │  MinIO (S3)  │  Jitsi    │
│  (encrypted)     │  (cache)  │  (storage)   │  (video)  │
└──────────────────────────────────────────────────────────┘

See docs/architecture/overview.md for the full C4 model.


Project Structure

tpt-doctor/
├── apps/
│   ├── api/                    # NestJS backend (REST API)
│   ├── web/                    # React staff frontend
│   └── patient-portal/         # React patient frontend
├── packages/
│   ├── shared/                 # Types, validators, constants
│   ├── auth/                   # Authentication & RBAC
│   ├── encryption/             # PHI encryption (AES-256-GCM)
│   ├── audit-log/              # Immutable audit trail
│   ├── compliance/             # HIPAA/GDPR/Privacy compliance
│   ├── config/                 # Shared configuration
│   ├── database/               # Prisma schema + migrations
│   └── notifications/          # Notification system
├── infrastructure/
│   ├── cloud/{aws,azure,gcp}/  # Terraform configurations
│   ├── on-premise/             # Docker Compose + backups
│   ├── ansible/                # Automated deployment
│   └── monitoring/             # Prometheus + Grafana
├── docs/                       # Full documentation
├── docker/                     # Docker config files
├── LICENSE                     # MIT License
└── README.md                   # This file

Documentation

| Document | Type | Description | |----------|------|-------------| | Quick Start | Guide | Get started in 5 minutes | | Architecture Overview | Technical | C4 model diagrams and system design | | Auth0 Setup | Guide | Step-by-step authentication setup | | System Requirements | Reference | Hardware, software, network requirements |

User Manuals

| Document | Description | |----------|-------------| | Clinical Staff Guide | Day-to-day operations for doctors, nurses, receptionists | | Patient Portal Guide | Self-service guide for patients | | Admin Guide | System administration and tenant management |

Deployment & Operations

| Document | Description | |----------|-------------| | Quick Start (5 min) | Fastest way to get running | | Self-Hosted (Docker) | Full on-premise Docker Compose stack | | DigitalOcean | Deploy on DigitalOcean (App Platform or Droplet) | | Any VPS (Linode, Vultr, etc.) | Generic VPS deployment guide | | Cloud (AWS/Azure/GCP) | Terraform-based cloud deployment | | Upgrade Guide | How to upgrade between versions |

Security & Compliance

| Document | Description | |-------------|-------------| | Security Hardening Checklist | Pre-flight security checklist | | Security Policies | Comprehensive security policies | | Compliance Manual | HIPAA/GDPR/AU/NZ/SOC2 compliance | | Disaster Recovery | Backup and restore procedures |

Configuration & Integrations

| Document | Description | |----------|-------------| | Auth0 Setup | Authentication configuration | | Telemedicine Setup | Jitsi and Twilio Video setup | | Integrations | Stripe, Twilio, SendGrid, and more | | API Reference | OpenAPI/Swagger documentation |

Troubleshooting

| Document | Description | |----------|-------------| | Troubleshooting FAQ | Common issues and solutions |


Tech Stack

| Layer | Technology | |-------|-----------| | Backend | NestJS, TypeScript, Prisma ORM | | Frontend | React 18, Vite, TailwindCSS, Zustand | | Database | PostgreSQL 16 | | Cache | Redis 7 | | Auth | Auth0 (OAuth2/OIDC, JWT, MFA) | | Encryption | AES-256-GCM, envelope encryption, KMS (multi-cloud) | | Storage | S3-compatible (MinIO for self-hosted) | | Telemedicine | WebRTC, Jitsi Meet, Socket.io | | Monitoring | Prometheus, Grafana, Sentry | | Infrastructure | Terraform, Ansible, Docker Compose | | Testing | Jest, Playwright, k6 |


Contributing

TPT Doctor is MIT licensed — contributions are welcome!

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -am 'Add my feature'
  4. Push: git push origin feature/my-feature
  5. Open a Pull Request

Please ensure tests pass: pnpm run test


License

MIT License — feel free to use, modify, and distribute.