Central messaging backbone for the HTPI healthcare platform, providing secure multi-tenant communication between microservices.
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
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Customer Portal │────▶│ Gateway Service │────▶│ │
└─────────────────┘ └──────────────────┘ │ │
│ │
┌─────────────────┐ ┌──────────────────┐ │ │
│ Admin Portal │────▶│ Admin Service │────▶│ │
└─────────────────┘ └──────────────────┘ │ │
│ NATS Server │
┌──────────────────────────────────────────┐ │ │
│ Microservices Layer │ │ │
├─────────────┬──────────────┬────────────┤ │ │
│ Patients │ Insurance │ Forms │─────▶│ │
│ Service │ Service │ Service │ │ │
└─────────────┴──────────────┴────────────┘ │ │
│ │ │
┌────────────────────┼────────────────────┐ │ │
│ ClaimMD │ MongoDB Service │◀─────│ │
│ Service │ (Database Layer) │ └─────────────────┘
└──────────────┴──────────────────────────┘
patient.*
- Patient management operationsinsurance.*
- Insurance management operationsform.*
- HCFA form operationsclaimmd.*
- ClaimMD API operationsdb.*
- Database operationsadmin.*
- Administrative operationshealth.*
- Health check operations
*.request
- Service requests*.response
- Service responses*.event
- Event notifications
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>
railway up
docker build -t htpi-nats .
docker run -p 4222:4222 -p 8222:8222 htpi-nats
docker-compose up -d
Access the monitoring dashboard at http://localhost:8222
curl http://localhost:8222/healthz
- 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 is handled at the application level:
- Each message includes
org_id
in the payload - Services filter operations by organization
- Database service enforces tenant isolation