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 runto start an Actix app that exposes the documented OpenAPI surface (openapi.yaml).- Use the
X-Athena-Clientheader to pick a Postgres pool for/gateway/*and/query/sql.
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.