Skip to content

AutoDLA WEB

You can connect AutoDLA with the web framework of your choosing to automatically build AutoDLA WEB, a robust Data Admin Panel

Setup

For this example we are going to use FastAPI

pip install autodla[fastapi] #install dependency

And the next schema:

from autodla import Object, primary_key
from autodla.dbs import PostgresDB, MemoryDB

class User(Object):
    id: primary_key = primary_key.auto_increment()
    name: str
    age: int

class Group(Object):
    id: primary_key = primary_key.auto_increment()
    group_name: str
    participants: list[User]

# MemoryDB works only in-memory. PostgresDB keeps data in SQLite and
# synchronizes with PostgreSQL.
db = MemoryDB()  # or PostgresDB()
db.attach([User, Group])
We create the data:
users = []
for i in range(2):
    users.append(User.new(
        name=DataGenerator.name(),
        age=DataGenerator.age()
    ))
group = Group.new(
    group_name='Group 1',
    participants=users
)

Connection

To connect AutoDLA with the web framework, you just need to use the function connnect_db:

# default fastAPI app creation
from fastapi import FastAPI
app = FastAPI()

# connect it
from autodla.connectors.fastapi import connect_db
connnect_db(app, db)
Done! now AutoDLA automatically configured the FastAPI app to be able to use it.

Usage

Endpoints

If you go to localhost:8000/docs (the default FastAPI documentation endpoint) you'll see that AutoDLA automatically generated CRUD endpoints for each model:

FastAPI endpoints created by AutoDLA

These endpoints are secured using OAuth2. by default the user and pasword are as follows:

AUTODLAWEB_USER=autodla
AUTODLAWEB_PASSWORD=password
you can setup this with changing the respective enviroment variables

Admin Panel

If you enter to localhost:8000/autodla-web you are going to see the admin authentication panel, use the previously mentioned credentials to enter

AutoDLA WEB Auth Page

Once you are authenticated, you'll have 2 tabs to work with:

Schema

This is the landing tab for the tool, in here you can see a canvas with the visualization of the defined schemas and their relationships

AutoDLA WEB Schema Page

Objects

This is your working tab, inside there is a sub-tab for each Model

AutoDLA WEB Objects Page

Let's work with Group to show the tool capabilities.

When you open the model sub-tab you can see a table, this contains all currently active Objects

AutoDLA WEB Objects Page with Group sub-tab open

If you click on a row of the table, you open the details specific object, inside the object details you can modify it or delete it, apart of seeing the complete history of it.

AutoDLA WEB Objects Page with Group sub-tab open, seeing the details of an object

Creating Objects

If you click the New button, a new window will be opened, allowing you to create a new instance of the Object you selected

AutoDLA WEB Objects Page with Group sub-tab open, New object button

AutoDLA WEB Objects Page with Group sub-tab open, Create object window

The update window (accessed via the object details) is similar in structure to this window, the only difference being that the data is automatically selected with the last available data

Nested Selection

If you need to select a different object for a field (in this example case, you need to select a User for the participants field), you can click the input field and a selection window for the required object is going to be opened, with a list of currently active objects, once you select one, its going to automatically insert it into the input field.

AutoDLA WEB Objects Page with Group sub-tab open, Create object window, User object selection window