How HxSync Works

HxSync listens to the case_events table using a background CDC listener registered at service startup. Every insert into case_events — case created, stage transitioned, step completed, field updated, comment added — is captured and placed on the HxSync internal queue. Each pipeline then picks up events matching its case type filter, applies the configured field mapping, transforms data types as needed, and writes to the target destination.

In real-time mode, the pipeline processes events as they arrive with sub-second latency under normal load. In scheduled mode, events are batched and flushed on a cron schedule you define (e.g., every 15 minutes, hourly, nightly). Scheduled mode is appropriate for targets with write-cost concerns (BigQuery streaming vs. batch load jobs) or destinations that prefer bulk inserts.

  ┌─────────────────────────────────────────────────────────────────────┐
  │                       Velaris case-service  :8200                      │
  │                                                                     │
  │   case.created ──▶  case_events  ◀──  stage.transition              │
  │   step.completed ──▶    table    ◀──  field.updated                 │
  └───────────────────────────┬─────────────────────────────────────────┘
                              │  CDC listener (background task)
                              ▼
  ┌───────────────────────────────────────────────────────────────────┐
  │                    HxSync Pipeline Engine                         │
  │                                                                   │
  │  ┌─────────────┐    ┌──────────────────┐    ┌─────────────────┐  │
  │  │ Case Type   │    │  Field Mapping   │    │  Transform &    │  │
  │  │ Filter      │───▶│  (JSON map)      │───▶│  Type Coerce    │  │
  │  └─────────────┘    └──────────────────┘    └────────┬────────┘  │
  │                                                      │           │
  └──────────────────────────────────────────────────────┼───────────┘
                                                         │
                    ┌────────────────────────────────────┤
                    │                    │               │
                    ▼                    ▼               ▼
          ┌──────────────┐   ┌─────────────────┐  ┌──────────────┐
          │ PostgreSQL   │   │  BigQuery       │  │  S3 Parquet  │
          │ (replica /   │   │  (streaming or  │  │  (hourly or  │
          │  target DB)  │   │   batch load)   │  │   daily)     │
          └──────────────┘   └─────────────────┘  └──────────────┘

Pipeline Configuration Reference

Field Type Description
Name string Human-readable pipeline name (e.g., "Mortgage Cases > BQ Analytics"). Used in monitoring and alerts.
Case Type Filter list of slugs Which case types this pipeline captures. Leave empty to capture all case types visible to the HxSync service account. Wildcards not supported — specify each slug explicitly.
Field Map JSON JSON object Maps Velaris case fields (case.data.X) to destination column names. Supports nested dot notation on the source side. See example below.
Destination Type enum postgres, bigquery, or s3_parquet. Determines which driver and DSN format to use.
Destination DSN string Connection string for the target. PostgreSQL: standard DSN. BigQuery: bigquery://project/dataset/table. S3: s3://bucket/prefix/ (Parquet files named by date-hour).
Sync Mode enum realtime (sub-second, event-driven) or scheduled (cron expression, batch). Real-time requires the destination to support single-row upserts; BigQuery real-time uses the Streaming API (higher cost).
Schedule (cron) cron string Required when Sync Mode is scheduled. Standard 5-field cron expression (e.g., */15 * * * * for every 15 minutes). All schedules run in UTC.
Error Handling enum skip — log error and continue; retry — exponential backoff up to 5 attempts then skip; pause — pause pipeline on first error and alert.
Backfill From Date ISO 8601 Optional. On pipeline creation or explicit backfill trigger, replay all case_events from this date. Useful when initialising a new warehouse table with historical data.
Lag Alert Threshold (s) integer Seconds of CDC lag before a warning is raised. Default: 60. When lag exceeds this value, the pipeline status turns yellow in Studio and an optional Slack notification is fired.
Slack Webhook URL URL Optional. Receives pipeline alerts: lag warnings, pause events, error summaries, and backfill completion.

Field Map JSON Format

The field map is a JSON object where each key is a destination column name and each value is a source expression. Source expressions support Velaris's case.data.X dot notation for custom case fields, plus a set of built-in case metadata fields.

// Example field map for a Mortgage Application pipeline > BigQuery
{
  "case_reference":       "case.reference",
  "case_type":            "case.type_slug",
  "created_at":           "case.created_at",
  "current_stage":        "case.current_stage",
  "status":               "case.status",
  "resolved_at":          "case.resolved_at",

  // Custom case fields via case.data.<field_name>
  "applicant_full_name":   "case.data.applicant_name",
  "loan_amount_gbp":       "case.data.loan_amount",
  "credit_score":          "case.data.credit_score",
  "property_postcode":     "case.data.property_address.postcode",

  // Nested object field (dot notation supported)
  "employer_name":         "case.data.employment.employer",
  "annual_income":         "case.data.employment.annual_income",

  // SLA metadata
  "sla_breached":          "case.sla_breached",
  "sla_breach_stage":      "case.sla_breach_stage"
}
Type coercion: HxSync automatically coerces field types to match the destination schema when the destination table already exists. Strings are quoted, numbers left as-is, booleans converted to the destination's boolean type, and timestamps normalised to ISO 8601 UTC. If type coercion fails for a row, it is handled according to your Error Handling setting.

How to Create a Pipeline

  1. Navigate to Studio > HxSync > Pipelines and click Add Pipeline.

  2. Enter a descriptive pipeline Name and optionally a description. Choose the Case Type Filter — select one or more case type slugs from the dropdown, or leave blank to capture all types.

  3. Select the Destination Type (postgres, bigquery, or s3_parquet). Enter the Destination DSN. For BigQuery, the HxSync service account must have the bigquery.tables.create and bigquery.tables.updateData IAM permissions on the target dataset. For S3, provide AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables on the case-service.

  4. Build the Field Map JSON. Use the inline JSON editor in Studio — it validates your expression syntax on blur. Click Preview to see a sample row from the most recent matching case event.

  5. Choose Sync Mode. For scheduled mode, enter the cron expression and confirm the UTC schedule in the display below the field. For realtime mode, confirm the destination supports upsert writes.

  6. Configure Error Handling and the optional Slack Webhook URL for alert notifications.

  7. If seeding a new warehouse table with historical data, toggle Enable Backfill and set the Backfill From Date. HxSync will replay all qualifying case_events rows from that date before switching to live CDC mode.

  8. Click Save & Activate. The pipeline starts immediately. Monitor its initial sync in the Pipelines list — a green status dot and a "Last Sync" timestamp confirm successful operation.

Monitoring Pipelines

The Studio > HxSync > Pipelines list shows a live status row for each pipeline:

Column Description
Status Green (running), Yellow (lag warning or recoverable error), Red (paused — requires manual intervention), Grey (inactive/disabled).
Last Sync Timestamp of the most recently flushed event batch. For real-time pipelines, this updates every few seconds. For scheduled, it shows the last cron execution time.
Lag Current CDC lag in seconds (difference between the newest unprocessed event timestamp and now). Values above the configured threshold show in amber.
Rows Synced (session) Number of rows written to the destination since the pipeline last started or was reset. Resets on pause/resume.
Rows Synced (total) Cumulative rows written since the pipeline was created. Stored in migration_pipeline_runs.
Error Log Link to the last 100 error entries for this pipeline. Shows row-level errors (field coercion failures, destination write errors) with the event payload that caused the failure.
Lag alert: When CDC lag exceeds your configured threshold (default 60 seconds), the pipeline status turns yellow and a Slack notification is fired (if configured). Common causes: destination write latency spike, network partition to the target, or a very large backfill competing with live events. Check the Error Log and destination health first.

Database Tables

HxSync writes its own operational metadata to two tables in the Velaris PostgreSQL database:

API Reference

Method Endpoint Description
POST /api/v1/sync/pipelines Create a new pipeline. Body: full pipeline configuration JSON (name, case_type_filter, field_map, destination_type, destination_dsn, sync_mode, error_handling, etc.).
GET /api/v1/sync/pipelines List all pipelines visible to the authenticated user. Returns status, last_sync, rows_synced, and lag for each.
GET /api/v1/sync/pipelines/{id} Get full details for a specific pipeline including current configuration, run history, and the last 10 error log entries.
PATCH /api/v1/sync/pipelines/{id} Update pipeline configuration. Changes take effect on the next event flush; a running real-time pipeline is not restarted unless the destination DSN changes.
POST /api/v1/sync/pipelines/{id}/pause Pause a running pipeline. Events continue to accumulate in the internal queue; they will be replayed when the pipeline is resumed.
POST /api/v1/sync/pipelines/{id}/resume Resume a paused pipeline. Flushes any queued events immediately before switching to live mode.
POST /api/v1/sync/pipelines/{id}/backfill Trigger a backfill for an existing pipeline. Body: {"from_date": "2026-01-01"}. Runs in the background; monitor via migration_pipeline_runs.
DELETE /api/v1/sync/pipelines/{id} Delete a pipeline. This does not drop destination tables or roll back previously synced data. Pause the pipeline and verify data integrity before deleting.
# Create a real-time pipeline: Claims > PostgreSQL replica
curl -s -X POST http://localhost:8200/api/v1/sync/pipelines \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <JWT_TOKEN>" \
  -d '{
    "name": "Claims Cases > Reporting DB",
    "case_type_filter": ["insurance-claim", "property-claim"],
    "field_map": {
      "case_reference":  "case.reference",
      "status":          "case.status",
      "created_at":      "case.created_at",
      "claim_type":      "case.data.claim_type",
      "claim_amount":    "case.data.claim_amount",
      "sla_breached":    "case.sla_breached"
    },
    "destination_type": "postgres",
    "destination_dsn":  "postgresql://reporting_user:pass@reporting-db:5432/analytics",
    "sync_mode": "realtime",
    "error_handling": "retry",
    "lag_alert_threshold_s": 60,
    "slack_webhook_url": "https://hooks.slack.com/services/XXX/YYY/ZZZ"
  }'