System Architecture

Technical overview of Glide HIMS architecture

High-Level Architecture
┌─────────────────────────────────────────────────────────────────────────────────────┐
│                              GLIDE HIMS ARCHITECTURE                                │
├─────────────────────────────────────────────────────────────────────────────────────┤
│                                                                                     │
│   ┌──────────────┐   ┌──────────────┐   ┌──────────────┐   ┌──────────────┐        │
│   │   Web App    │   │  Mobile App  │   │   Kiosk App  │   │  3rd Party   │        │
│   │   (React)    │   │  (React N.)  │   │   (Electron) │   │    APIs      │        │
│   └──────┬───────┘   └──────┬───────┘   └──────┬───────┘   └──────┬───────┘        │
│          │                  │                   │                  │                │
│          └─────────────┬────┴───────────────────┴───────┬──────────┘                │
│                        │                                │                           │
│                        ▼                                ▼                           │
│            ┌───────────────────────┐       ┌───────────────────────┐               │
│            │   NGINX / Load        │       │   WebSocket Server    │               │
│            │   Balancer + SSL      │       │   (Real-time events)  │               │
│            └───────────┬───────────┘       └───────────┬───────────┘               │
│                        │                                │                           │
│                        ▼                                ▼                           │
│   ┌─────────────────────────────────────────────────────────────────────────┐      │
│   │                         NestJS Backend Application                      │      │
│   ├─────────────────────────────────────────────────────────────────────────┤      │
│   │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐           │      │
│   │  │  Auth   │ │Patients │ │ Billing │ │Pharmacy │ │   Lab   │           │      │
│   │  │ Module  │ │ Module  │ │ Module  │ │ Module  │ │ Module  │           │      │
│   │  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘           │      │
│   │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐           │      │
│   │  │   IPD   │ │   HR    │ │ Assets  │ │ Reports │ │Settings │           │      │
│   │  │ Module  │ │ Module  │ │ Module  │ │ Module  │ │ Module  │           │      │
│   │  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘           │      │
│   │  ┌─────────────────────────────────────────────────────────────┐       │      │
│   │  │            Enterprise Services (License, Updates, Flags)    │       │      │
│   │  └─────────────────────────────────────────────────────────────┘       │      │
│   └───────────────────────────────┬─────────────────────────────────────────┘      │
│                                   │                                                 │
│          ┌────────────────────────┼────────────────────────┐                       │
│          ▼                        ▼                        ▼                       │
│   ┌─────────────┐         ┌─────────────┐         ┌─────────────┐                  │
│   │ PostgreSQL  │         │    Redis    │         │ File Store  │                  │
│   │  Database   │         │   (Cache)   │         │  (S3/Local) │                  │
│   └─────────────┘         └─────────────┘         └─────────────┘                  │
│                                                                                     │
└─────────────────────────────────────────────────────────────────────────────────────┘
Technology Stack
Frontend
React 18 Vite Tailwind CSS Zustand React Query React Router
Backend
NestJS TypeScript TypeORM Passport.js Swagger
Database & Cache
PostgreSQL 15 Redis 7
Infrastructure
Docker Nginx PM2
Backend Module Structure
packages/backend/src/
├── main.ts                     # Application entry point
├── app.module.ts               # Root module, imports all feature modules
├── common/                     # Shared utilities, decorators, guards
│   ├── decorators/
│   ├── filters/
│   ├── guards/
│   ├── interceptors/
│   └── pipes/
├── config/                     # Configuration management
├── database/
│   ├── entities/              # TypeORM entities (data models)
│   └── migrations/            # Database migrations
└── modules/
    ├── auth/                   # Authentication & authorization
    │   ├── auth.controller.ts
    │   ├── auth.service.ts
    │   ├── auth.module.ts
    │   ├── guards/
    │   ├── strategies/        # JWT, Local, etc.
    │   └── decorators/
    ├── patients/              # Patient management
    ├── appointments/          # Scheduling
    ├── billing/               # Invoicing & payments
    ├── finance/               # Financial management
    ├── pharmacy/              # Drug inventory & dispensing
    ├── laboratory/            # Lab tests & results
    ├── ipd/                   # Inpatient management
    ├── opd/                   # Outpatient management
    ├── hr/                    # Human resources
    ├── assets/                # Asset management
    ├── notifications/         # Alerts & notifications
    ├── reports/               # Report generation
    ├── settings/              # System configuration
    ├── licensing/             # Enterprise licensing
    │   ├── license.service.ts
    │   ├── license.controller.ts
    │   └── phone-home.service.ts
    ├── feature-flags/         # Feature flag management
    └── updates/               # Version & update management
                

Core System Modules

Patient Management
  • Patient registration with demographics
  • Medical Record Number (MRN) generation
  • Medical history tracking
  • Biometric verification integration
  • Insurance & membership management
Billing & Finance
  • Invoice generation
  • Payment processing (cash, card, mobile money)
  • Insurance claim management
  • Financial reporting
  • Pricing management
Pharmacy
  • Drug inventory management
  • Prescription processing
  • Medication dispensing
  • Stock alerts & reorder points
  • Batch & expiry tracking
Laboratory
  • Test catalog management
  • Order creation & tracking
  • Result entry & validation
  • Equipment integration (HL7/FHIR)
  • Quality control
Inpatient (IPD)
  • Admission management
  • Bed/ward allocation
  • Nursing notes & vitals
  • Discharge planning
  • Bed occupancy tracking
Human Resources
  • Employee management
  • Attendance tracking
  • Leave management
  • Payroll integration
  • Department management
Request Flow
┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐
│  Client  │───▶│   Nginx  │───▶│  Guards  │───▶│Controller│───▶│ Service  │
│ (Browser)│    │  (SSL)   │    │  (Auth)  │    │ (Route)  │    │ (Logic)  │
└──────────┘    └──────────┘    └──────────┘    └──────────┘    └────┬─────┘
                                                                     │
                                                                     ▼
┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐
│ Response │◀───│Interceptor◀───│ Service  │◀───│Repository│◀───│ Database │
│  (JSON)  │    │(Transform)│    │ (Logic)  │    │ (ORM)    │    │  (PG)    │
└──────────┘    └──────────┘    └──────────┘    └──────────┘    └──────────┘

Flow explanation: 1. Client sends request → 2. Nginx handles SSL termination and proxies to backend → 3. Auth guards validate JWT token → 4. Controller handles route → 5. Service contains business logic → 6. Repository interacts with database → 7. Response transformed and returned to client

Database Schema Overview
┌─────────────────┐       ┌─────────────────┐       ┌─────────────────┐
│     tenants     │       │      users      │       │    employees    │
├─────────────────┤       ├─────────────────┤       ├─────────────────┤
│ id (PK)         │◀──┐   │ id (PK)         │       │ id (PK)         │
│ name            │   │   │ tenant_id (FK) ─┼──────▶│ user_id (FK)   ─┼──▶ users
│ subdomain       │   └───┤ email           │       │ tenant_id (FK)  │
│ license_key     │       │ password_hash   │       │ department      │
│ settings        │       │ role            │       │ position        │
└─────────────────┘       └─────────────────┘       └─────────────────┘

┌─────────────────┐       ┌─────────────────┐       ┌─────────────────┐
│    patients     │       │   encounters    │       │    invoices     │
├─────────────────┤       ├─────────────────┤       ├─────────────────┤
│ id (PK)         │◀──────┤ patient_id (FK) │◀──────┤ encounter_id(FK)│
│ tenant_id (FK)  │       │ tenant_id (FK)  │       │ tenant_id (FK)  │
│ mrn             │       │ doctor_id (FK)  │       │ patient_id (FK) │
│ full_name       │       │ facility_id     │       │ total_amount    │
│ date_of_birth   │       │ type            │       │ paid_amount     │
│ gender          │       │ status          │       │ status          │
│ phone           │       │ diagnosis       │       │ items (JSONB)   │
│ insurance_info  │       │ notes           │       │ created_at      │
└─────────────────┘       └─────────────────┘       └─────────────────┘

┌─────────────────┐       ┌─────────────────┐       ┌─────────────────┐
│     licenses    │       │  feature_flags  │       │  app_versions   │
├─────────────────┤       ├─────────────────┤       ├─────────────────┤
│ id (PK)         │       │ id (PK)         │       │ id (PK)         │
│ license_key     │       │ tenant_id (FK)  │       │ version         │
│ organization    │       │ feature         │       │ release_notes   │
│ license_type    │       │ is_enabled      │       │ is_mandatory    │
│ max_users       │       │ config (JSONB)  │       │ is_latest       │
│ expires_at      │       │ updated_at      │       │ released_at     │
│ signature       │       └─────────────────┘       └─────────────────┘
└─────────────────┘
Security Architecture
Authentication
  • JWT-based authentication
  • Access tokens (1 hour expiry)
  • Refresh tokens (7 days expiry)
  • Optional MFA (TOTP)
  • Biometric authentication support
Authorization
  • Role-based access control (RBAC)
  • Permission-based guards
  • Tenant isolation (multi-tenant)
  • Facility-level access control
  • Resource ownership checks
Data Protection
  • TLS 1.3 for transport encryption
  • Passwords hashed with bcrypt
  • Sensitive data encryption at rest
  • Audit logging for all changes
API Security
  • Rate limiting (100 req/min default)
  • CORS configuration
  • Input validation (class-validator)
  • SQL injection prevention (TypeORM)
  • XSS protection headers