# yandex/odyssey architecture

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

- Interactive diagram: https://gitdiagram.com/yandex/odyssey
- Repository: https://github.com/yandex/odyssey

## Overview

Odyssey is a multithreaded PostgreSQL connection pooler and request router. Its principal workflow accepts client connections, authenticates them, proxies requests to PostgreSQL through shared pools, and returns backend connections for reuse; transaction tracking supports cancellation and rollback after unexpected disconnects. The README documents these runtime capabilities, while sampled source also confirms an audit callback module and a Prometheus exporter. Most core routing, authentication, and worker implementations were not excerpted, so their detailed call relationships are not asserted.

Main entry points: [`sources/common/wchar.c`](https://github.com/yandex/odyssey/blob/master/sources/common/wchar.c) (Multibyte support), [`sources/worker.c`](https://github.com/yandex/odyssey/blob/master/sources/worker.c) (Worker processing), [`sources/shared_pool.c`](https://github.com/yandex/odyssey/blob/master/sources/shared_pool.c) (Shared connection pools), [`sources/reset.c`](https://github.com/yandex/odyssey/blob/master/sources/reset.c) (Transaction recovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Connection runtime"]
  node_entry["Client frontend<br/>[frontend.c]"]
  node_workers["Worker processing<br/>[worker.c]"]
  node_routing["Request routing<br/>[router.c]"]
  node_pools[("Shared connection pools<br/>[shared_pool.c]")]
  node_transaction["Transaction recovery<br/>[reset.c]"]
  node_configuration["Pool configuration<br/>[model.c]"]
  node_query["Query handling<br/>[query.c]"]
  node_sql_parser["SQL parsing<br/>[parser.c]"]
end

subgraph group_security["Authentication and security"]
  node_auth["Client authentication<br/>[auth.c]"]
  node_auth_methods["Auth integrations<br/>[external_auth.c]"]
  node_tls["TLS support<br/>[tls.c]"]
end

subgraph group_operations["Operations and integrations"]
  node_audit["Audit callbacks<br/>[audit_module.c]"]
  node_metrics["Prometheus exporter<br/>[exporter.go]"]
  node_module_api["Module API<br/>[module.h]"]
  node_audit_api["Audit module declarations<br/>[audit_module.h]"]
end

subgraph group_text["Text processing"]
  node_saslprep["SASLprep<br/>[saslprep.c]"]
  node_unicode["Multibyte support<br/>[wchar.c]"]
  node_unicode_tables["Unicode tables"]
  node_unicode_width["Unicode width table"]
  node_encoding_defs["Encoding definitions<br/>[pg_wchar.h]"]
  node_common_defs["Common C definitions<br/>[od_c.h]"]
  node_compat_defs["PostgreSQL compatibility<br/>[pg_compat.h]"]
  node_ascii["ASCII utilities<br/>[ascii.h]"]
  node_simd["SIMD primitives<br/>[simd.h]"]
end

node_clients(("PostgreSQL clients"))
node_backend[("PostgreSQL servers")]
node_metrics_endpoint(("Prometheus"))

node_clients -->|"connects"| node_entry
node_workers -->|"authenticates"| node_auth
node_workers -->|"proxies requests"| node_routing
node_routing -->|"forwards requests"| node_backend
node_workers -->|"shares pools"| node_pools
node_transaction -->|"returns connection"| node_pools
node_transaction -->|"cancels or rolls back"| node_backend
node_configuration -.->|"configures pools"| node_pools
node_auth -.->|"delegates authentication"| node_auth_methods
node_entry -.->|"secures connection"| node_tls
node_metrics -->|"queries Odyssey"| node_backend
node_metrics -->|"serves metrics"| node_metrics_endpoint
node_query -.->|"parses SQL"| node_sql_parser
node_audit_api -->|"includes API"| node_module_api
node_audit -->|"implements callbacks"| node_audit_api
node_saslprep -.->|"normalizes text"| node_unicode
node_unicode -.->|"uses character ranges"| node_unicode_tables
node_unicode -.->|"uses width ranges"| node_unicode_width
node_unicode -->|"uses encoding definitions"| node_encoding_defs
node_unicode -->|"uses definitions"| node_common_defs
node_unicode -->|"uses compatibility definitions"| node_compat_defs
node_ascii -->|"uses primitives"| node_simd

click node_entry "https://github.com/yandex/odyssey/blob/master/sources/frontend.c"
click node_workers "https://github.com/yandex/odyssey/blob/master/sources/worker.c"
click node_routing "https://github.com/yandex/odyssey/blob/master/sources/router.c"
click node_pools "https://github.com/yandex/odyssey/blob/master/sources/shared_pool.c"
click node_transaction "https://github.com/yandex/odyssey/blob/master/sources/reset.c"
click node_configuration "https://github.com/yandex/odyssey/blob/master/sources/cfg/model.c"
click node_auth "https://github.com/yandex/odyssey/blob/master/sources/auth.c"
click node_auth_methods "https://github.com/yandex/odyssey/blob/master/sources/external_auth.c"
click node_tls "https://github.com/yandex/odyssey/blob/master/sources/tls.c"
click node_audit "https://github.com/yandex/odyssey/blob/master/modules/audit_module.c"
click node_metrics "https://github.com/yandex/odyssey/blob/master/prometheus/exporter/exporter.go"
click node_query "https://github.com/yandex/odyssey/blob/master/sources/query.c"
click node_sql_parser "https://github.com/yandex/odyssey/blob/master/sources/sql/full/parser.c"
click node_saslprep "https://github.com/yandex/odyssey/blob/master/sources/common/saslprep.c"
click node_unicode "https://github.com/yandex/odyssey/blob/master/sources/common/wchar.c"
click node_unicode_tables "https://github.com/yandex/odyssey/blob/master/sources/include/common/unicode_nonspacing_table.h"
click node_unicode_width "https://github.com/yandex/odyssey/blob/master/sources/include/common/unicode_east_asian_fw_table.h"
click node_encoding_defs "https://github.com/yandex/odyssey/blob/master/sources/include/mb/pg_wchar.h"
click node_common_defs "https://github.com/yandex/odyssey/blob/master/sources/include/od_c.h"
click node_compat_defs "https://github.com/yandex/odyssey/blob/master/sources/include/pg_compat.h"
click node_ascii "https://github.com/yandex/odyssey/blob/master/sources/include/utils/ascii.h"
click node_simd "https://github.com/yandex/odyssey/blob/master/sources/include/port/simd.h"
click node_module_api "https://github.com/yandex/odyssey/blob/master/sources/include/module.h"
click node_audit_api "https://github.com/yandex/odyssey/blob/master/modules/audit_module.h"

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_entry,node_workers,node_routing,node_pools,node_transaction,node_configuration,node_query,node_sql_parser toneBlue
class node_auth,node_auth_methods,node_tls,node_clients,node_backend toneAmber
class node_audit,node_metrics,node_module_api,node_audit_api toneMint
class node_saslprep,node_unicode,node_unicode_tables,node_unicode_width,node_encoding_defs,node_common_defs,node_compat_defs,node_ascii,node_simd toneRose
class node_metrics_endpoint toneIndigo
```

## Components

### Connection runtime

- [Client frontend](https://github.com/yandex/odyssey/blob/master/sources/frontend.c): `sources/frontend.c`
- [Worker processing](https://github.com/yandex/odyssey/blob/master/sources/worker.c): `sources/worker.c`
- [Request routing](https://github.com/yandex/odyssey/blob/master/sources/router.c): `sources/router.c`
- [Shared connection pools](https://github.com/yandex/odyssey/blob/master/sources/shared_pool.c): `sources/shared_pool.c`
- [Transaction recovery](https://github.com/yandex/odyssey/blob/master/sources/reset.c): `sources/reset.c`
- [Pool configuration](https://github.com/yandex/odyssey/blob/master/sources/cfg/model.c): `sources/cfg/model.c`
- [Query handling](https://github.com/yandex/odyssey/blob/master/sources/query.c): `sources/query.c`
- [SQL parsing](https://github.com/yandex/odyssey/blob/master/sources/sql/full/parser.c): `sources/sql/full/parser.c`

### Authentication and security

- [Client authentication](https://github.com/yandex/odyssey/blob/master/sources/auth.c): `sources/auth.c`
- [Auth integrations](https://github.com/yandex/odyssey/blob/master/sources/external_auth.c): `sources/external_auth.c`
- [TLS support](https://github.com/yandex/odyssey/blob/master/sources/tls.c): `sources/tls.c`

### Operations and integrations

- [Audit callbacks](https://github.com/yandex/odyssey/blob/master/modules/audit_module.c): `modules/audit_module.c`
- [Prometheus exporter](https://github.com/yandex/odyssey/blob/master/prometheus/exporter/exporter.go): `prometheus/exporter/exporter.go`
- [Module API](https://github.com/yandex/odyssey/blob/master/sources/include/module.h): `sources/include/module.h`
- [Audit module declarations](https://github.com/yandex/odyssey/blob/master/modules/audit_module.h): `modules/audit_module.h`

### Text processing

- [SASLprep](https://github.com/yandex/odyssey/blob/master/sources/common/saslprep.c): `sources/common/saslprep.c`
- [Multibyte support](https://github.com/yandex/odyssey/blob/master/sources/common/wchar.c): `sources/common/wchar.c`
- [Unicode tables](https://github.com/yandex/odyssey/blob/master/sources/include/common/unicode_nonspacing_table.h): `sources/include/common/unicode_nonspacing_table.h`
- [Unicode width table](https://github.com/yandex/odyssey/blob/master/sources/include/common/unicode_east_asian_fw_table.h): `sources/include/common/unicode_east_asian_fw_table.h`
- [Encoding definitions](https://github.com/yandex/odyssey/blob/master/sources/include/mb/pg_wchar.h): `sources/include/mb/pg_wchar.h`
- [Common C definitions](https://github.com/yandex/odyssey/blob/master/sources/include/od_c.h): `sources/include/od_c.h`
- [PostgreSQL compatibility](https://github.com/yandex/odyssey/blob/master/sources/include/pg_compat.h): `sources/include/pg_compat.h`
- [ASCII utilities](https://github.com/yandex/odyssey/blob/master/sources/include/utils/ascii.h): `sources/include/utils/ascii.h`
- [SIMD primitives](https://github.com/yandex/odyssey/blob/master/sources/include/port/simd.h): `sources/include/port/simd.h`

### Other components

- **PostgreSQL clients**
- **PostgreSQL servers**
- **Prometheus**

## Connections

- PostgreSQL clients → Client frontend: connects (evidence: `README.md`)
- Worker processing → Client authentication: authenticates (evidence: `README.md`)
- Worker processing → Request routing: proxies requests (evidence: `README.md`)
- Request routing → PostgreSQL servers: forwards requests (evidence: `README.md`)
- Worker processing → Shared connection pools: shares pools (evidence: `README.md`)
- Transaction recovery → Shared connection pools: returns connection (evidence: `README.md`)
- Transaction recovery → PostgreSQL servers: cancels or rolls back (evidence: `README.md`)
- Pool configuration → Shared connection pools: configures pools
- Client authentication → Auth integrations: delegates authentication
- Client frontend → TLS support: secures connection
- Prometheus exporter → PostgreSQL servers: queries Odyssey (evidence: `prometheus/exporter/exporter.go`)
- Prometheus exporter → Prometheus: serves metrics (evidence: `prometheus/exporter/exporter.go`)
- Query handling → SQL parsing: parses SQL
- Audit module declarations → Module API: includes API (evidence: `modules/audit_module.h`)
- Audit callbacks → Audit module declarations: implements callbacks (evidence: `modules/audit_module.c`)
- SASLprep → Multibyte support: normalizes text
- Multibyte support → Unicode tables: uses character ranges (evidence: `sources/common/wchar.c`)
- Multibyte support → Unicode width table: uses width ranges (evidence: `sources/common/wchar.c`)
- Multibyte support → Encoding definitions: uses encoding definitions (evidence: `sources/common/wchar.c`)
- Multibyte support → Common C definitions: uses definitions (evidence: `sources/common/wchar.c`)
- Multibyte support → PostgreSQL compatibility: uses compatibility definitions (evidence: `sources/common/wchar.c`)
- ASCII utilities → SIMD primitives: uses primitives (evidence: `sources/include/utils/ascii.h`)
