Skip to content

agentlang-ai/agentlang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppCI Fractl clj CI Fractl cljs CI

The Fractl Programming Language

Fractl unlocks the future of tri-modal development - concurrent use of 3 different ways of programming:

  • Traditional coding in IDEs,
  • Visual development in a no-code builder, and,
  • Code generation with generative-AI.

Fractl Loves Gen AI

As a language, Fractl is data-oriented and declarative, with an abstraction that is closer to natural languages than traditional programming languages. This makes fractl a much better fit for Gen AI-powered code generation. Users can rapidly build business application in Fractl from high-level specifications - typically more than 10x faster than traditional programming languages.

Fractl is open

The Fractl language specification, its compiler and runtime are open source.

The code you build in Fractl can be run anywhere using the open source compiler and runtime, thereby avoiding the vendor lock-in of other low-code/no-code platforms.

Fractl is innovative

Fractl introduces a number of innovative concepts to programming:

  1. Graph-based Hierarchical Data Model - compose the high-level data model of an application as a hierarchical graph of business entities with relationships. Such entities and relationships are first-class constructs in Fractl.
  2. Zero-trust Programming - tightly control operations on business entities through declarative access-control encoded directly in the model itself.
  3. Declarative Dataflow - express business logic as purely-declarative patterns of data.
  4. Resolvers - use a simple, but powerful mechanism to interface with external systems.
  5. Interceptors - extend the fractl runtime with custom capabilities.
  6. Entity-graph-Database Mapping - take advantage of an abstract persistence layer for fully-automated storage of entity instances.

A Taste of Fractl

The following code snippet shows the Fractl model (i.e., program) for a simple accounting application.

(component :Accounts.Core)

(entity :Company
 {:Name {:type :String :guid true}
  :rbac [{:roles ["manager"] :allow [:create]}]})

(entity :AccountHead
 {:Name {:type :String :id true}
  :rbac [{:roles ["accountant"] :allow [:create]}]})

(entity :Entry
 {:No {:type :Int :id true}
  :Type {:oneof ["income" "expense"]}
  :Amount :Decimal
  :Remarks {:type :String :optional true}
  :DateCreated :Now})

(relationship :CompanyAccounts
 {:meta {:contains [:Company :AccountHead]}})

(relationship :Transactions
 {:meta {:contains [:AccountHead :Entry]}})

(record :BalanceReport
 {:Balance :Decimal
  :GeneratedOn :Now})

(defn- find-balance [entries]
  (reduce (fn [b t]
            (let [op (if (= "income" (:Type t)) + -)]
              (op b (:Amount t))))
          0 entries))

(event :GenerateReport
 {:Since :DateTime
  :Company :String
  :AccountHead :String})

(dataflow :GenerateReport
 {:AccountHead? {}
  :-> [[:CompanyAccounts?
        {:Company {:Name? :GenerateReport.Company}}
        :GenerateReport.AccountHead]]
  :as [:A]}
 {:Entry
  {:DateCreated? [:>= :GenerateReport.Since]}
  :-> [[:Transactions? :A]]
  :as :Es}
 {:BalanceReport
  {:Balance '(find-balance :Es)}})

Save this code to a file named accounts.fractl and its ready to be run as a highly-scalable accounting service with RESTful APIs to perform CRUD operations and generate balance report! But before you can actually run it, you need to install Fractl. The next section will help you with that.

Download and Install

Prerequisites

  1. JVM 19 or later
  2. Linux, Mac OSX or a Unix emulator in Windows

Download the Fractl CLI tool and execute the model:

./fractl /path/to/accounts.fractl

We can create a new company using an HTTP POST request,

curl --header "Content-Type: application/json" \
--request POST \
--data '{"Accounts.Core/Company": {"Name": "acme"}}' \
http://localhost:8080/_e/Accounts.Core/Company

To make sure the new company is persisted in the store, try the following HTTP GET:

curl http://localhost:8080/_e/Accounts.Core/Company/acme

If Fractl is installed correctly, both these requests will return an OK status along with a :Company instance. Listed below are a few more HTTP requests that you can try with our "accounting" application:

  1. Create an account-head for the new company.
POST /_e/Accounts.Core/Company/acme/CompanyAccounts/AccountHead

{"Accounts.Core/AccountHead": {"Name": "Department01"}}
  1. Make some transactions under the new account-head.
POST /_e/Accounts.Core/Company/acme/CompanyAccounts/AccountHead/Department01/Transactions/Entry

{"Accounts.Core/Entry":
 {"No": 1, "Type": "income",
  "Amount": 2000.0, "Remarks": "Opening balance"}}

POST /_e/Accounts.Core/Company/acme/CompanyAccounts/AccountHead/Department01/Transactions/Entry

{"Accounts.Core/Entry":
 {"No": 2, "Type": "expense",
  "Amount": 500.0, "Remarks": "Rent paid"}}
  1. Generate the balance-report for the account-head.
POST /_e/Accounts.Core/GenerateReport

{"Accounts.Core/GenerateReport":
 {"Since": "2023-11-09T00:00:00.00",
  "Company": "acme",
  "AccountHead": "Department01"}}

You're all set to further explore Fractl. Please proceed to the official documentation pages.