data-service

`data-service` is the only user-safe data access boundary for Vinova Backbone applications and microservices.

It exists to protect business data. Every request that reads or writes user-scoped application data must pass through this service so the authenticated user can be derived from the authentication token and every operation can be restricted to the data that user is allowed to access.

Data Access Boundary

Backbone separates raw persistence access from secure application data access:

This rule is mandatory because `datahub` can reach every table, while `data-service` enforces the security layer that prevents callers from selecting or modifying records owned by other users.

Browser clients and non-admin microservices must never send a trusted `userId` in the request body or query string. `data-service` must derive the effective user from the authentication token and build the authorization context itself.

The expected request flow is:


UserInterface / product service

  -> data-service

     -> validate authentication context

     -> derive user and ownership scope

     -> apply authorization filters

     -> call datahub

     -> return only allowed data

Direct `datahub` access is reserved for internal platform operations and AdminInterface tooling. It must not become a shortcut for application features.

Quick Start


# Development

npm run dev



# Production

npm start

Architecture

This service uses the centralized microservice framework:

`data-service` owns the authorization layer above `datahub`. Route handlers must keep business authorization close to the API surface and must call `datahub` only after the request has been associated with the authenticated user.

Analytics Boundary

UserInterface must call `data-service` for analytics data.

`data-service` must not implement analytics rules directly. It must:

When calling `analytic-service`, `data-service` must not forward browser-provided `userId` values. If a user identifier is required, it must be placed under `authorizationContext.subject.userId` after being derived from the token.

Internal analytics calls target:

Frontend-facing analytics endpoints:

Through Traefik these are exposed under `/data-service/analytics/*`.

Each endpoint derives the user from `req.userCtx`, applies ownership/sharing checks through the shared access helpers, builds an internal `authorizationContext`, calls `analytic-service`, and returns the canonical payload received from the analytics boundary.

Internal token requirements:

Configuration:

Code Reduction

Traditional approach: ~650 lines (main.js + server.js + status.js) **This service: ~165 lines (75% reduction)**

Standard Endpoints

Custom Endpoints

Administrative settings (authenticated platform administrators only):

Add your custom routes in `server.js`:


routes: [

  { path: '/api', router: apiRouter, protected: true }

]

Development

Port: 5003

Access locally: http://localhost:5003

Documentation