← Back to Library

Reporting & Analytics (REST + SQL layer)

api ·  analysts, app devs
reportinganalyticspostgresqlsqlsearchcsv-export

Reporting & Analytics API

What it is. Reporting Sync is WIP's cross-cutting reporting and analytics layer. A background sync worker consumes NATS events for document, template, terminology, term, and term-relation changes and materializes them as flattened PostgreSQL table views — one doc_<value> table per template per namespace, plus fixed terminologies / terms / templates / term_relations metadata tables — so consumers can query WIP data with SQL instead of the document stores' own APIs (reporting_sync/worker.py, reporting_sync/schema_manager.py). A separate batch-sync path backfills or rebuilds those tables from the REST APIs of Def-Store, Template-Store, and Document-Store (reporting_sync/batch_sync.py). On top of the table views the service exposes ad-hoc read-only SQL querying, unified cross-entity search (terminology/term/template/document/file), outgoing/incoming reference validation, an aggregated referential-integrity check, an activity feed, and CSV export (reporting_sync/main.py).

Reaching it. Base path /api/reporting-sync (APIRouter(prefix="/api/reporting-sync"), main.py). /health is additionally exposed unprefixed, for direct container probes rather than through the API prefix. The interactive schema is served unprefixed at /docs (FastAPI default), reachable only when addressing the service directly. The service declares an X-API-Key security requirement in its OpenAPI contract (declare_api_key_security(app), main.py) — every route in this doc expects that header. See also: Auth & Access; Routing & Ingress.

Conventions that apply.

Endpoints

Health & status

GET /health

GET /api/reporting-sync/health

GET /api/reporting-sync/status

Monitoring & metrics

GET /api/reporting-sync/metrics

GET /api/reporting-sync/metrics/consumer

GET /api/reporting-sync/alerts

PUT /api/reporting-sync/alerts/config

POST /api/reporting-sync/alerts/test

Table & schema introspection

GET /api/reporting-sync/table-name

GET /api/reporting-sync/schema/{template_value}

Batch sync

POST /api/reporting-sync/sync/batch/terminologies

POST /api/reporting-sync/sync/batch/terms

POST /api/reporting-sync/sync/batch/term_relations

POST /api/reporting-sync/sync/batch/templates

POST /api/reporting-sync/sync/batch

GET /api/reporting-sync/sync/batch/jobs

GET /api/reporting-sync/sync/batch/jobs/{job_id}

POST /api/reporting-sync/sync/batch/{template_value}

DELETE /api/reporting-sync/sync/batch/jobs/{job_id}

DELETE /api/reporting-sync/sync/batch/jobs

Integrity check

GET /api/reporting-sync/health/integrity

Search & activity

POST /api/reporting-sync/search

GET /api/reporting-sync/activity/recent

GET /api/reporting-sync/references/term/{term_id}/documents

GET /api/reporting-sync/entity/{entity_type}/{entity_id}/references

GET /api/reporting-sync/entity/{entity_type}/{entity_id}/referenced-by

Query (cross-template joins)

GET /api/reporting-sync/tables

POST /api/reporting-sync/query

CSV export

GET /api/reporting-sync/export/csv

POST /api/reporting-sync/export/csv

Namespace deletion

DELETE /api/reporting-sync/namespace/{prefix}

Root

GET /api/reporting-sync/

Store-specific gotchas

See also

Generated from real source code, not hand-written — see the WIP Technical Library.