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.
- Python 3.12+
- Docker & Docker Compose (for containerized deployments)
- Optional:
jqfor pretty JSON output on CLI
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=infoFirst, 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 flake8Then, deploy the services (uses the configured deployment platform):
manage deployIf your deployment platform requires a local server running (e.g., during development), start it with:
manage runserverQuery asset state (replace WTVB01-001 with your asset UUID):
curl "http://localhost:5555/asset_state?asset_uuid=WTVB01-001" | jqGet specific data items:
curl "http://localhost:5555/asset_state?asset_uuid=WTVB01-001&id=avail" | jqThe 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
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
Run code quality checks with:
flake8 .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.