lsFusion : Open-Source Platform for Business Applications
Tags: opensource, lowcode
Published: 2023-01-31 07:19:00

[lsFusion](https://lsfusion.org) platform is designed for rapid development of business applications. It is distributed under the terms of a Lesser General Public License (LGPLv3). The source code of the platform is available on [Github](https://github.com/lsfusion/platform).

lsFusion is best suited for creating complex systems with large numbers of entities and forms, where users need to input and process large amounts of data. However, the platform can also be used to quickly create simple applications instead of spreadsheets when Excel’s functionality is not enough.

At the same time the use of the platform will not give a great advantage when developing applications aimed at interaction with a large number of “external” users or without the need for any complex calculations. You should also take into account that the web interface is a single page application using JavaScript. Therefore, the lsFusion platform is not well-suited for creating websites, for example.

## Alternatives
Currently, there are several platforms on the market to solve similar problems. Of those that have been in use for a long time, Access and Visual Foxpro can be singled out. More modern analogues are low-code platforms like Power Apps. However, lsFusion takes a fundamentally different approach to application development. In particular, it uses almost no visual programming, and all logic is set using a high-level language.

## Paradigm
Most modern platforms use standard relational logic, in which the application structure is defined by entities and the relationships between them. In lsFusion, [classes](https://docs.lsfusion.org/Classes/) that can inherit from each other are used instead of entities. Fields and relations are defined by [properties](https://docs.lsfusion.org/Properties/). Properties are essentially functions that accept class objects as parameters, returning either primitive type values (fields) or other objects (relations). A field in a table with multiple keys from relational logic will be represented as a property with the corresponding objects as parameters.

All properties fall into two categories :

[Primary](https://docs.lsfusion.org/Data_properties_DATA/). Entered directly by the user, and do not directly depend on any other properties.
Computed. Computed using [operators](https://docs.lsfusion.org/Property_operators_paradigm/) based on other properties.
A similar scheme is used in spreadsheets. Primary properties correspond to cells that store values. Cells that contain formulas are similar to computed properties.

The user interface is created using [forms](https://docs.lsfusion.org/Forms/) to which objects and properties are added, and their relationships specified by expressions.

With the help of the [event](https://docs.lsfusion.org/Events) mechanism, it is possible to perform certain [actions](https://docs.lsfusion.org/Actions/) upon the occurrence of given conditions.

Thus, when using lsFusion platform, most of the logic is not set in a sequence of commands, but as a specification of the solution to the problem. That is, the expected result is described, but not how to get it. This approach is called declarative, and has several advantages over the classic imperative.

## Language
Since the platform paradigm differs significantly from existing approaches, a specialized language was created to specify the logic. SQL-like syntax with keywords instead of symbols was chosen to lower the entry threshold into development.

The application logic is specified in the form of flat text files called [modules](https://docs.lsfusion.org/Modules/). These files contain the source code in an internal language. Each module can simultaneously contain declarations of classes and properties as well as forms, events, constraints, designs, and so on. Dependencies can be specified between modules. The source code can only use elements from the modules it depends on (including recursively).

Here are few examples :

![Classes and Primary Properties](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vd7lrzu2x3bn4mhbbx6c.png)

![Computed Properties](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxthdnn2odkyepox4xob.png)

![Actions and Events](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lx5c9m0wn1l3c16xdrfq.png)


![Forms](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/49rmqi0b2jz55rw10790.png)

More different examples of language syntax and use cases can be found [here](https://docs.lsfusion.org/Examples/).

## Architecture
lsFusion platform consists of two Java applications. A Java virtual machine must be installed in the operating system to run them.

The first is an application server that reads the program logic created by the developer from specific files. These files have the extension lsf, and contain the source code written in the internal language of the platform. They describe both the domain logic and the user interface. The project structure is as follows:

![MyCompany Project Structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ud91fex93u36g6kkqt47.png)

The second application is Apache Tomcat, with a web server deployed on it that runs the web application. It communicates with the application server through RMI requests using an internal protocol.

## How to develop
Applications in lsFusion are developed using a special [plugin](https://plugins.jetbrains.com/plugin/7601-lsfusion) for IntelliJ IDEA Community Edition. The plugin highlights syntax and errors, supports navigation and refactoring of source code.

The project structure on lsFusion is similar to that of any java application. The source code in the internal language acts as regular resource files that do not need to be compiled.

Due to the fact that the platform is based on Java and the source code has a flat text structure, you can use Git, Maven, and connect external Java classes and libraries to solve highly specialized problems.

## How it works
The relational DBMS PostgreSQL is used as a data storage system.

When the application server starts, the platform reads the system logic from the required modules and synchronizes the database structure with it. The user interface is automatically generated based on the specified forms.

Based on the lsFusion code, the platform automatically generates all SQL queries to read and write data without using any ORM patterns. Thus, almost all calculations are done in PostgreSQL instead of on the application server.

Changes made within a [session](https://docs.lsfusion.org/Change_sessions/) (e.g. when a user edits data on a form) are written to temporary tables. At the moment of saving session changes (e.g., when Save button is pressed) a transaction is started, events are executed, and changes are written to the database.

A distinctive feature of the lsFusion platform is that you can set [MATERIALIZED](https://docs.lsfusion.org/Materializations/) flag for any calculated property. A separate field is created for such a property in the table, which is automatically recalculated when the data on which it depends changes. At the same time, when calculating the values of dependent properties, the already calculated value from this field will be used. Thus you can easily balance the load on the database for writing and reading without changing the logic of the system. This feature is similar to [Materialized View with Fast Refresh](https://docs.oracle.com/database/121/DWHSG/refresh.htm#DWHSG8361) in Oracle only without any restrictions.

## Who can develop
The complexity of development in lsFusion is slightly higher than development in SQL, but much lower than in the classical general-purpose programming languages. The developer does not need to manually manage the memory, locks, transactions, the interaction between client and server, or application server and database. All of this is done automatically by the platform based on logic defined in a single, uniform language.

This high-level approach greatly reduces the entry threshold into application development. As a result, applications can be created by people without any programming experience. One week is enough for a basic study of the lsFusion platform, and in a month a developer can already create rather complicated applications. This is achieved due to the fact that the platform operates with a small number of abstractions, on the basis of which you can set almost any business logic. A developer just needs to learn how to define classes (entities), build properties using a few basic operators, and assemble forms from them.

## Features
### Object Oriented Programming
The lsFusion platform supports multiple class inheritance and polymorphism over several parameters. For example :

![Polymorphism over several parameters](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lxffo2owaqforhzyihme.png)

The declaration of an abstract property and its implementation can reside in different modules. This makes it possible to develop a system with a Low Coupling / High Cohesion architecture.

### Print forms
Print forms, text documents and spreadsheets are [generated](https://docs.lsfusion.org/Print_view/) using the JasperReports library. The platform can automatically generate complex structure of reports and subreports, and the developer only needs to adjust the arrangement of elements visually using JasperSoft Studio.

### API
The platform supports sending and receiving requests via [HTTP protocol](https://docs.lsfusion.org/How-to_Interaction_via_HTTP_protocol/). Combined with the built-in mechanism for [exporting and importing](https://docs.lsfusion.org/How-to_Working_with_external_formats/) JSON/XML files it’s easy to interact with any external systems.

Extension
If the task can not be solved by the standard functionality of the platform, you can use the underlying programming languages. In particular, you can create properties which calculations are implemented in [PL/pgSQL](https://docs.lsfusion.org/FORMULA_operator/) language, which are then built into SQL queries. [Using Java](https://docs.lsfusion.org/How-to_INTERNAL/) you can create highly specialized actions. With JavaScript you can create custom visual elements for displaying [properties](https://docs.lsfusion.org/How-to_Custom_components_properties/) and [objects](https://docs.lsfusion.org/How-to_Custom_components_objects/).

## Interface
In any table in a form the user can sort and select rows, hide columns and change their order. Filtered data from any table can be easily exported into spreadsheets with a single button. Navigation through the table rows is implemented as “infinite scrolling”.

In addition to changing the value of any cell, the user can change values in all records using the group editing mechanism. Pasting into any table from the clipboard is also supported.


![Interface example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdtp2us4dd6t2mzmcfbb.png)

Pivoting mode is automatically available in each table of the form, which allows user to group data and build diagrams in any slice on their own.

![Pivoting example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/51naaz1p5oatle870ehk.png)

## First steps
First you need to install lsFusion on your local computer. Under Windows, there is an [installer](https://docs.lsfusion.org/Development_auto/) that will install PostgreSQL, Java, IntelliJ IDEA, and the platform itself on the computer. Then you need to create an empty [lsFusion project](https://docs.lsfusion.org/IDE/) in IDEA.

The best way to start studying lsFusion is to use the examples described in the [How-to section](https://docs.lsfusion.org/How-to/) and two simple examples: [Score table](https://docs.lsfusion.org/Score_table/) and [Materials Management](https://docs.lsfusion.org/Materials_management/).

You can then explore the source code for [MyCompany](https://github.com/lsfusion-solutions/mycompany), which implements the basic logic of a simple ERP system. This solution is distributed under the Apache-2.0 license, and can be used as a basis for developing your own system.

You can view the demo version at: [https://demo.lsfusion.org/mycompany](https://demo.lsfusion.org/mycompany).

## Support
The lsFusion platform has been developed for 12 years by a distributed team of programmers from different countries. During this time, a large number of applications based on it were implemented, from simple applications with a few forms to complex ERP systems with thousands of users and processes. The development of the platform is funded by companies creating their own commercial solutions based on it.

lsFusion is suitable for application development by individual programmers as well as large teams, due to its high declarability, OOP support and the possibility of using Git. The license enables both in-house application development and commercial products based on it.