Skip to content

Data Layer Architecture ​

Overview ​

The Data Layer provides structured data services with automatic CRUD operations, relationship handling, and database persistence. This document describes how data services are structured and how they integrate with workflows and applications.

Service Architecture ​

Each Data Layer service consists of four layers:

Data Model Layer

Defines entities, their fields, relationships, and constraints. The data model specifies what data the service manages and how entities relate to each other.

API Layer

Handles data access requests and responses. The API layer validates requests, enforces type safety, and coordinates operations across the service.

Business Logic Layer

Implements data operations and validations. This includes standard CRUD operations automatically provided for all entities, plus custom operations for specialized requirements.

Database Layer

Manages data persistence and queries. The database layer handles transactions, enforces constraints, and optimizes data retrieval.

This layered architecture provides:

  • Clear separation between data access and persistence
  • Consistent patterns across all data services
  • Extension points for custom logic
  • Independent scaling of components

Core Capabilities ​

Structured Data Models

Data services provide type-safe entities with defined relationships. Each entity has typed fields, validation constraints, and connections to related entities.

Key aspects:

  • Strongly-typed entity definitions
  • Declarative relationship mapping
  • Data integrity constraints
  • Schema versioning

Automatic Operations

All entities automatically receive complete CRUD operations:

  • Create — Add new entities with validation
  • Read — Retrieve single entities or filtered lists
  • Update — Modify existing entities with constraint checking
  • Delete — Remove entities with relationship handling

Additional automatic capabilities:

  • Pagination for large result sets
  • Filtering and sorting on entity fields
  • Relationship navigation between entities
  • Transaction management for consistency

Data Persistence

Data services provide reliable persistence:

  • Database integration for long-term storage
  • Transactional operations for data consistency
  • Automatic schema migration as models evolve
  • Query optimization for performance

Extensibility

Beyond automatic operations, data services can be extended with custom logic:

  • Specialized queries with complex filtering and aggregation
  • Multi-step business workflows coordinating multiple entities
  • Integration with external systems and APIs
  • Domain-specific validation rules beyond database constraints
  • Event-driven actions triggered by data changes
  • Batch processing operations for bulk data handling

Custom operations integrate with standard operations while maintaining data service consistency and transaction support.

Data Model Definition ​

Data services are defined through schemas that specify:

Entities

The core data types the service manages. Each entity defines its fields, types, and constraints.

Relationships

How entities connect to each other. Relationships can be one-to-one, one-to-many, or many-to-many with automatic navigation in both directions.

Constraints

Rules ensuring data validity including required fields, unique values, default values, and custom validation logic.

Operations

What actions are available on entities. Standard operations are provided automatically; custom operations can be added for specialized needs.

See the Schema Guide for data model design patterns.

Integration Points ​

Workflow Engine

Workflows access Data Layer services through connection tasks:

  • Data Import — Load operational data into workflows
  • Data Export — Write workflow results to data services
  • Type Validation — Ensure workflow outputs match entity schemas

The Workflow Engine uses a Data Layer service for its own backend, storing workflows, experiments, and execution results.

Applications

Frontend applications connect to data services for operational data:

  • Configuration-driven connections
  • Type-safe queries
  • Automatic error handling
  • Real-time data updates

Data Model Evolution ​

As operational requirements change, data models evolve:

Adding Entities

New entity types can be added as capabilities expand without affecting existing entities.

Modifying Relationships

Relationships between entities can be updated as workflows and data flows change.

Updating Constraints

Validation rules and constraints can be refined based on operational experience.

Extending Operations

Custom operations can be added for new specialized requirements while preserving existing functionality.

The Data Layer manages schema changes while preserving data integrity and custom business logic.

Design Principles ​

Automatic Standard Operations

All entities receive complete CRUD operations automatically. This ensures consistent data access patterns and reduces implementation effort.

Selective Customization

Custom logic is added only where specialized behavior is needed. Standard operations handle routine data access; custom operations implement unique business rules.

Type Safety Throughout

Type validation occurs at every layer:

  • Schema validation during development
  • Request validation in the API layer
  • Constraint enforcement in the database
  • Cross-service compatibility checking

Auditability

Data changes are tracked for operational insight:

  • Schema version history
  • Data modification logs
  • Transaction records
  • Complete audit trail

Performance Characteristics ​

Caching

Data services include built-in caching for frequently accessed data, reducing database load and improving response times.

Query Optimization

The database layer optimizes queries automatically, including efficient relationship loading and index utilization.

Scaling

Data services can scale independently based on load, with the layered architecture enabling component-level optimization.

See Also ​

User documentation for Optimal Reality