Skip to Content
Agentlang is open source now!
ConceptsGraph-based Data Model

Graph-based Data Model

Agentlang isn’t just another programming language — it’s designed around a graph-based, hierarchical data model that naturally reflects the real world. Unlike traditional relational databases or generic graph approaches, Agentlang lets you model complex domains with precision, flexibility, and clarity.

Why Graph-based?

  • Expressive Domain Modeling: The structure and shape of your business domain can be mapped directly into Agentlang’s data model. Entities, their relationships, and metadata form a graph that mirrors real-world interactions.
  • Flexible Hierarchies: From a developer’s perspective, the hierarchical and nested nature of this model is liberating. Maps, lists, combinations of lists of maps of maps… you name it, Agentlang can handle it.
  • Elegant Access Control: Ownership, containment, and access policies are naturally represented in the hierarchy. This makes implementing Zero Trust programming patterns both intuitive and maintainable.

Entity-Graph to Database Mapping

Every entity you define in an Agentlang application is backed by a persistent store — typically a relational database like SQLite or Postgres. The runtime automatically:

  • Persists entities, relationships, and metadata as a coherent graph.
  • Generates and maintains the database schema.
  • Converts data seamlessly between runtime objects and the storage layer.

Entities representing external resources are the exception. These are accessed via Agentlang Resolvers, abstracting the communication with external systems.


Core Concepts of the Data Model

Entity-Relationship Graph

Entities are nodes, relationships are edges, forming a rich graph capturing your domain data.

Hierarchical Relationships

Relationships in Agentlang come in two types:

  • between — simple associations.
  • contains — parent-child relationships forming trees.

Together, these create a graph of trees, allowing hierarchical structure and networked connections simultaneously.

Paths

Each entity can be uniquely addressed via a path:

  • Acts as a reference to the node.
  • Serializable for storage or transmission.
  • Bindable in computations and dataflows for context-aware processing.

Type Composition and Inheritance

Agentlang supports composition and inheritance for reusable and extensible schema design:

record PersonalInformation { firstName String, lastName String, dateOfBirth DateTime } record ContactInformation { street1 String, street2 String, zip String, email Email, phoneNumber String } entity Person { name String @id, personalInfo PersonalInformation, contact ContactInformation } entity Student extends Person { id UUID @id } entity Teacher extends Person { id UUID @id } entity Course { name String @id, subjects String[], startDate DateTime } relationship StudentCourse contains(Course, Student) relationship TeacherCourse between(Teacher, Course)

This example demonstrates how Agentlang enables composition and inheritance to build flexible, reusable data models. The Person entity is composed of smaller records, PersonalInformation and ContactInformation, encapsulating a person’s details in a structured way. Using inheritance, Student and Teacher extend Person, automatically including all personal and contact information while adding their own specific attributes. Relationships are then defined to model real-world associations: StudentCourse is a contains relationship linking students to the courses they are enrolled in, forming a parent-child hierarchy, while TeacherCourse is a between relationship connecting teachers to the courses they teach, capturing many-to-many associations. This approach allows developers to represent complex domain models in a clean, declarative, and highly expressive way.

Summary

Agentlang’s graph-based, hierarchical, and composable data model:

  • Mirrors real-world domains intuitively.
  • Supports complex nested structures effortlessly.
  • Provides a foundation for reliable, context-aware agent workflows.
Last updated on