Skip to content

nikolamaric/table_builder

Repository files navigation

Dynamic Table Builder application

The goal is to build a simple backend for a dynamic table builder app, where the user can build tables dynamically. The app has the following endpoints:

Request type Endpoint Action
POST /api/table Generate dynamic Django model based on user provided fields types and titles. The field type can be a string, number, or Boolean.
PUT /api/table/:id This end point allows the user to update the structure of dynamically generated model.
POST /api/table/:id/row Allows the user to add rows to the dynamically generated model while respecting the model schema.
GET /api/table/:id/rows Get all the rows in the dynamically generated model.

How to run it?

Fork the repo, position to the root and do the following steps:

  • Build the docker containers: docker-compose build

  • Run the docker containers: docker-compose up -d

And you are ready to go! Everything is running on: localhost:8000. So it means that if you want to create a new dynamic table, you should send POST on: http://localhost:8000/api/table.

Do the same for other endpoints too.

API Endpoints:

POST /api/table

(Create new table)

Request body:

{
  "name": "Table 1",
  "fields": {
    "name": "str",
    "age": "int",
    "is_active": "bool"
  }
}

PUT /api/table/:id

(Update table - only new fields will be added, existing fields will not be updated.)

Request body:

{
  "fields": {
    "name": "str",
    "age": "int",
    "email": "str" // new field
  }
}

POST /api/table/:id/row

(Create new row)

Request body:

{
  "name": "John",
  "age": 25,
  "is_active": true,
  "email": "[email protected]"
}

GET /api/table/:id/rows

(Get all rows)

Response body:

[
  {
    "id": 1,
    "name": "John",
    "age": 25,
    "is_active": true,
    "email": "[email protected]"
  }
]

Releases

No releases published

Packages

No packages published