# aws-samples/connect-v2v-translation-with-cx-options architecture

> Architecture diagram of the GitHub repository aws-samples/connect-v2v-translation-with-cx-options, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-samples/connect-v2v-translation-with-cx-options
- Repository: https://github.com/aws-samples/connect-v2v-translation-with-cx-options

## Overview

This sample web app enables an agent to handle a Connect voice interaction while transcribing both sides, translating speech in either direction, and synthesizing translated audio. The browser app coordinates the workflow; audio/session managers handle media, and AWS adapters perform speech recognition, translation, and text-to-speech. CDK stacks provision Cognito and host/configure the frontend and optional service proxies. The README documents the Connect Streams/RTC integration and bidirectional workflow; some implementation details and the frontend-config custom resource were not sampled.

Main entry points: [`webapp/main.js`](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/main.js) (Interaction UI), [`cdk-stacks/lib/cdk-frontend-stack.ts`](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/cdk-frontend-stack.ts) (Frontend stack), [`webapp/adapters/transcribeAdapter.js`](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/adapters/transcribeAdapter.js) (Transcription adapter), [`webapp/utils/authUtility.js`](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/utils/authUtility.js) (Auth and credentials)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Agent web app"]
  node_main["Interaction UI<br/>[main.js]"]
  node_common["Web utilities<br/>[commonUtility.js]"]
end

subgraph group_voice["Voice processing"]
  node_audioctx["Audio context"]
  node_audiostream["Audio stream"]
  node_session["Session tracks"]
  node_inputtest["Microphone test"]
  node_micstream["Microphone stream<br/>[transcribeUtils.js]"]
  node_transcribe["Transcription adapter"]
  node_translate["Translation adapter"]
  node_polly["Speech synthesis adapter<br/>[pollyAdapter.js]"]
end

subgraph group_cloud["Cloud deployment"]
  node_backend["Backend stack"]
  node_frontend["Frontend stack"]
  node_deployment["S3 deployment"]
  node_frontendconfig["Frontend config"]
  node_bucket[("Frontend bucket")]
  node_cloudfront["CloudFront"]
end

subgraph group_identity["Identity and config"]
  node_config["Runtime config<br/>[config.js]"]
  node_auth["Auth and credentials<br/>[authUtility.js]"]
  node_cognito["Cognito resources<br/>[cognito-stack.ts]"]
  node_ssm["SSM parameters<br/>[ssm-params-util.ts]"]
end

node_agent(("Agent"))
node_connect["Amazon Connect"]
node_streamsrtc["Streams and RTC"]
node_transcribesvc["Amazon Transcribe"]
node_translatesvc["Amazon Translate"]
node_pollysvc["Amazon Polly"]

node_agent -->|"configures"| node_main
node_main -->|"manages tracks"| node_session
node_main -->|"creates context"| node_audioctx
node_main -.->|"manages playback"| node_audiostream
node_main -->|"tests input"| node_inputtest
node_main -->|"captures audio"| node_micstream
node_main -->|"starts transcription"| node_transcribe
node_main -->|"translates text"| node_translate
node_main -->|"synthesizes speech"| node_polly
node_main -->|"uses utilities"| node_common
node_main -->|"reads settings"| node_config
node_session -->|"validates inputs"| node_common
node_audiostream -->|"validates inputs"| node_common
node_transcribe -->|"gets credentials"| node_auth
node_translate -->|"gets credentials"| node_auth
node_polly -->|"gets credentials"| node_auth
node_transcribe -->|"formats audio"| node_micstream
node_transcribe -->|"streams audio"| node_transcribesvc
node_translate -->|"translates text"| node_translatesvc
node_polly -->|"synthesizes audio"| node_pollysvc
node_streamsrtc -->|"provides media"| node_connect
node_backend -->|"loads settings"| node_ssm
node_backend -->|"creates identity"| node_cognito
node_frontend -->|"loads settings"| node_ssm
node_frontend -->|"deploys assets"| node_deployment
node_frontend -->|"creates config"| node_frontendconfig
node_frontend -->|"creates bucket"| node_bucket
node_frontend -->|"configures distribution"| node_cloudfront
node_deployment -->|"deploys web app"| node_bucket
node_frontendconfig -.->|"writes config"| node_bucket
node_cloudfront -->|"proxies requests"| node_pollysvc
node_cloudfront -->|"proxies requests"| node_translatesvc
node_auth -->|"authenticates"| node_cognito

click node_main "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/main.js"
click node_config "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/config.js"
click node_common "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/utils/commonUtility.js"
click node_auth "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/utils/authUtility.js"
click node_audioctx "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/managers/AudioContextManager.js"
click node_audiostream "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/managers/AudioStreamManager.js"
click node_session "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/managers/SessionTrackManager.js"
click node_inputtest "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/managers/InputTestManager.js"
click node_micstream "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/utils/transcribeUtils.js"
click node_transcribe "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/adapters/transcribeAdapter.js"
click node_translate "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/adapters/translateAdapter.js"
click node_polly "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/adapters/pollyAdapter.js"
click node_backend "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/cdk-backend-stack.ts"
click node_cognito "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/infrastructure/cognito-stack.ts"
click node_frontend "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/cdk-frontend-stack.ts"
click node_deployment "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/frontend/frontend-s3-deployment-stack.ts"
click node_frontendconfig "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/frontend/frontend-config-stack.ts"
click node_ssm "https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/config/ssm-params-util.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_main,node_common toneBlue
class node_audioctx,node_audiostream,node_session,node_inputtest,node_micstream,node_transcribe,node_translate,node_polly toneAmber
class node_backend,node_frontend,node_deployment,node_frontendconfig,node_bucket,node_cloudfront toneMint
class node_config,node_auth,node_cognito,node_ssm toneRose
class node_agent,node_connect,node_streamsrtc,node_transcribesvc,node_translatesvc,node_pollysvc toneIndigo
```

## Components

### Agent web app

- [Interaction UI](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/main.js): `webapp/main.js`
- [Web utilities](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/utils/commonUtility.js): `webapp/utils/commonUtility.js`

### Voice processing

- [Audio context](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/managers/AudioContextManager.js): `webapp/managers/AudioContextManager.js`
- [Audio stream](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/managers/AudioStreamManager.js): `webapp/managers/AudioStreamManager.js`
- [Session tracks](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/managers/SessionTrackManager.js): `webapp/managers/SessionTrackManager.js`
- [Microphone test](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/managers/InputTestManager.js): `webapp/managers/InputTestManager.js`
- [Microphone stream](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/utils/transcribeUtils.js): `webapp/utils/transcribeUtils.js`
- [Transcription adapter](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/adapters/transcribeAdapter.js): `webapp/adapters/transcribeAdapter.js`
- [Translation adapter](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/adapters/translateAdapter.js): `webapp/adapters/translateAdapter.js`
- [Speech synthesis adapter](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/adapters/pollyAdapter.js): `webapp/adapters/pollyAdapter.js`

### Cloud deployment

- [Backend stack](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/cdk-backend-stack.ts): `cdk-stacks/lib/cdk-backend-stack.ts`
- [Frontend stack](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/cdk-frontend-stack.ts): `cdk-stacks/lib/cdk-frontend-stack.ts`
- [S3 deployment](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/frontend/frontend-s3-deployment-stack.ts): `cdk-stacks/lib/frontend/frontend-s3-deployment-stack.ts`
- [Frontend config](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/frontend/frontend-config-stack.ts): `cdk-stacks/lib/frontend/frontend-config-stack.ts`
- **Frontend bucket**
- **CloudFront**

### Identity and config

- [Runtime config](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/config.js): `webapp/config.js`
- [Auth and credentials](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/webapp/utils/authUtility.js): `webapp/utils/authUtility.js`
- [Cognito resources](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/lib/infrastructure/cognito-stack.ts): `cdk-stacks/lib/infrastructure/cognito-stack.ts`
- [SSM parameters](https://github.com/aws-samples/connect-v2v-translation-with-cx-options/blob/main/cdk-stacks/config/ssm-params-util.ts): `cdk-stacks/config/ssm-params-util.ts`

### Other components

- **Agent**
- **Amazon Connect**
- **Streams and RTC**
- **Amazon Transcribe**
- **Amazon Translate**
- **Amazon Polly**

## Connections

- Agent → Interaction UI: configures (evidence: `README.md`)
- Interaction UI → Session tracks: manages tracks (evidence: `webapp/main.js`)
- Interaction UI → Audio context: creates context (evidence: `webapp/main.js`)
- Interaction UI → Audio stream: manages playback (evidence: `webapp/main.js`)
- Interaction UI → Microphone test: tests input (evidence: `webapp/main.js`)
- Interaction UI → Microphone stream: captures audio (evidence: `webapp/main.js`)
- Interaction UI → Transcription adapter: starts transcription (evidence: `webapp/main.js`)
- Interaction UI → Translation adapter: translates text (evidence: `webapp/main.js`)
- Interaction UI → Speech synthesis adapter: synthesizes speech (evidence: `webapp/main.js`)
- Interaction UI → Web utilities: uses utilities (evidence: `webapp/main.js`)
- Interaction UI → Runtime config: reads settings (evidence: `webapp/main.js`)
- Session tracks → Web utilities: validates inputs (evidence: `webapp/managers/SessionTrackManager.js`)
- Audio stream → Web utilities: validates inputs (evidence: `webapp/managers/AudioStreamManager.js`)
- Transcription adapter → Auth and credentials: gets credentials (evidence: `webapp/adapters/transcribeAdapter.js`)
- Translation adapter → Auth and credentials: gets credentials (evidence: `webapp/adapters/translateAdapter.js`)
- Speech synthesis adapter → Auth and credentials: gets credentials (evidence: `webapp/adapters/pollyAdapter.js`)
- Transcription adapter → Microphone stream: formats audio (evidence: `webapp/adapters/transcribeAdapter.js`)
- Transcription adapter → Amazon Transcribe: streams audio (evidence: `webapp/adapters/transcribeAdapter.js`)
- Translation adapter → Amazon Translate: translates text (evidence: `README.md`)
- Speech synthesis adapter → Amazon Polly: synthesizes audio (evidence: `webapp/adapters/pollyAdapter.js`)
- Streams and RTC → Amazon Connect: provides media (evidence: `README.md`)
- Backend stack → SSM parameters: loads settings (evidence: `cdk-stacks/lib/cdk-backend-stack.ts`)
- Backend stack → Cognito resources: creates identity (evidence: `cdk-stacks/lib/cdk-backend-stack.ts`)
- Frontend stack → SSM parameters: loads settings (evidence: `cdk-stacks/lib/cdk-frontend-stack.ts`)
- Frontend stack → S3 deployment: deploys assets (evidence: `cdk-stacks/lib/cdk-frontend-stack.ts`)
- Frontend stack → Frontend config: creates config (evidence: `cdk-stacks/lib/cdk-frontend-stack.ts`)
- Frontend stack → Frontend bucket: creates bucket (evidence: `cdk-stacks/lib/cdk-frontend-stack.ts`)
- Frontend stack → CloudFront: configures distribution (evidence: `cdk-stacks/lib/cdk-frontend-stack.ts`)
- S3 deployment → Frontend bucket: deploys web app
- Frontend config → Frontend bucket: writes config
- CloudFront → Amazon Polly: proxies requests
- CloudFront → Amazon Translate: proxies requests
- Auth and credentials → Cognito resources: authenticates (evidence: `README.md`)
