# thugney/vert architecture

> Architecture diagram of the GitHub repository thugney/vert, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thugney/vert
- Repository: https://github.com/thugney/vert

## Overview

Eriteach is a multi-tenant appointment and customer-service platform, with web and API booking alongside voice and SMS channels. The main workflow is a customer request entering through a channel, being scoped to a tenant, verified and checked against booking rules, then reserved through a booking engine. Businesses also configure and activate their service through onboarding and the portal; background workers handle push notifications and events. The README is empty, so capability coverage is based on the source tree and SOURCE INDEX; several subsystem links remain omitted where excerpts do not show the caller.

Main entry points: [`src/core/booking-service.ts`](https://github.com/thugney/vert/blob/main/src/core/booking-service.ts) (Booking service), [`src/api/app.ts`](https://github.com/thugney/vert/blob/main/src/api/app.ts) (HTTP API), [`src/push/worker.ts`](https://github.com/thugney/vert/blob/main/src/push/worker.ts) (Push worker), [`src/voice/webhook.ts`](https://github.com/thugney/vert/blob/main/src/voice/webhook.ts) (Voice tool webhook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_server["Server runtime<br/>[server.ts]"]
  node_api["HTTP API<br/>[app.ts]"]
  node_api_routes["API routes<br/>[api-routes.ts]"]
end

subgraph group_booking["Booking and tenants"]
  node_tenant_scope["Tenant scope<br/>[db-scope.ts]"]
  node_tenants["Tenant configuration<br/>[tenants.ts]"]
  node_booking_service["Booking service<br/>[booking-service.ts]"]
  node_booking_engine["Booking engine<br/>[engine.ts]"]
  node_closures["Availability rules<br/>[closures.ts]"]
  node_policy["Booking policy<br/>[policy.ts]"]
  node_countries["Country profiles<br/>[countries.ts]"]
  node_verification["Verification service<br/>[service.ts]"]
  node_phone_codes["Phone codes<br/>[phone-code.ts]"]
end

subgraph group_channels["Customer channels"]
  node_voice_webhook["Voice tool webhook<br/>[webhook.ts]"]
  node_sms_worker["SMS worker<br/>[sms-worker.ts]"]
  node_sms_inbound["SMS inbound<br/>[sms-inbound.ts]"]
end

subgraph group_business["Business operations"]
  node_registration["Registration<br/>[registration.ts]"]
  node_onboarding["Onboarding routes"]
  node_work["Work management<br/>[work.ts]"]
  node_alerts["Alerts<br/>[service.ts]"]
  node_events["Event delivery<br/>[service.ts]"]
  node_push_worker["Push worker<br/>[worker.ts]"]
  node_push_delivery["Push delivery<br/>[web-push.ts]"]
end

subgraph group_web["Web experience"]
  node_web_portal["Tenant web app<br/>[page.tsx]"]
  node_web_api["Web API client<br/>[api.ts]"]
  node_oidc["OIDC authentication<br/>[oidc.ts]"]
end

node_customer(("Customer"))
node_business_user(("Business user"))
node_database[("PostgreSQL")]
node_voice_platform(("Voice platform"))
node_sms_provider(("SMS provider"))

node_server -->|"builds"| node_api
node_server -->|"creates"| node_booking_engine
node_server -->|"runs rounds"| node_push_worker
node_api -->|"routes bookings"| node_booking_service
node_api -->|"registers inbound"| node_sms_inbound
node_api -->|"scopes requests"| node_tenant_scope
node_api_routes -.->|"serves API"| node_booking_service
node_booking_service -->|"reserves slots"| node_booking_engine
node_booking_service -->|"checks country rules"| node_countries
node_booking_service -->|"assesses verification"| node_verification
node_booking_service -.->|"uses code service"| node_phone_codes
node_tenants -->|"validates policy"| node_policy
node_voice_webhook -->|"sets scope"| node_tenant_scope
node_voice_webhook -->|"resolves called number"| node_tenants
node_voice_webhook -->|"handles booking tools"| node_booking_service
node_voice_platform -->|"calls tools"| node_voice_webhook
node_sms_worker -->|"scopes work"| node_tenant_scope
node_sms_worker -->|"uses tenant channel"| node_tenants
node_sms_provider -.->|"delivers messages"| node_sms_inbound
node_onboarding -->|"creates assisted tenants"| node_registration
node_push_worker -->|"scopes delivery"| node_tenant_scope
node_push_worker -->|"loads tenant"| node_tenants
node_push_worker -->|"sends notifications"| node_push_delivery
node_push_delivery -.->|"delivers subscriptions"| node_database
node_booking_service -.->|"persists bookings"| node_database
node_business_user -.->|"manages service"| node_web_portal
node_customer -.->|"requests booking"| node_web_portal
node_web_portal -.->|"calls API"| node_web_api
node_web_api -.->|"sends requests"| node_api
node_web_portal -.->|"authenticates"| node_oidc

click node_server "https://github.com/thugney/vert/blob/main/src/server.ts"
click node_api "https://github.com/thugney/vert/blob/main/src/api/app.ts"
click node_api_routes "https://github.com/thugney/vert/blob/main/src/api/api-routes.ts"
click node_tenant_scope "https://github.com/thugney/vert/blob/main/src/db-scope.ts"
click node_tenants "https://github.com/thugney/vert/blob/main/src/tenants.ts"
click node_booking_service "https://github.com/thugney/vert/blob/main/src/core/booking-service.ts"
click node_booking_engine "https://github.com/thugney/vert/blob/main/src/adapters/engine.ts"
click node_closures "https://github.com/thugney/vert/blob/main/src/core/closures.ts"
click node_policy "https://github.com/thugney/vert/blob/main/src/policy.ts"
click node_countries "https://github.com/thugney/vert/blob/main/src/countries.ts"
click node_verification "https://github.com/thugney/vert/blob/main/src/verification/service.ts"
click node_phone_codes "https://github.com/thugney/vert/blob/main/src/verification/phone-code.ts"
click node_voice_webhook "https://github.com/thugney/vert/blob/main/src/voice/webhook.ts"
click node_sms_worker "https://github.com/thugney/vert/blob/main/src/channels/sms-worker.ts"
click node_sms_inbound "https://github.com/thugney/vert/blob/main/src/sms-inbound.ts"
click node_registration "https://github.com/thugney/vert/blob/main/src/registration.ts"
click node_onboarding "https://github.com/thugney/vert/blob/main/src/api/onboarding-routes.ts"
click node_work "https://github.com/thugney/vert/blob/main/src/work.ts"
click node_alerts "https://github.com/thugney/vert/blob/main/src/alerts/service.ts"
click node_events "https://github.com/thugney/vert/blob/main/src/events/service.ts"
click node_push_worker "https://github.com/thugney/vert/blob/main/src/push/worker.ts"
click node_push_delivery "https://github.com/thugney/vert/blob/main/src/push/web-push.ts"
click node_web_portal "https://github.com/thugney/vert/blob/main/web/app/%5Btenant%5D/page.tsx"
click node_web_api "https://github.com/thugney/vert/blob/main/web/lib/api.ts"
click node_oidc "https://github.com/thugney/vert/blob/main/web/lib/oidc.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_api,node_api_routes,node_business_user toneBlue
class node_tenant_scope,node_tenants,node_booking_service,node_booking_engine,node_closures,node_policy,node_countries,node_verification,node_phone_codes,node_database toneAmber
class node_voice_webhook,node_sms_worker,node_sms_inbound toneMint
class node_registration,node_onboarding,node_work,node_alerts,node_events,node_push_worker,node_push_delivery toneRose
class node_web_portal,node_web_api,node_oidc,node_customer,node_voice_platform,node_sms_provider toneIndigo
```

## Components

### Application entry

- [Server runtime](https://github.com/thugney/vert/blob/main/src/server.ts): `src/server.ts`
- [HTTP API](https://github.com/thugney/vert/blob/main/src/api/app.ts): `src/api/app.ts`
- [API routes](https://github.com/thugney/vert/blob/main/src/api/api-routes.ts): `src/api/api-routes.ts`

### Booking and tenants

- [Tenant scope](https://github.com/thugney/vert/blob/main/src/db-scope.ts): `src/db-scope.ts`
- [Tenant configuration](https://github.com/thugney/vert/blob/main/src/tenants.ts): `src/tenants.ts`
- [Booking service](https://github.com/thugney/vert/blob/main/src/core/booking-service.ts): `src/core/booking-service.ts`
- [Booking engine](https://github.com/thugney/vert/blob/main/src/adapters/engine.ts): `src/adapters/engine.ts`
- [Availability rules](https://github.com/thugney/vert/blob/main/src/core/closures.ts): `src/core/closures.ts`
- [Booking policy](https://github.com/thugney/vert/blob/main/src/policy.ts): `src/policy.ts`
- [Country profiles](https://github.com/thugney/vert/blob/main/src/countries.ts): `src/countries.ts`
- [Verification service](https://github.com/thugney/vert/blob/main/src/verification/service.ts): `src/verification/service.ts`
- [Phone codes](https://github.com/thugney/vert/blob/main/src/verification/phone-code.ts): `src/verification/phone-code.ts`

### Customer channels

- [Voice tool webhook](https://github.com/thugney/vert/blob/main/src/voice/webhook.ts): `src/voice/webhook.ts`
- [SMS worker](https://github.com/thugney/vert/blob/main/src/channels/sms-worker.ts): `src/channels/sms-worker.ts`
- [SMS inbound](https://github.com/thugney/vert/blob/main/src/sms-inbound.ts): `src/sms-inbound.ts`

### Business operations

- [Registration](https://github.com/thugney/vert/blob/main/src/registration.ts): `src/registration.ts`
- [Onboarding routes](https://github.com/thugney/vert/blob/main/src/api/onboarding-routes.ts): `src/api/onboarding-routes.ts`
- [Work management](https://github.com/thugney/vert/blob/main/src/work.ts): `src/work.ts`
- [Alerts](https://github.com/thugney/vert/blob/main/src/alerts/service.ts): `src/alerts/service.ts`
- [Event delivery](https://github.com/thugney/vert/blob/main/src/events/service.ts): `src/events/service.ts`
- [Push worker](https://github.com/thugney/vert/blob/main/src/push/worker.ts): `src/push/worker.ts`
- [Push delivery](https://github.com/thugney/vert/blob/main/src/push/web-push.ts): `src/push/web-push.ts`

### Web experience

- [Tenant web app](https://github.com/thugney/vert/blob/main/web/app/%5Btenant%5D/page.tsx): `web/app/[tenant]/page.tsx`
- [Web API client](https://github.com/thugney/vert/blob/main/web/lib/api.ts): `web/lib/api.ts`
- [OIDC authentication](https://github.com/thugney/vert/blob/main/web/lib/oidc.ts): `web/lib/oidc.ts`

### Other components

- **Customer**
- **Business user**
- **PostgreSQL**
- **Voice platform**
- **SMS provider**

## Connections

- Server runtime → HTTP API: builds (evidence: `src/server.ts`)
- Server runtime → Booking engine: creates (evidence: `src/server.ts`)
- Server runtime → Push worker: runs rounds (evidence: `src/server.ts`)
- HTTP API → Booking service: routes bookings (evidence: `src/api/app.ts`)
- HTTP API → SMS inbound: registers inbound (evidence: `src/api/app.ts`)
- HTTP API → Tenant scope: scopes requests (evidence: `src/api/app.ts`)
- API routes → Booking service: serves API
- Booking service → Booking engine: reserves slots (evidence: `src/core/booking-service.ts`)
- Booking service → Country profiles: checks country rules (evidence: `src/core/booking-service.ts`)
- Booking service → Verification service: assesses verification (evidence: `src/core/booking-service.ts`)
- Booking service → Phone codes: uses code service (evidence: `src/core/booking-service.ts`)
- Tenant configuration → Booking policy: validates policy (evidence: `src/tenants.ts`)
- Voice tool webhook → Tenant scope: sets scope (evidence: `src/voice/webhook.ts`)
- Voice tool webhook → Tenant configuration: resolves called number (evidence: `src/voice/webhook.ts`)
- Voice tool webhook → Booking service: handles booking tools (evidence: `src/voice/webhook.ts`)
- Voice platform → Voice tool webhook: calls tools (evidence: `src/voice/webhook.ts`)
- SMS worker → Tenant scope: scopes work (evidence: `src/channels/sms-worker.ts`)
- SMS worker → Tenant configuration: uses tenant channel (evidence: `src/channels/sms-worker.ts`)
- SMS provider → SMS inbound: delivers messages
- Onboarding routes → Registration: creates assisted tenants (evidence: `src/api/onboarding-routes.ts`)
- Push worker → Tenant scope: scopes delivery (evidence: `src/push/worker.ts`)
- Push worker → Tenant configuration: loads tenant (evidence: `src/push/worker.ts`)
- Push worker → Push delivery: sends notifications (evidence: `src/push/worker.ts`)
- Push delivery → PostgreSQL: delivers subscriptions
- Booking service → PostgreSQL: persists bookings
- Business user → Tenant web app: manages service
- Customer → Tenant web app: requests booking
- Tenant web app → Web API client: calls API
- Web API client → HTTP API: sends requests
- Tenant web app → OIDC authentication: authenticates
