Comprehensive guides and references for the OpenFrame platform
The Api Lib Domain Services module provides core domain-level business services that sit between the API layer (REST and GraphQL) and the persistence layer (Mongo repositories and documents). It encapsulates reusable business logic that is shared across API services, GraphQL data fetchers, and potentially other backend components.
This module focuses on:
By centralizing this logic, the platform ensures consistent behavior across API surfaces and prevents duplication in controllers or data fetchers.
The Api Lib Domain Services module is part of the API library layer and interacts primarily with:
flowchart TD
Client["Client Applications"] --> ApiLayer["API Service Layer"]
ApiLayer --> DomainServices["Api Lib Domain Services"]
DomainServices --> Repositories["Mongo Repositories"]
Repositories --> Database[("MongoDB")]
flowchart LR
InstalledAgentService["InstalledAgentService"]
ToolConnectionService["ToolConnectionService"]
DefaultDeviceStatusProcessor["DefaultDeviceStatusProcessor"]
InstalledAgentService --> InstalledAgentRepository["InstalledAgentRepository"]
ToolConnectionService --> ToolConnectionRepository["ToolConnectionRepository"]
DefaultDeviceStatusProcessor --> Machine["Machine Document"]
Component:
deps.openframe-oss-lib.openframe-api-lib.src.main.java.com.openframe.api.service.InstalledAgentService.InstalledAgentService
The InstalledAgentService encapsulates business logic for retrieving installed agents associated with machines.
Key responsibilities:
The method:
getInstalledAgentsForMachines(List<String> machineIds)
is specifically designed to support GraphQL DataLoader patterns. Instead of executing one query per machine, it:
findByMachineIdIn.This approach:
flowchart TD
Start["Request Installed Agents"] --> CheckEmpty{{"machineIds empty?"}}
CheckEmpty -->|"Yes"| ReturnEmpty["Return empty list"]
CheckEmpty -->|"No"| QueryRepo["findByMachineIdIn"]
QueryRepo --> Group["Group by machineId"]
Group --> MapBack["Map results to input order"]
MapBack --> End["Return List<List<InstalledAgent>>"]
Component:
deps.openframe-oss-lib.openframe-api-lib.src.main.java.com.openframe.api.service.ToolConnectionService.ToolConnectionService
The ToolConnectionService provides read-only access to tool connections associated with machines.
Key responsibilities:
The service is annotated with @Transactional(readOnly = true) to explicitly define its intent as a read-focused service.
Similar to InstalledAgentService, the method:
getToolConnectionsForMachines(List<String> machineIds)
implements a batch loading strategy:
findByMachineIdIn.This ensures consistent performance characteristics for GraphQL queries resolving nested tool connection data.
flowchart TD
Start["Request Tool Connections"] --> CheckEmpty{{"machineIds empty?"}}
CheckEmpty -->|"Yes"| ReturnEmpty["Return empty list"]
CheckEmpty -->|"No"| QueryRepo["findByMachineIdIn"]
QueryRepo --> Group["Group by machineId"]
Group --> MapBack["Map results to input order"]
MapBack --> End["Return List<List<ToolConnection>>"]
Component:
deps.openframe-oss-lib.openframe-api-lib.src.main.java.com.openframe.api.service.processor.DefaultDeviceStatusProcessor.DefaultDeviceStatusProcessor
DefaultDeviceStatusProcessor is a pluggable post-processing hook for device status updates.
It implements the DeviceStatusProcessor interface and is annotated with:
@Component@ConditionalOnMissingBeanThis means:
When a device status changes, the processor:
This provides:
flowchart TD
StatusChange["Machine status updated"] --> ProcessorInterface["DeviceStatusProcessor"]
ProcessorInterface --> DefaultImpl["DefaultDeviceStatusProcessor"]
ProcessorInterface --> CustomImpl["Custom Implementation (optional)"]
If a custom implementation is provided, Spring will inject it instead of the default.
Both InstalledAgentService and ToolConnectionService are designed with batch operations as first-class citizens. This aligns with:
The services:
This keeps them reusable and testable.
DefaultDeviceStatusProcessor demonstrates a pattern where:
This supports tenant-level or deployment-specific customization.
These repositories abstract MongoDB access and are responsible for:
Device status changes may originate from streaming services or Kafka consumers. Once persisted, post-processing logic can be applied via DeviceStatusProcessor implementations.
The Api Lib Domain Services module provides a clean, reusable domain service layer for:
It is optimized for:
By isolating these responsibilities, the platform maintains a clear separation between:
This modular design supports scalability, maintainability, and multi-tenant extensibility across the OpenFrame ecosystem.