DEV Community

Franck Blettner
Franck Blettner

Posted on

A Generic Backend for All Your Apps

In modern application development, having a reusable and scalable backend is crucial for efficiency and maintainability. With the Liberty Framework, you can create a backend that serves multiple applications seamlessly. This guide will walk you through setting up your backend and integrating it with your frontend.

Step 1: Install the Framework

You can install the Liberty Framework using either Python or Docker, depending on your preference.

Requirements

A PostgreSQL 16 database is required. You can either:

  • Create a Docker image based on postgres:16, or
  • Install PostgreSQL 16 directly on your host system.

Install with Python

pip install liberty-framework
Enter fullscreen mode Exit fullscreen mode

After installation, you can start the framework with:

liberty-start
Enter fullscreen mode Exit fullscreen mode

Install with Docker

docker pull ghcr.io/fblettner/liberty-framework:latest
docker run -p 8000:8000 ghcr.io/fblettner/liberty-framework
Enter fullscreen mode Exit fullscreen mode

Installation URL

  • Setup: http://<your_host>:<your_port>/setup Follow the wizard to configure your backend

Image description

Image description

Image description

Step 2: Configure the framework

  • Application: http://<your_host>:<your_port>

Connect to liberty with admin account and password set during the installation

Create a New Application

  1. Go to the Menu.
  2. Navigate to Settings > Applications.
  3. Click Create a New Application.
  4. Fill in the necessary Properties.
  5. Configure the Connection settings.
  6. Use the UI to set your application theme

Image description

Image description

Create the Database

After saving the new application you can create the database repository using button Create Database

Create a User

Right click on the application and select Display Users
Create a new user with the required permissions.

Image description

Image description

Step 3: Configure your Backend

Disconnect and reconnect to the BACKEND.

  1. Go to the Menu.
  2. Click on Framework to display the development menus
  3. Create a new applications as you did in the first step for your database (Database that contains your application data)

Set Up Queries

Now that your backend is configured, you can create database queries.

  1. Go to the Menu.
  2. Queries Builder
  3. Create your queries

Create query is easy, you will describe your query, add method for SELECT, UPDATE, INSERT or DELETE depending on your database type, and set your SQL

Image description

Image description

Image description

That's it ! You are now able to use your query in your frontend or simply as an API call.

Step 4: Usage example

Encrypt your password

Endpoint: POST /api/fmw/encrypt

{
    "plain_text": "your_password"
}
Enter fullscreen mode Exit fullscreen mode

Get a token for your API user / password

Endpoint: POST /api/auth/token?pool=backend&mode=session&type=database

{
  "user": "admin",
  "password": "return_from_encrypt_endpoint"
}
Enter fullscreen mode Exit fullscreen mode

Call your query

Endpoint: GET /api/db/query?source=query&type=table&pool=backend&mode=session&query=query_id

{
    "items": [
        {
            "ROW_ID": 1,
            "USR_APPS_ID": 10,
            "USR_ID": "APPLEAD",
            "USR_NAME": "Financial/Distribution Company",
            "USR_REGISTRATION": "430788490",
            "USR_STATUS": null,
            "USR_DT_LOGIN": null,
            "USR_DT_CREATION": null,
            "USR_PRIVILEGED": "N",
            "USR_DT_REFRESH": "2025-02-27",
            "USR_UKID": 2
        },
        {
            "ROW_ID": 2,
            "USR_APPS_ID": 10,
            "USR_ID": "CRPCTL",
            "USR_NAME": null,
            "USR_REGISTRATION": null,
            "USR_STATUS": null,
            "USR_DT_LOGIN": null,
            "USR_DT_CREATION": null,
            "USR_PRIVILEGED": "N",
            "USR_DT_REFRESH": "2025-02-27",
            "USR_UKID": 2
        },
        {
            "ROW_ID": 3,
            "USR_APPS_ID": 10,
            "USR_ID": "CRPDTA",
            "USR_NAME": null,
            "USR_REGISTRATION": null,
            "USR_STATUS": null,
            "USR_DT_LOGIN": null,
            "USR_DT_CREATION": null,
            "USR_PRIVILEGED": "N",
            "USR_DT_REFRESH": "2025-02-27",
            "USR_UKID": 2
        }
    ],
    "status": "success",
    "metadata": [
        {
            "headerName": "ROW_ID",
            "field": "ROW_ID",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_APPS_ID",
            "field": "USR_APPS_ID",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_ID",
            "field": "USR_ID",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_NAME",
            "field": "USR_NAME",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_REGISTRATION",
            "field": "USR_REGISTRATION",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_STATUS",
            "field": "USR_STATUS",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_DT_LOGIN",
            "field": "USR_DT_LOGIN",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_DT_CREATION",
            "field": "USR_DT_CREATION",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_PRIVILEGED",
            "field": "USR_PRIVILEGED",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_DT_REFRESH",
            "field": "USR_DT_REFRESH",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        },
        {
            "headerName": "USR_UKID",
            "field": "USR_UKID",
            "type": "text",
            "operator": "like",
            "rules": null,
            "rules_values": null,
            "default": null
        }
    ],
    "hasMore": false,
    "limit": 1000,
    "offset": 0,
    "count": 3
}
Enter fullscreen mode Exit fullscreen mode

The Added Value of Liberty Framework

The Liberty Framework provides a structured and scalable backend solution that simplifies application development. It allows you to create and manage applications, configure databases, and delivers API endpoints for all your queries. The flexibility of Liberty Framework enables seamless integration with any frontend, whether you choose to use Liberty-Core or any other custom application. Its API-first approach ensures that your backend remains reusable, scalable, and adaptable to various use cases, making it an excellent choice for modern application development.

Instead of hardcoding your queries, you can manage them through a database with authentication and JWT security to prevent SQL injection.

Edit:
A socket dashboard is also available to display current connection to the database

Image description

Useful Links

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post