Infrastructure Architecture
Compact reference for Digital Thai MoCA / BrainDI platform infrastructure.
AWS account: 564141170168 · Region: ap-southeast-1
Repositories & Deploy Targets
| Repository | Deploy target | Runtime |
|---|---|---|
| automoca-web-app | AWS Amplify → CloudFront | Static SPA |
| braindi-backoffice-frontend | AWS Amplify → CloudFront | Static SPA |
| automoca-api-services | ECS (braindi-backend) + ALB | Go API (port 8080) |
| automoca-aiservice | ECS (automoca-ai-service-dev) | Python Kafka worker |
automoca-api-servicesis deployed in AWS asbraindi-backend(ECR, ECS, secrets).
Topology
DNS (Route53 → CloudFront / ALB)
| Environment | Patient app | Backoffice | API |
|---|---|---|---|
| Prod DTM | dtm.aimet.tech | backoffice.dtm.aimet.tech | api.dtm.aimet.tech |
| Prod BrainDI | braindi.aimet.tech | backoffice.braindi.aimet.tech | api.braindi.aimet.tech |
| Dev | dev.dtm.aimet.tech | backoffice.dev.dtm.aimet.tech | api.dev.braindi.aimet.tech |
| Siriraj | siriraj.*.aimet.tech | backoffice.siriraj.*.aimet.tech | api.siriraj.*.aimet.tech |
- Frontends: CloudFront distributions
- Prod API:
braindi-prod-1392139716.ap-southeast-1.elb.amazonaws.com - Dev API:
dev-alb-452655975.ap-southeast-1.elb.amazonaws.com
ECS
| Cluster | Service | Task definition |
|---|---|---|
braindi-backend | braindi-backend-dev | braindi-backend-dev |
braindi-backend | braindi-backend-prod | braindi-backend-prod |
automoca-ai-service-dev | automoca-ai-service-dev-service-* | automoca-ai-service-dev |
automoca-ai-service-dev | automoca-ai-service-prod-service-* | automoca-ai-service-prod |
global-asr-service | Shared ASR platform | Kafka + WebSocket (/ws/v1/speech) |
Global ASR Integration
braindi-backend uses global-asr-service in two ways:
| Mode | Path | Use case |
|---|---|---|
| Real-time | Patient app → WSS /web/tests/ws/speech → backend WebSocket reverse proxy → ASR_WS_URL/ws/v1/speech | Live transcription during MoCA test (via @bream-is-a-fish/aimet-asr-react-client) |
| Async | Backend → Kafka input.asr → global-asr-service → Kafka braindi.output.asr → backend consumer | Batch/offline audio transcription |
Backend env: ASR_WS_URL (WebSocket base URL), ASR_KAFKA_* (async topics/brokers).
ECR
| Repository | Image example |
|---|---|
braindi-backend | 564141170168.dkr.ecr.ap-southeast-1.amazonaws.com/braindi-backend:<tag> |
automoca-ai-service | 564141170168.dkr.ecr.ap-southeast-1.amazonaws.com/automoca-ai-service:<sha> |
Amplify
| App | Repository | Default domain |
|---|---|---|
auto-moca-web-app | automoca-web-app | ddvcmytiooo28.amplifyapp.com |
braindi-backoffice-frontend | braindi-backoffice-frontend | d36kp5f38yecvq.amplifyapp.com |
Build: yarn install → yarn build → artifacts from dist/. Sentry secrets injected from AWS Secrets Manager at build time.
Data Stores
| Service | Resource | Notes |
|---|---|---|
| MongoDB | External (Atlas) | MONGO_URI via Secrets Manager |
| Redis | braindi-backend-prod-0001-001 | ElastiCache, cache.t4g.micro |
| S3 | automoca-web-backend-dev/prod | Test files, media |
| S3 | audio-temp-automoca-dev | Temporary audio |
| S3 | automoca-data, automoca-img-temp, moca-materials | Assets / temp |
| S3 | braindi-video-test | Video test files |
Messaging
| Component | Topics / channels |
|---|---|
| Kafka (IAM auth in prod) | ASR: input.asr → braindi.output.asr |
| Kafka | AI: input.ai.braindi → output.ai.braindi |
| SNS | braindi-predict-result-delay-alarm-dev/prod |
| global-asr-service (ECS) | Real-time: WSS /ws/v1/speech (proxied by backend). Async: consumes input.asr, produces braindi.output.asr; S3: global-asr-service-dev |
| automoca-aiservice (ECS) | Consumes input.ai.braindi, produces output.ai.braindi |
Secrets Manager
| Secret prefix | Used by |
|---|---|
braindi-backend-dev, braindi-backend-prod | Go API |
dev/prod/automoca/ai-service/* | AI service (GCP, Azure, API keys) |
CI/CD
| Repo | Trigger | Pipeline |
|---|---|---|
| automoca-api-services | Push to dev | GitHub Actions → ECR → ECS braindi-backend-dev |
| automoca-aiservice | Push to dev / main | GitHub Actions → ECR → ECS dev / update prod task def |
| automoca-web-app | Git push | Amplify auto-deploy |
| braindi-backoffice-frontend | Git push | Amplify auto-deploy |
Backend deploy role: arn:aws:iam::564141170168:role/braindi-backend-actions-runner
External Dependencies (outside this AWS account)
| Service | Purpose |
|---|---|
| Google Cloud Speech-to-Text | Speech recognition |
| Google Gemini / Azure OpenAI | AI scoring (via aiservice) |
CFC proxy (VITE_CFC_PROXY_ENDPOINT) | Backoffice file upload |
| Sentry | Frontend error tracking |