# aws-samples/amazon-connect-chat-translate architecture

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

- Interactive diagram: https://gitdiagram.com/aws-samples/amazon-connect-chat-translate
- Repository: https://github.com/aws-samples/amazon-connect-chat-translate

## Overview

This is a React agent-side application for Amazon Connect chat, translating customer messages into English and agent replies into each customer’s language. The main flow is authenticated startup, Connect contact events, per-contact language selection or first-message detection, translation, chat display, and sending the translated reply through the contact session. README also documents concurrent chats and custom terminology support. The sampled files show the UI and Amplify client calls; backend translation wiring is documented by the project setup but its handler source was not excerpted here.

Main entry points: [`src/components/ccp.js`](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/ccp.js) (Connect controller), [`src/components/chatroom.js`](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/chatroom.js) (Chat workspace), [`src/App.js`](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/App.js) (Authenticated app), [`src/store/state.js`](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/store/state.js) (Chat state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Agent application"]
  node_startup["Authenticated app<br/>[App.js]"]
  node_connect["Connect controller<br/>[ccp.js]"]
end

subgraph group_language["Language processing"]
  node_detect["Language detection<br/>[detectText.js]"]
  node_translate["Client translation<br/>[translate.js]"]
  node_api_client["Translation API client<br/>[translateAPI.js]"]
end

subgraph group_chat["Chat interaction"]
  node_chatroom["Chat workspace<br/>[chatroom.js]"]
  node_message["Message view<br/>[message.js]"]
  node_state["Chat state<br/>[state.js]"]
end

subgraph group_cloud["Amplify services"]
  node_amplify_api["Translation API"]
  node_lambda["Translation handler<br/>[index.js]"]
  node_translate_service["Amazon Translate"]
  node_comprehend["Amazon Comprehend"]
  node_custom_term["Custom terminology setup<br/>[index.js]"]
end

node_agent(("Agent"))
node_connect_service["Amazon Connect"]

node_agent -->|"signs in"| node_startup
node_startup -->|"renders"| node_connect
node_connect -->|"embeds CCP"| node_connect_service
node_connect -->|"renders workspace"| node_chatroom
node_connect -->|"updates"| node_state
node_connect -->|"detects language"| node_detect
node_connect -->|"translates customer"| node_translate
node_connect -->|"stores translated chat"| node_state
node_chatroom -->|"reads and updates"| node_state
node_chatroom -->|"renders messages"| node_message
node_agent -->|"writes reply"| node_chatroom
node_chatroom -->|"requests translation"| node_api_client
node_chatroom -->|"sends translated reply"| node_connect_service
node_api_client -->|"posts translation"| node_amplify_api
node_amplify_api -.->|"routes request"| node_lambda
node_lambda -.->|"translates text"| node_translate_service
node_detect -.->|"detects language"| node_comprehend
node_translate -.->|"uses Predictions"| node_translate_service
node_custom_term -->|"registers terminology"| node_translate_service
node_startup -->|"configures Amplify"| node_connect

click node_startup "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/App.js"
click node_connect "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/ccp.js"
click node_chatroom "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/chatroom.js"
click node_message "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/message.js"
click node_state "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/store/state.js"
click node_detect "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/detectText.js"
click node_translate "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/translate.js"
click node_api_client "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/translateAPI.js"
click node_amplify_api "https://github.com/aws-samples/amazon-connect-chat-translate/tree/main/amplify/backend/api/amazonTranslateAPI"
click node_lambda "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/amplify/backend/function/amazonTranslateLambda/src/index.js"
click node_custom_term "https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/amplify/backend/function/postInstallScript/src/index.js"

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_startup,node_connect toneBlue
class node_detect,node_translate,node_api_client toneAmber
class node_chatroom,node_message,node_state toneMint
class node_amplify_api,node_lambda,node_translate_service,node_comprehend,node_custom_term toneRose
class node_agent,node_connect_service toneIndigo
```

## Components

### Agent application

- [Authenticated app](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/App.js): `src/App.js`
- [Connect controller](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/ccp.js): `src/components/ccp.js`

### Language processing

- [Language detection](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/detectText.js): `src/components/detectText.js`
- [Client translation](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/translate.js): `src/components/translate.js`
- [Translation API client](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/translateAPI.js): `src/components/translateAPI.js`

### Chat interaction

- [Chat workspace](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/chatroom.js): `src/components/chatroom.js`
- [Message view](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/components/message.js): `src/components/message.js`
- [Chat state](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/src/store/state.js): `src/store/state.js`

### Amplify services

- [Translation API](https://github.com/aws-samples/amazon-connect-chat-translate/tree/main/amplify/backend/api/amazonTranslateAPI): `amplify/backend/api/amazonTranslateAPI`
- [Translation handler](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/amplify/backend/function/amazonTranslateLambda/src/index.js): `amplify/backend/function/amazonTranslateLambda/src/index.js`
- **Amazon Translate**
- **Amazon Comprehend**
- [Custom terminology setup](https://github.com/aws-samples/amazon-connect-chat-translate/blob/main/amplify/backend/function/postInstallScript/src/index.js): `amplify/backend/function/postInstallScript/src/index.js`

### Other components

- **Agent**
- **Amazon Connect**

## Connections

- Agent → Authenticated app: signs in (evidence: `src/App.js`)
- Authenticated app → Connect controller: renders (evidence: `src/App.js`)
- Connect controller → Amazon Connect: embeds CCP (evidence: `src/components/ccp.js`)
- Connect controller → Chat workspace: renders workspace (evidence: `src/components/ccp.js`)
- Connect controller → Chat state: updates (evidence: `src/components/ccp.js`)
- Connect controller → Language detection: detects language (evidence: `src/components/ccp.js`)
- Connect controller → Client translation: translates customer (evidence: `src/components/ccp.js`)
- Connect controller → Chat state: stores translated chat (evidence: `src/components/ccp.js`)
- Chat workspace → Chat state: reads and updates (evidence: `src/components/chatroom.js`)
- Chat workspace → Message view: renders messages (evidence: `src/components/chatroom.js`)
- Agent → Chat workspace: writes reply (evidence: `src/components/chatroom.js`)
- Chat workspace → Translation API client: requests translation (evidence: `src/components/chatroom.js`)
- Chat workspace → Amazon Connect: sends translated reply (evidence: `src/components/chatroom.js`)
- Translation API client → Translation API: posts translation (evidence: `src/components/translateAPI.js`)
- Translation API → Translation handler: routes request
- Translation handler → Amazon Translate: translates text
- Language detection → Amazon Comprehend: detects language
- Client translation → Amazon Translate: uses Predictions
- Custom terminology setup → Amazon Translate: registers terminology (evidence: `amplify/backend/function/postInstallScript/src/index.js`)
- Authenticated app → Connect controller: configures Amplify (evidence: `src/App.js`)
