Kiến trúc tổng thể
Mô hình Hyperscaler-style: control plane đa dịch vụ + data plane trên OpenStack/K8s, event-driven, observable.
Sơ đồ luồng request
┌────────────┐
│ End user │
└─────┬──────┘
│ HTTPS
▼
┌──────────────────────┐ ┌───────────────────────┐
│ Lotus Console (Next)│◄──►│ API Gateway (Go) │
│ :3100 │ │ :8080 + auth/RBAC │
└──────────────────────┘ └──────────┬────────────┘
│ JWT context
┌───────────────────────────────┼───────────────────────────────┐
▼ ▼ ▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐
│ iam:8081 │ │compute:82 │ │storage:83 │ │ network:84│ … │72 services│
└────┬──────┘ └────┬──────┘ └────┬──────┘ └────┬──────┘ └────┬──────┘
│ │ │ │ │
└─────► PostgreSQL ◄─── Redis ───────► RabbitMQ (events) ◄──────┘
│
OpenTelemetry → Jaeger · Prometheus · Grafana
Layer logic
Edge / Gateway
API Gateway (Go) làm reverse proxy + auth forward + rate-limit. Lotus Console (Next.js) là SPA cho người dùng cuối & admin.
Control plane
72 microservice Go chuyên trách (iam, compute, network…) — stateless, scale ngang. Mỗi service expose REST + healthz + Prometheus metrics + OTel traces.
Data plane
VM/container chạy trên Docker (dev) / OpenStack KVM + Kubernetes (prod). Block/Object storage tách lớp, snapshots & backups quản lý qua control plane.
Event bus
RabbitMQ làm event backbone — billing events, audit, autoscale signals — có DLQ + retry, được wrap trong package events.
Observability
OpenTelemetry collector → Jaeger (tracing), Prometheus (metrics), Grafana (dashboards), audit-service (compliance log).
Storage layer
PostgreSQL share schemas per service (30 max conn, 10 idle), Redis cho session/cache, object-storage filesystem-backed (S3 API).
Shared Go packages
| Package | Mục đích |
|---|---|
logger | Zerolog structured logging, request id propagation. |
dbconnector | GORM + PostgreSQL pool (30 max / 10 idle), helpers migrate. |
rbac | Middleware RBAC, gọi IAM remote authorize. |
errorhandler | Standardized API response + error mapping. |
events | RabbitMQ publisher với DLQ + retry, JSON envelope. |
tracing | OpenTelemetry init + Jaeger exporter. |
geoip | IP→geo lookup cho audit/anti-abuse. |
Triển khai
| Môi trường | Công cụ | Vị trí |
|---|---|---|
| Dev (single host) | Docker Compose | docker-compose.yml |
| Staging / Prod | Kubernetes Helm | infrastructure/k8s/ |
| IaC | Terraform | infrastructure/terraform/ |
| Edge nodes | node-agent + cluster-bootstrap | services/node-agent/ |