Definiti

Describe your domain

Does your language enable you to describe your domain? Does it only describe you domain or do technical stuffs are in your way?

The objective of Definiti is to provide a declarative language and tools to help you describe your domain and throw out technical code at the edge of your application.

How does it work?

Define all your domain logic in Definiti language, then generate sources code in your technical languages such as Scala or Typescript.

It is also possible to generate other things than sources files, as glossary, plantUML diagrams and more.

The following diagram represents a simple workflow with Definiti:

Definiti is not intended to work as a standalone language. Please check which languages are supported before using it.

Getting started

We use docker to download and execute the Definiti compiler. Please refers to the documentation to install it on your environment.

To start using Definiti, execute the following installation command:

bash -c "$(curl https://raw.githubusercontent.com/definiti/definiti/master/script/install.sh -sSf)"

You will be ask for the version, the languages and the plugins to use. For instance, we will take following configuration:

  • version: default

  • languages: scala

  • plugins: none

Once done, write your first Definiti file in src/main/definiti/blog.def (we will come back to the syntax later):

src/main/definiti/blog.def
package my.blog

type BlogArticle {
  title: String
  description: String
  date: Date
}

Then compile it:

./definiti

You will see a new directory: target/scalamodel with the most interesting file my/blog/blog.scala:

src/main/scala-definiti/my/blog/blog.scala
package my

import definiti.native._
import java.time.LocalDateTime

package object blog {
  case class BlogArticle(title: String, description: String, date: LocalDateTime)
  object BlogArticle {
    val verification: Verification[BlogArticle] = Verification.none[BlogArticle]
  }
}

You can now use it in your own project:

src/main/scala/my/app/App.scala
package my.app

import java.time.LocalDateTime
import my.blog.BlogArticle


object App {
  def main(args: Array[String]): Unit = {
    val firstArticle = BlogArticle(
      title = "My first article",
      description = "My description",
      date = LocalDateTime.now()
    )
    println(firstArticle)
  }
}

What's next?

Please check the left panel to go through the documentation.

Last updated