Skip to content

Repository files navigation

OpenFactory-AssetAPI — Serving Layer for Asset Data

Dev Container Ready Python Version License Pre-Release

OpenFactory-AssetAPI is the core serving layer within the OpenFactory platform, designed to provide efficient access to real-time and computed asset data. It exposes both state query and streaming endpoints for developers and systems to retrieve asset telemetry and state information.

This service leverages a modular architecture with plugin-based grouping strategies and deployment platforms, enabling flexible and scalable data routing tailored to various production environments.


🚀 Quick Start

Prerequisites

  • Python 3.12+
  • Docker & Docker Compose (for containerized deployments)
  • Optional: jq for pretty JSON output on CLI

1. Configure Environment

Create a .env file (or export env vars) with key settings, for example:

GROUPING_STRATEGY=workcenter
DEPLOYMENT_PLATFORM=swarm
KSQLDB_URL=http://<ksqldb-ip>:8088
KAFKA_BROKER=<kafka-broker-ip>:9092
LOG_LEVEL=info

2. Build and Run

First, install the package (editable mode, with optional dev dependencies):

pip install -e .           # for normal install
# or
pip install -e .[dev]      # to include dev tools like flake8

Then, deploy the services (uses the configured deployment platform):

manage deploy

If your deployment platform requires a local server running (e.g., during development), start it with:

manage runserver

3. Interact with the API

Query asset state (replace WTVB01-001 with your asset UUID):

curl "http://localhost:5555/asset_state?asset_uuid=WTVB01-001" | jq

Get specific data items:

curl "http://localhost:5555/asset_state?asset_uuid=WTVB01-001&id=avail" | jq

🧩 Plugin System

The routing layer loads grouping strategies and deployment platforms dynamically via entry points configured in pyproject.toml.

This allows:

  • Selecting strategies and platforms at runtime via environment variables (GROUPING_STRATEGY, DEPLOYMENT_PLATFORM)
  • Easily adding new plugins without modifying core code

Default plugins include:

  • Grouping: workcenter
  • Deployment: swarm, docker

🛠 Development

CLI commands

Use the manage command for common tasks:

manage deploy       # initialize streams and resources
manage runserver    # start the API server
manage teardown     # stop deployed services and clean up

(Requires installation in editable mode: pip install -e .)

🔧 For a zero-config local dev environment using Docker and VS Code, see Development Container Setup

Linting

Run code quality checks with:

flake8 .

⚙ Configuration

Key environment variables include:

Variable Description Default
GROUPING_STRATEGY Grouping plugin to load workcenter
DEPLOYMENT_PLATFORM Deployment plugin to load swarm
KSQLDB_URL ksqlDB endpoint URL http://<ksqldb-ip>:8088
KAFKA_BROKER Kafka bootstrap server address <kafka-broker-ip>:9092
LOG_LEVEL Logging verbosity level info

For a comprehensive list of configuration options and their defaults, refer to the Settings class in routing_layer/app/config.py.

About

OpenFactory Serving Layer for Assets

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages