Layers of Code

The code of DSO-API has the following layers:

digraph foo {

   drf [label="Django REST Framework"]
   rest_framework_dso [label="rest_framework_dso"]
   dynamic [label="dso_api.dynamic_api"]
   schematools_contrib_django [label="schematools.contrib.django"]

   schematools_contrib_django -> dynamic
   drf -> rest_framework_dso
   rest_framework_dso -> dynamic
}

The dso_api.dynamic_api provides the dynamic API. For this, it uses the datasets definitions that schematools.contrib.django provides.

REST API Logic

The REST API code is based on Django REST Framework. There are 3 layers:

  • Generic REST Framework

  • Generic DSO compatibility

  • Application choices (like blending Amsterdam Schema into API policies).

The generic DSO compatibility layer is implemented in the rest_framework_dso package, so it could be moved out to a official PyPI package. This implements most features like embedding or the ?_fields=... parameter.

The specific logic to generate the API is implemented in the dso_api.dynamic_api package. This involves transforming an Amsterdam Schema / DynamicModel into the serializer layout, applying policies such as authorization/time-travel filtering based on schema data.

The Schematools Package

The schematools package fulfills a special role. It contains all fundamental parts that can be shared with other applications. Specifically of interest are:

The schematools package also provides a CLI: schema with various useful command-line tools such as:

  • schema import geojson ...

  • schema import ndjson ...

  • schema introspect db ...

  • schema introspect geojson ...

More information can be found using schema --help and checking the README file.