Skip to content

thepherm/htpi-nats

Repository files navigation

HTPI NATS Server

Central messaging backbone for the HTPI healthcare platform, providing secure multi-tenant communication between microservices.

Overview

This NATS server configuration provides:

  • JetStream for message persistence
  • Service-level authentication and authorization
  • Topic-based permissions for each service
  • Clustering support for high availability
  • Health monitoring endpoints

Services Architecture

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│ Customer Portal │────▶│  Gateway Service │────▶│                 │
└─────────────────┘     └──────────────────┘     │                 │
                                                  │                 │
┌─────────────────┐     ┌──────────────────┐     │                 │
│  Admin Portal   │────▶│  Admin Service   │────▶│                 │
└─────────────────┘     └──────────────────┘     │                 │
                                                  │   NATS Server   │
┌──────────────────────────────────────────┐      │                 │
│          Microservices Layer             │      │                 │
├─────────────┬──────────────┬────────────┤      │                 │
│  Patients   │  Insurance   │   Forms    │─────▶│                 │
│  Service    │   Service    │  Service   │      │                 │
└─────────────┴──────────────┴────────────┘      │                 │
                     │                            │                 │
┌────────────────────┼────────────────────┐      │                 │
│   ClaimMD    │  MongoDB Service         │◀─────│                 │
│   Service    │  (Database Layer)        │      └─────────────────┘
└──────────────┴──────────────────────────┘

Topic Structure

Service Topics

  • patient.* - Patient management operations
  • insurance.* - Insurance management operations
  • form.* - HCFA form operations
  • claimmd.* - ClaimMD API operations
  • db.* - Database operations
  • admin.* - Administrative operations
  • health.* - Health check operations

Message Patterns

  • *.request - Service requests
  • *.response - Service responses
  • *.event - Event notifications

Environment Variables

Required for Production

NATS_PATIENTS_USER=<service_username>
NATS_PATIENTS_PASS=<secure_password>
NATS_INSURANCE_USER=<service_username>
NATS_INSURANCE_PASS=<secure_password>
NATS_FORMS_USER=<service_username>
NATS_FORMS_PASS=<secure_password>
NATS_CLAIMMD_USER=<service_username>
NATS_CLAIMMD_PASS=<secure_password>
NATS_MONGODB_USER=<service_username>
NATS_MONGODB_PASS=<secure_password>
NATS_GATEWAY_USER=<service_username>
NATS_GATEWAY_PASS=<secure_password>
NATS_ADMIN_USER=<service_username>
NATS_ADMIN_PASS=<secure_password>

Deployment

Railway

railway up

Docker

docker build -t htpi-nats .
docker run -p 4222:4222 -p 8222:8222 htpi-nats

Docker Compose

docker-compose up -d

Monitoring

Access the monitoring dashboard at http://localhost:8222

Health Check Endpoint

curl http://localhost:8222/healthz

Security

  • Each service has its own credentials
  • Topic-based permissions restrict service access
  • No service can directly access another service's topics
  • All database operations must go through the MongoDB service

Multi-Tenancy

Multi-tenancy is handled at the application level:

  • Each message includes org_id in the payload
  • Services filter operations by organization
  • Database service enforces tenant isolation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published