Skip to main content

Ingest Server

A lightweight Node.js service that accepts the SDK's HTTP push, buffers events in a local DuckDB staging table, and periodically exports them as date-partitioned Parquet files on S3.

browser / RN ──POST {batch,sentAt}──▶ ingest-server (Fastify + DuckDB)
│ INSERT into .staging.duckdb
│ flush on timer or row threshold
▼
S3 s3://bucket/events/dt=YYYY-MM-DD/part-<uuid>.parquet
│
DuckDB read_parquet('s3://…/**/*.parquet')

Prerequisites​

  • Node.js 20+
  • pnpm 9+
  • An S3-compatible bucket (AWS S3, Cloudflare R2, MinIO, …)
  • DuckDB CLI for queries: brew install duckdb

Setup​

cp apps/ingest-server/.env.example apps/ingest-server/.env
# Edit S3_BUCKET, AWS_*, PORT, etc.

pnpm install
pnpm --filter ingest-server dev

Environment variables​

VariableDefaultDescription
PORT8787HTTP port
INGEST_PATH/batchPOST path
S3_BUCKET—Required. Target bucket
S3_PREFIXeventsKey prefix
AWS_REGIONus-east-1AWS region
AWS_ACCESS_KEY_ID—Blank for IAM auth
AWS_SECRET_ACCESS_KEY—Blank for IAM auth
ENDPOINT_URL—MinIO / R2 override
DUCKDB_STAGING_PATH./.staging.duckdbLocal staging file
FLUSH_INTERVAL_MS60000Flush interval
FLUSH_MAX_ROWS5000Row-count flush threshold

Wire the SDK​

import { HttpStorageAdapter } from '@drakkar.software/sunglasses-storage-http';

new HttpStorageAdapter({ endpoint: 'http://localhost:8787/batch' })

Response codes​

CodeMeaningSDK behaviour
200Batch stagedSuccess
400Malformed bodyNon-retriable — batch discarded
503Staging failedRetry with backoff

Query with DuckDB​

duckdb
> .read apps/ingest-server/queries/01-setup.sql
> .read apps/ingest-server/queries/02-explore.sql

See Local testing with MinIO and Event shape for the Parquet schema.

Visualize with the analytics dashboard​

For a built-in UI instead of the DuckDB CLI, run the analytics dashboard alongside the ingest server. It queries the same S3 Parquet prefix via DuckDB and exposes charts (DAU, top events, retention) plus a read-only SQL console.