Infrastructure Overview
This document provides an overview of the iHospita infrastructure architecture, including API gateway, observability stack, and deployment configuration.
Architecture Diagram
┌─────────────────────────────────────────────────────────────────────────────────┐
│ INFRASTRUCTURE OVERVIEW │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ CLIENTS │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Portal │ │ Console │ │ Queue │ │ Landing │ │
│ │ (React) │ │ (Next.js) │ │ (Next.js) │ │ (Next.js) │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │ │
│ └────────────────┴────────────────┴────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ CLOUDFLARE (CDN + WAF) │ │
│ │ - DDoS Protection - SSL/TLS Termination - Edge Caching │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ KONG API GATEWAY │ │
│ │ - Rate Limiting - Authentication - Load Balancing │ │
│ │ - Request Transform - Circuit Breaker - Health Checks │ │
│ │ │ │
│ │ Routes: │ │
│ │ /api/auth/* → Keycloak │ │
│ │ /api/hms/* → HMS Service │ │
│ │ /api/crm/* → CRM Service │ │
│ │ /api/payment/* → Payment Service │ │
│ │ /api/queue/* → Queue Service │ │
│ │ /api/report/* → Report Service │ │
│ └────────────────────── ───────────────────────────────────────────────────┘ │
│ │ │
│ ┌──────────────────────────┼──────────────────────────┐ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Keycloak │ │ NestJS │ │ NestJS │ │
│ │ (Identity) │ │ Services │ │ Report │ │
│ │ │ │ │ │ Service │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └──────────────────────────┼──────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ DATA LAYER │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ PostgreSQL │ │ PostgreSQL │ │ Redis │ │ S3/Spaces │ │ │
│ │ │ (App DB) │ │ (Keycloak) │ │ (Cache) │ │ (Storage) │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ OBSERVABILITY STACK │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ Prometheus │ │ Loki │ │ Grafana │ │ Tempo │ │ │
│ │ │ (Metrics) │ │ (Logs) │ │ (Dashboard) │ │ (Traces) │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
Technology Stack
| Layer | Technology | Purpose |
|---|---|---|
| CDN/WAF | Cloudflare | DDoS protection, SSL termination, caching |
| API Gateway | Kong 3.5 | Rate limiting, auth, routing, load balancing |
| Identity | Keycloak 23 | OAuth2/OIDC, 2FA, user management |
| Backend | NestJS | Microservices (hms, crm, payment, queue, report) |
| Database | PostgreSQL 15 | Primary relational database |
| Cache | Redis 7 | Session, caching, pub/sub, queues |
| Storage | DigitalOcean Spaces | S3-compatible object storage |
| Metrics | Prometheus | Time-series metrics collection |
| Logs | Loki | Log aggregation and querying |
| Traces | Tempo | Distributed tracing |
| Dashboards | Grafana | Visualization and alerting |
| Container | Docker | Containerization |
| Orchestration | Docker Compose | Container orchestration |
Service Endpoints
| Service | Internal URL | Kong Route |
|---|---|---|
| Keycloak | http://keycloak:8080 | /auth/* |
| HMS Service | http://hms-service:3000 | /api/hms/* |
| CRM Service | http://crm-service:3001 | /api/crm/* |
| Payment Service | http://payment-service:3002 | /api/payment/* |
| Queue Service | http://queue-service:3003 | /api/queue/* |
| Report Service | http://report-service:3004 | /api/report/* |
Port Allocation
| Service | Port | Purpose |
|---|---|---|
| Kong Proxy | 8000 | HTTP API requests |
| Kong Proxy SSL | 8443 | HTTPS API requests |
| Kong Admin | 8001 | Kong admin API |
| Keycloak | 8080 | Identity provider |
| PostgreSQL | 5432 | Database |
| Redis | 6379 | Cache |
| Prometheus | 9090 | Metrics server |
| Grafana | 3000 | Dashboard UI |
| Loki | 3100 | Log aggregation |
| Tempo | 3200 | Trace collection |
Network Architecture