Concerto Modeling Language

website·Indexed 34 days ago

https://concerto.accordproject.org

A modeling language (CML) for defining domain-specific models with support for model evolution, validation, and code generation. It includes a CLI for validating and compiling models into various targets including Java, TypeScript, Rust, C#, Go, GraphQL, OpenAPI, JSON Schema, Protobuf, and others. The ecosystem provides a JS API for managing AST declarations and a configurable linter via the lintModel API.

Tokens
35.5K
Snippets
223
Records
309
Agent score
59%

What's inside Concerto

  1. Overview of Concerto data modeling language

    Concerto is a lightweight, object-oriented data modeling (schema) language and runtime designed for business concepts. It provides a more readable alternative to JSON/XML Schema or XMI and allows developers to capture real-world business models that map easily to various runtime environments. Key capabilities include:

    • Serialization and deserialization (with validation) of instances to/from JSON.
    • Runtime introspection of models via APIs.
    • Conversion of models into over 14 common data model formats.
    • Ability to infer models from JSON documents, JSON Schema, and OpenAPI v3 specifications.
    • Publishing reusable models to websites or the Accord Project model repository.
  2. Overview of Concerto JS Modules

    Concerto provides a suite of modules for defining and managing domain-specific models. Key modules include:

    • concerto-core: The core framework for domain-specific models.
    • concerto-cto: Concrete syntax module for Concerto.
    • concerto-metamodel: Management of the Concerto metamodel.
    • concerto-tools: General tooling for Concerto.
    • concerto-util: Utility functions for the framework.
    • concerto-vocabulary: Vocabulary management.
    • concerto-linter: Linting tools for Concerto models.
  3. Overview of the Concerto Conformance Test Suite

    The Concerto Conformance Test Suite is a cross-language validation tool designed to test the semantic correctness of the Accord Project's Concerto modeling language. It ensures that modifications to core components, such as the ModelFile or ModelManager, comply with a defined set of semantic validation rules. While it currently supports JavaScript, it is designed to test multiple implementations (e.g., Rust, C#) provided the respective language's step file is available.
  4. Overview of Concerto Vocabulary

    The Vocabulary module for Concerto allows developers to associate human-readable labels (Terms) with model elements. These terms are stored in locale-specific YAML files associated with a Concerto namespace. This enables multi-language support (e.g., English, French, Chinese) and allows specific locales to override or supplement terms from a base vocabulary (e.g., British English overriding generic English).
  5. Compile a Concerto model to XML Schema

    Use the concerto compile command with the --target xmlschema flag to generate an XML Schema (XSD) from a Concerto model file. This allows you to express constraints about XML documents based on your Concerto model definitions.
    concerto compile --model test.cto --target xmlschema
  6. Generate dynamic web forms with Concerto UI/Form

    Use the Concerto UI/Form web components to automatically generate dynamic web forms based on Concerto model definitions.
    # Project available at: https://github.com/accordproject/web-components
  7. Analyze class declarations using ClassDeclaration

    The ClassDeclaration class is the base for various model elements. It provides methods to inspect properties, super-types, and determine the kind of declaration (Asset, Participant, Transaction, Event, Concept, or Enum).
    // Check declaration type
    if (decl.isAsset()) { /* ... */ }
    if (decl.isEnum()) { /* ... */ }
    
    // Access properties
    const properties = decl.getProperties();
    const specificProp = decl.getProperty(name);
    const superTypes = decl.getAllSuperTypeDeclarations();
  8. Understand Java code generation output

    Concerto generates Java classes that extend base types such as Concept. The generated code includes Jackson annotations for JSON serialization (e.g., @JsonTypeInfo, @JsonIdentityInfo) and provides standard getters and setters for model properties. Identifying fields are mapped to a getID() method.
    // this code is generated and should not be modified
    package test;
    
    import concerto.Concept;
    import com.fasterxml.jackson.annotation.*;
    
    @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class")
    @JsonIgnoreProperties({"id"})
    @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email")
    public class Person extends Concept {
       
       // the accessor for the identifying field
       public String getID() {
          return this.getEmail();
       }
    
       private String email;
       private java.util.Date dob;
       public String getEmail() {
          return this.email;
       }
       public java.util.Date getDob() {
          return this.dob;
       }
       public void setEmail(String email) {
          this.email = email;
       }
       public void setDob(java.util.Date dob) {
          this.dob = dob;
       }
    }
  9. Generate Markdown documentation from a Concerto model

    Use the concerto compile command with the --target markdown flag to generate a Markdown representation of a Concerto model. The resulting output includes a namespace declaration, an overview of declarations (concepts, assets, etc.), a list of imports, and a Mermaid class diagram representing the model structure.
    concerto compile --model test.cto --target markdown