What HxAnalytics Is

HxAnalytics is accessible from Studio > HxAnalytics (/hxanalytics) and provides a multi-tab dashboard combining pre-built KPI cards, a natural-language query interface powered by HxNexus, a pivot-table breakdowns view, an SLA performance report, and a data export API. All views are scoped to the authenticated user's access group — an agent-level user sees their group's cases; an administrator with platform-wide access sees aggregate data across all groups.

The analytics engine runs directly against your PostgreSQL 16 database. There is no separate OLAP store — queries execute against the live case_instances, case_event_log, case_instance_variables, and case_sla_instances tables using optimised indexed reads. For heavy historical exports (millions of rows), HxSync pipelines should push data to a dedicated warehouse; HxAnalytics is optimised for interactive operational queries rather than petabyte-scale batch jobs.

Access group enforcement: Natural language queries routed through HxNexus respect access group boundaries at the SQL retrieval layer — not just at the prompt layer. Every generated query carries a hard WHERE clause constraining results to the authenticated user's permitted case types and records. There is no way for a correctly scoped user to extract data from another access group via HxNexus, even with adversarial phrasing.

Studio UI Tabs

The HxAnalytics Studio page (/hxanalytics) is organised into five tabs. Each tab shares a common Date Range selector (default: last 30 days) and Case Type Filter (default: all visible types).

Tab Contents Primary Audience
Overview KPI cards: Total Cases, Open Cases, Cases Closed (period), Avg Resolution Time, SLA Breach Rate, Top Case Type by Volume. Sparkline trends under each card. Configurable card order per user. Managers, Executives
Ask HxNexus Full-page natural language query interface. Type any operational question; HxNexus generates scoped SQL, retrieves data, and returns a prose answer with optional chart or table. Session history persists for the tab lifetime. Analysts, Managers
Breakdowns Interactive pivot table. Row: Case Type or Stage. Column: Time Period (day/week/month), Assignee Group, or Status. Cell value: Count, Avg Duration, or SLA Breach %. Drill-down by clicking any cell to see the underlying case list. Operations Analysts
SLA Report Per-stage SLA attainment gauge, breach count, MTTR (mean time to resolve per stage), top breached case types ranked by severity. Time-series chart of daily breach rate. Exportable as PDF. Process Owners, QA
Export Configure and trigger data exports. Choose format (CSV or JSON), date range, case type filter, and fields. Generates a download link or pushes to a HxSync pipeline. Audit-logged. Data Engineers, Compliance

Capabilities

💬
Natural Language Queries
Ask any operational question in plain English (or any language the AI model supports). HxNexus translates the intent into scoped SQL, executes it, and returns a structured prose answer — no SQL knowledge required. Example: "How many Mortgage Application cases were opened last week vs the week before?"
📊
Drill-Down Dashboard
Click any KPI card or pivot cell to instantly see the underlying case list. Drill down from portfolio level to individual case with full event history — all without leaving the analytics tab. Breadcrumb trail shows the filter chain applied.
⏰
SLA Performance Tracking
Pre-built SLA report shows attainment % per stage, breach counts by severity, and trend over time. Identify chronic bottleneck stages at a glance. SLA policies defined in Studio feed directly into the report — no separate configuration needed.
📈
Volume Trends
Time-series charts show case intake, resolution, and backlog by day, week, or month. Forecast mode (HxNexus-powered) projects the next 14 days of volume based on historical patterns — useful for staffing and capacity planning.
🔗
Cross-Case Insights
HxNexus can correlate across case types — e.g., "Do Loan Application approval rates drop when Claims intake spikes?" These multi-type insights are constrained to what the authenticated user's access group can see.
📥
Export (CSV / JSON)
Export case data, event logs, or SLA metrics as CSV or JSON for use in external tools. The Export API supports programmatic access with date range and field selection parameters. All exports are audit-logged with the requesting user and timestamp.

How Natural Language Queries Work

When you type a question in the Ask HxNexus tab, the following pipeline runs:

  1. Query received by case-service (through the gateway on :8200): The question is submitted to the HxNexus query endpoint with the user's JWT, which carries their access group membership and role.

  2. Intent classification: HxNexus classifies the query as an analytics intent (aggregate, trend, SLA, comparison) rather than a case-lookup or graph-query intent, triggering the analytics retrieval path.

  3. Scoped SQL generation: The AI generates a PostgreSQL query parameterised for the user's access group. The generated SQL is never executed directly — it is sanitised, the access-group WHERE clause is injected at the ORM layer, and the result set is capped at a configurable row limit (default 10,000 rows) before being returned to the AI model.

  4. Data summarisation: The retrieved rows are serialised and passed to the AI model as context. The AI generates a prose answer, optional formatted table, and 3 suggested follow-up questions. For queries returning aggregations, the AI may also suggest a chart type (bar, line, pie) — the frontend renders it using the embedded Chart.js library.

  5. Response delivered: The structured response is rendered in the Ask HxNexus tab with the answer, any chart, a collapsible "Sources" section listing the case IDs or aggregate keys used, and follow-up suggestion chips.

Configuration

HxAnalytics requires no special configuration beyond what Velaris already needs to run. Access group scoping is automatic — it inherits from the authenticated user's JWT claims. The only prerequisites are:

Zero-config analytics: No ETL pipelines, no separate BI database, no schema mapping. HxAnalytics queries your live Velaris PostgreSQL instance directly. For high-volume deployments where analytics queries compete with transactional workloads, consider configuring a read replica and setting ANALYTICS_DB_URL on the case-service to point to it.

Optional Environment Variables

Variable Default Description
ANALYTICS_DB_URL Falls back to DATABASE_URL Point to a PostgreSQL read replica to offload analytics queries from the primary. Same schema required.
ANALYTICS_ROW_LIMIT 10000 Maximum rows returned by any single analytics query before HxNexus summarises. Increase for data-dense exports; decrease for constrained environments.
ANALYTICS_EXPORT_MAX_ROWS 500000 Maximum rows for a single CSV/JSON export via the Export tab or API. Larger datasets should use HxSync to push to a warehouse.
ANALYTICS_CACHE_TTL 60 Seconds to cache repeated identical analytics queries (same user, same question). Reduces DB load for dashboards refreshed on a timer.

Export API Reference

The Export API lets you programmatically pull case data for integration with external BI tools, compliance archives, or data warehouses. All requests require a valid Bearer JWT. Exports are audit-logged.

GET /api/v1/analytics/export

Parameter Type Required Description
format string Yes csv or json. CSV uses RFC 4180 encoding with a header row. JSON returns a newline-delimited JSON stream for large datasets.
from ISO 8601 date Yes Start of date range (inclusive). Based on cases.created_at. Example: 2026-01-01
to ISO 8601 date Yes End of date range (inclusive). Example: 2026-03-31
case_type string No Filter to a specific case type slug (e.g., mortgage-application). Omit for all visible types.
fields comma-separated No Specific case fields to include in addition to standard columns. Example: applicant_name,loan_amount,credit_score
include_events boolean No If true, exports the case_events log for each case (significantly increases output size). Default: false
# Export all Mortgage Application cases for Q1 2026 as CSV
curl -s \
  -H "Authorization: Bearer <JWT_TOKEN>" \
  "http://localhost:8200/api/v1/analytics/export?format=csv&from=2026-01-01&to=2026-03-31&case_type=mortgage-application&fields=applicant_name,loan_amount,credit_score" \
  --output mortgage-q1-2026.csv

# Export all cases as newline-delimited JSON with full event log
curl -s \
  -H "Authorization: Bearer <JWT_TOKEN>" \
  "http://localhost:8200/api/v1/analytics/export?format=json&from=2026-04-01&to=2026-04-30&include_events=true" \
  --output april-cases.ndjson
Large exports: The Export API streams the response body — you will not receive a pre-signed download URL. For exports exceeding ANALYTICS_EXPORT_MAX_ROWS, the response is truncated and a X-Export-Truncated: true header is set. Configure a HxSync pipeline to BigQuery or S3 for untruncated bulk exports.