# googlecloudplatform/ces-genesys-chat architecture

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

- Interactive diagram: https://gitdiagram.com/googlecloudplatform/ces-genesys-chat
- Repository: https://github.com/googlecloudplatform/ces-genesys-chat

## Overview

Genesys Chat Adapter for CXAS is a FastAPI middleware that accepts Genesys Bot Connector turns, authenticates and routes them to a CXAS deployment, then translates CXAS responses into Genesys messages and intents. Its principal workflow includes session and turn tracking, including intent rotation for loop prevention, and supports Firestore-backed or in-memory session state. Configuration resolves API keys and runtime settings; structured logging adds request correlation. Source excerpts are partial, so the graph includes README-documented capabilities where implementation details were not sampled.

Main entry points: [`src/main.py`](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py) (Utterance endpoint), [`src/config.py`](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/config.py) (Runtime configuration), [`src/logging_utils.py`](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/logging_utils.py) (Structured request logging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Genesys ingress"]
  node_endpoint["Utterance endpoint<br/>[main.py]"]
  node_auth["API key authentication<br/>[main.py]"]
end

subgraph group_adapter["Turn adapter"]
  node_routing["Deployment routing<br/>[main.py]"]
  node_translation["Request translation<br/>[main.py]"]
  node_response["Response translation<br/>[main.py]"]
  node_intent["Intent rotation<br/>[main.py]"]
end

subgraph group_state["Session state"]
  node_session["Session and turn tracking<br/>[main.py]"]
  node_memory[("In-memory session cache<br/>[main.py]")]
  node_firestore[("Firestore sessions")]
end

subgraph group_operations["Configuration and observability"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_logging["Structured request logging<br/>[logging_utils.py]"]
end

node_genesys(("Genesys Bot Connector"))
node_secretmanager["Secret Manager"]
node_ces["CXAS CES API"]

node_genesys -->|"posts turn"| node_endpoint
node_endpoint -->|"checks key"| node_auth
node_auth -.->|"uses keys"| node_config
node_config -->|"resolves secrets"| node_secretmanager
node_endpoint -.->|"routes turn"| node_routing
node_routing -.->|"loads mapping"| node_session
node_routing -.->|"provides deployment"| node_translation
node_translation -->|"posts utterance"| node_ces
node_ces -->|"returns result"| node_response
node_response -->|"selects intent"| node_intent
node_response -->|"returns reply"| node_genesys
node_session -->|"reads and writes"| node_memory
node_session -->|"reads and writes"| node_firestore
node_endpoint -->|"binds request context"| node_logging
node_endpoint -.->|"uses settings"| node_config

click node_endpoint "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py"
click node_auth "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py"
click node_config "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/config.py"
click node_routing "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py"
click node_translation "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py"
click node_response "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py"
click node_intent "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py"
click node_session "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py"
click node_memory "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py"
click node_logging "https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/logging_utils.py"

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_endpoint,node_auth toneBlue
class node_routing,node_translation,node_response,node_intent toneAmber
class node_session,node_memory,node_firestore,node_ces toneMint
class node_config,node_logging toneRose
class node_genesys,node_secretmanager toneIndigo
```

## Components

### Genesys ingress

- [Utterance endpoint](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py): `src/main.py`
- [API key authentication](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py): `src/main.py`

### Turn adapter

- [Deployment routing](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py): `src/main.py`
- [Request translation](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py): `src/main.py`
- [Response translation](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py): `src/main.py`
- [Intent rotation](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py): `src/main.py`

### Session state

- [Session and turn tracking](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py): `src/main.py`
- [In-memory session cache](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/main.py): `src/main.py`
- **Firestore sessions**

### Configuration and observability

- [Runtime configuration](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/config.py): `src/config.py`
- [Structured request logging](https://github.com/googlecloudplatform/ces-genesys-chat/blob/main/src/logging_utils.py): `src/logging_utils.py`

### Other components

- **Genesys Bot Connector**
- **Secret Manager**
- **CXAS CES API**

## Connections

- Genesys Bot Connector → Utterance endpoint: posts turn (evidence: `README.md`)
- Utterance endpoint → API key authentication: checks key (evidence: `README.md`)
- API key authentication → Runtime configuration: uses keys (evidence: `src/main.py`)
- Runtime configuration → Secret Manager: resolves secrets (evidence: `src/config.py`)
- Utterance endpoint → Deployment routing: routes turn (evidence: `src/main.py`)
- Deployment routing → Session and turn tracking: loads mapping (evidence: `src/main.py`)
- Deployment routing → Request translation: provides deployment (evidence: `src/main.py`)
- Request translation → CXAS CES API: posts utterance (evidence: `README.md`)
- CXAS CES API → Response translation: returns result (evidence: `README.md`)
- Response translation → Intent rotation: selects intent (evidence: `README.md`)
- Response translation → Genesys Bot Connector: returns reply (evidence: `README.md`)
- Session and turn tracking → In-memory session cache: reads and writes (evidence: `src/main.py`)
- Session and turn tracking → Firestore sessions: reads and writes (evidence: `README.md`)
- Utterance endpoint → Structured request logging: binds request context (evidence: `src/main.py`)
- Utterance endpoint → Runtime configuration: uses settings (evidence: `src/main.py`)
