Athena RS
Lightweight gateway crate that proxies Athena/Supabase/Scylla traffic and routes SQL queries through SQLx-managed PostgreSQL pools while normalizing cacheable JSON payloads.
Highlights
- Gateway endpoints:
/gateway/data,/gateway/fetch,/gateway/update, and/gateway/queryaccept structured fetch payloads, enforce theX-Athena-Clientheader, and optionally normalize camelCase to snake_case when configured. - Gateway post-processing:
/gateway/dataand/gateway/fetchaccept optional JSON fields such asgroup_by,time_granularity(day,hour,minute),aggregation_column,aggregation_strategy(cumulative_sum), andaggregation_dedup. When present the response will include apost_processing.groupedarray with{ label, rows, aggregation }entries so callers can easily visualize grouped rows plus their (optionally deduplicated) cumulative aggregates. - SQL executor:
/query/sqldispatches to Athena/Scylla, PostgreSQL, or Supabase; PostgreSQL queries now reuse the same SQLx pool registry and honorX-Athena-Client. - Proxy helpers:
proxy_requestforwards arbitrary REST calls to the configured upstream (Athena, Dexter, etc.) with caching + auth header management. - Cache layer: Built on
mokawith optional Redis write-through and helper utilities inapi::cache. - Configuration:
config.yamldrives URLs, caches, Postgres pools, and the camel-to-snake toggle. Useopenapi.yamlfor tooling compatibility.
Dedicated configuration notes
- Replace each
postgres_clientsURI with${ENV_VAR_NAME}references, and provide the real host via environment variables before starting the binary; this keeps credentials out of version control and allows per-deployment secrets.
Running
- Populate
config.yamland export the referenced env vars. cargo run -- --api-onlyto start an Actix app that exposes the documented OpenAPI surface (openapi.yaml); the API no longer boots automatically unless--api-onlyorserveris provided.- Use the
X-Athena-Clientheader to pick a Postgres pool for/gateway/*and/query/sql.
Docker compose
- Pre-pull the Redis image used for optional caching:
docker pull redis:8.2.4-alpine3.22. - Run
docker compose up --buildto bring up theathenaAPI and the standalonerediscache together. - Athena listens on
http://localhost:4052and keeps running even if Redis is turned off; caching only activates when you pointATHENA_REDIS_URL=redis://redis:6379at the Redis service. - Stop the stack with
docker compose down; theredis-datavolume preserves cache data between runs.
CLI helpers
The same athena_rs binary now exposes CLI helpers alongside the HTTP API. Provide --config/--pipelines to override config.yaml or config/pipelines.yaml, and call cargo run -- <command> (or cargo run -- server) when you need tooling; the API only starts on boot when you pass --api-only.
You can also pass --port to override the API port when booting the server instead of editing config.yaml.
cargo run -- --api-only(orcargo run -- server) starts the Actix Web server.cargo run -- pipeline --client my_client --payload-file ./workflows/pipeline.jsonruns a pipeline request locally (use--payload-jsonor--payload-fileto supply asource/transform/sinkbody and--pipelineto reference a prebuilt definition).cargo run -- clients list/add/remove/set-defaultto manage theconfig/clients.jsonfile that stores reusable Postgres client names.cargo run -- fetch --client my_client --body-file ./examples/fetch.jsonposts the payload tohttps://athena-db.com/gateway/fetchwith the savedX-Athena-Client.cargo run -- diagprints platform, CPU, and build metadata.cargo run -- --version(orcargo run -- version) prints the build version and exits.
Web explorer
- The
apps/webNext.js app now hosts the Athena Explorer UI (apps/web/app/page.tsx), which renders a table list sidebar, editable datagrid, and schema action drawer powered by the gateway/SQL APIs. - Run
npm installfromapps/weband startnpm run devto explore the workspace while pointing the frontend tohttps://athena-db.com(override viaNEXT_PUBLIC_ATHENA_BASE_URL). The UI also expects the Athena headers (NEXT_PUBLIC_ATHENA_CLIENT,NEXT_PUBLIC_ATHENA_USER_ID,NEXT_PUBLIC_ATHENA_COMPANY_ID,NEXT_PUBLIC_ATHENA_ORGANIZATION_ID) when issuing insert/delete requests. - The datagrid components now rely on the
/schema/clients,/schema/tables, and/schema/columnsendpoints to discover Postgres pools and table metadata while still issuing row/DDL requests through/gateway/fetch,/query/sql, and the gateway insert/delete endpoints defined inopenapi.yaml. Set uppostgres_clientsinconfig.yamlso the Rust backend can expose the pools that the UI lets you switch between.
For detailed API contracts, import openapi.yaml into your preferred OpenAPI tooling.
AthenaClient SDK
The newly introduced AthenaClient SDK exposes a builder-based interface that works across Supabase, PostgreSQL, Scylla, and other backends in a single API. Use the builder to configure SSL, pools, health checks, and connection timeouts, or rely on the convenience constructors from athena_rs::AthenaClient for the most common flows.
use ;
use json;
let client = builder
.backend
.url
.key
.health_tracking
.max_connections
.build
.await?;
let rows = client
.select
.columns
.where_eq
.limit
.execute
.await?;
let _ = client
.insert
.payload
.execute
.await?;
The SDK also exposes helpers such as:
AthenaClient::new(url, key)(defaults to the native SQL backend)AthenaClient::new_with_backend(url, key, backend_type)for explicit backend selectionAthenaClient::new_with_backend_name(url, key, "supabase")/"postgrest"/"scylla"/"neon"for quick scripts
Behind the scenes, AthenaClient picks the right translator (SQL vs. CQL), handles health tracking (circuit breaker + probes), and keeps the original drivers untouched, meaning your existing Supabase/SQlX/Scylla code still works while you migrate to the shared SDK.