MGA Sample Template
The MGA (Managing General Agent) sample scaffolds a complete insurance platform with multiple interconnected services — an API backend, a web frontend, and a report generation worker.
What gets created
Running tawa sample --mga my-mga generates three service directories, each with its own catalog-info.yaml, package.json, and health endpoint:
| Directory | Type | Description |
|---|---|---|
my-mga-api/ | Express API | Backend service — policies, quotes, claims |
my-mga-web/ | Next.js app | Frontend — dashboard, policy list, quote wizard |
my-mga-reports/ | Worker service | Report generation — bordereaux, loss runs |
tawa sample --mga my-mga
# Output:
# my-mga-api/
# my-mga-web/
# my-mga-reports/Each directory is a standalone deployable service. They communicate via internal dependencies resolved by the builder at deploy time.
API service structure
The my-mga-api/ service is an Express API with TypeScript that provides the core insurance operations.
| Detail | Value |
|---|---|
| Framework | express |
| Routes | /api/policies, /api/quotes, /api/claims |
| Database | MongoDB (auto-provisioned) |
| Auth | OAuth via Bio-ID (auto-provisioned) |
| Health endpoint | /health |
catalog-info.yaml
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: my-mga-api
description: MGA insurance API
annotations:
insureco.io/framework: express
spec:
type: service
lifecycle: production
owner: my-org
routes:
- path: /api/policies
methods: [GET, POST, PUT]
auth: required
- path: /api/quotes
methods: [GET, POST]
auth: required
- path: /api/claims
methods: [GET, POST]
auth: required
databases:
- type: mongodbBIO_CLIENT_ID and BIO_CLIENT_SECRET on every deploy. You do not need to create OAuth clients manually.Web service structure
The my-mga-web/ service is a Next.js 14 application with App Router that provides the insurance platform UI.
| Detail | Value |
|---|---|
| Framework | nextjs |
| Auth | Bio-ID PKCE authentication |
| Pages | Dashboard, policy list, quote wizard |
| API communication | Calls my-mga-api via internal dependency |
| Health endpoint | /api/health |
catalog-info.yaml
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: my-mga-web
description: MGA insurance portal
annotations:
insureco.io/framework: nextjs
spec:
type: service
lifecycle: production
owner: my-org
internalDependencies:
- service: my-mga-api
port: 3000The builder resolves my-mga-api to a Kubernetes DNS URL and injects it as MY_MGA_API_URL in the web service's environment. Your frontend calls the API at process.env.MY_MGA_API_URL without hardcoding any URLs.
Reports worker structure
The my-mga-reports/ service is an Express worker that generates policy reports, bordereaux, and loss runs. It has no public routes and is not exposed via ingress.
| Detail | Value |
|---|---|
| Framework | worker |
| Public routes | None |
| Reports | Policy reports, bordereaux, loss runs |
| Database | MongoDB (for report data) |
| Health endpoint | None (worker type) |
catalog-info.yaml
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: my-mga-reports
description: MGA report generation worker
annotations:
insureco.io/framework: worker
spec:
type: service
lifecycle: production
owner: my-org
internalDependencies:
- service: my-mga-api
port: 3000
databases:
- type: mongodbworker framework type tells the builder to skip ingress creation and health check configuration. The pod runs a long-lived process started by node dist/worker.js.Multi-service setup
Each service declares its dependencies in catalog-info.yaml under spec.internalDependencies. During deploy, the builder resolves each dependency to a Kubernetes cluster DNS URL via Koko.
# In my-mga-web/catalog-info.yaml
spec:
internalDependencies:
- service: my-mga-api
port: 3000The builder resolves this to the full cluster DNS address:
http://my-mga-api.my-mga-api-prod.svc.cluster.local:3000This URL is injected as an environment variable named MY_MGA_API_URL (derived from the service name, uppercased with hyphens replaced by underscores). Your app reads it from process.env like any other env var.
Dependency graph
my-mga-web ──────> my-mga-api ──────> MongoDB
^
my-mga-reports ─────────┘ ──────────> MongoDBBoth the web frontend and the reports worker depend on the API service. The API service and the reports worker each have their own MongoDB database (auto-provisioned separately).
Deploying
Each service is deployed independently. Deploy the API service first because the web and reports services depend on it.
Deploy order
- API — deploy first (other services depend on it)
- Web — deploy after the API is running
- Reports — deploy last (depends on API)
Commands
# 1. Deploy the API service
cd my-mga-api
tawa preflight
tawa deploy
# 2. Deploy the web frontend
cd ../my-mga-web
tawa preflight
tawa deploy
# 3. Deploy the reports worker
cd ../my-mga-reports
tawa preflight
tawa deploytawa preflight before deploying. This validates the catalog-info.yaml, health endpoint, and git remote.Production deploys
Follow the same order with the --prod flag:
cd my-mga-api && tawa deploy --prod
cd ../my-mga-web && tawa deploy --prod
cd ../my-mga-reports && tawa deploy --prodAfter deploying, the services are available at:
| Service | Sandbox URL | Production URL |
|---|---|---|
| API | my-mga-api.sandbox.tawa.insureco.io | my-mga-api.tawa.insureco.io |
| Web | my-mga-web.sandbox.tawa.insureco.io | my-mga-web.tawa.insureco.io |
| Reports | No public URL (worker type) | |
Common customization
The MGA sample is a starting point. Here are common ways to extend it after scaffolding.
Add PlugINS integrations
The Tawa PlugINS store provides pre-built insurance integrations. Common additions for MGA platforms:
| PlugIN | Purpose |
|---|---|
| RaterSpot | Comparative rating engine for quote generation |
| PolicyPay | Premium payment processing and installment plans |
Add Redis for caching
If your quote flow involves expensive rate calculations, add Redis to the API service for caching:
# In my-mga-api/catalog-info.yaml
spec:
databases:
- type: mongodb
- type: redisThis injects REDIS_URL into the API pod on the next deploy. Use it to cache quote results, rate tables, or session data.
Connect to OFAC Check
For compliance screening on policy applicants, add an internal dependency to an OFAC screening service:
# In my-mga-api/catalog-info.yaml
spec:
internalDependencies:
- service: ofac-check
port: 3000The builder resolves this to the cluster DNS URL and injects it as OFAC_CHECK_URL in your pod environment.
Related
- catalog-info.yaml Reference — full field reference for all configuration options
- Databases — how database provisioning works
- OAuth Integration — Bio-ID auto-provisioning details
- Platform Architecture — how platform services connect
- Getting Started — deploy your first service