https://github.com/openfactoryio/openfactory-asset-api
OpenFactory Serving Layer for Assets
https://github.com/openfactoryio/openfactory-asset-api
Last synced: 3 months ago
JSON representation
OpenFactory Serving Layer for Assets
- Host: GitHub
- URL: https://github.com/openfactoryio/openfactory-asset-api
- Owner: openfactoryio
- License: apache-2.0
- Created: 2025-07-31T17:42:47.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-11-22T03:58:23.000Z (7 months ago)
- Last Synced: 2025-11-22T06:02:21.647Z (7 months ago)
- Language: Python
- Size: 106 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenFactory-AssetAPI โ Serving Layer for Asset Data
[](docs/devcontainer.md)
 
---
**OpenFactory-AssetAPI** is the core serving layer within the [OpenFactory](https://github.com/Demo-Smart-Factory-Concordia-University/OpenFactory) platform. It provides efficient access to **real-time** and **computed asset data** through:
* ๐ **State query endpoints**
* ๐ก **Streaming interfaces**
Its modular, plugin-based architecture supports flexible deployment and grouping strategies, tailored to various industrial environments.
---
## ๐ Quick Start
> This guide assumes deployment on an OpenFactory **Swarm** cluster.
### โ
Prerequisites
* Python 3.12+
* Docker
* A running OpenFactory Swarm cluster
* (Optional) `jq` for pretty-printing JSON responses
---
### ๐ง 1. Configure Environment
Create a `.env` file or export the following variables:
```env
GROUPING_STRATEGY=workcenter
DEPLOYMENT_PLATFORM=swarm
KSQLDB_URL=http://:8088
KAFKA_BROKER=:9092
```
---
### โถ๏ธ 2. Run
Install the package on a Swarm **manager node** of your OpenFactory cluster:
```bash
pip install -e .
```
Deploy the services:
```bash
manage deploy
```
---
### ๐ 3. Interact with the API
Query asset state:
```bash
curl "http://:5555/asset_state?asset_uuid=PROVER3018" | jq
```
Get specific asset data:
```bash
curl "http://:5555/asset_state?asset_uuid=PROVER3018&id=avail" | jq
```
Stream real-time telemetry:
```bash
curl "http://:5555/asset_stream?asset_uuid=PROVER3018"
```
---
## ๐งฉ Plugin System
The routing layer loads **grouping strategies** and **deployment platforms** dynamically using Python [entry points](https://packaging.python.org/en/latest/specifications/entry-points/) defined in `pyproject.toml`.
This enables:
* ๐น๏ธ Runtime plugin selection via environment variables:
* `GROUPING_STRATEGY`
* `DEPLOYMENT_PLATFORM`
* โ Easy plugin extension without modifying core code
**Default plugins:**
* Grouping: `workcenter`
* Deployment: `swarm`, `docker`
โน๏ธ Docker Deployment Info
When using the docker deployment platform, start the local server manually with:
```bash
manage runserver
```
---
## ๐ Development
### ๐งช Install for Dev
Install in editable mode with dev tools:
```bash
pip install -e .[dev]
./dev-setup.sh # installs latest openfactory-core
```
> ๐ง For a zero-config local dev environment using Docker and VS Code, see [Development Container Setup](./docs/devcontainer.md)
---
### ๐ป CLI Commands
Use the `manage` command for development tasks:
```bash
manage deploy # deploys services and streams
manage runserver # starts local API server
manage teardown # cleans up services
```
> ๐ก `manage` requires the package to be installed in editable mode.
---
### โ
Code Quality
Run linting checks with:
```bash
flake8 .
```
---
## โ๏ธ Configuration
Key environment variables:
| Variable | Description | Default |
| --------------------- | ------------------------------ | ------------ |
| `GROUPING_STRATEGY` | Grouping plugin to load | `workcenter` |
| `DEPLOYMENT_PLATFORM` | Deployment plugin to load | `swarm` |
| `KSQLDB_URL` | ksqlDB endpoint URL | *(None)* |
| `KAFKA_BROKER` | Kafka bootstrap server address | *(None)* |
๐ For full configuration details, refer to:
* [`routing_layer/app/config.py`](routing_layer/app/config.py)
* [Routing Layer README](routing_layer/README.md#๏ธ-environment-configuration)