Backend Generator#

class besser.generators.backend.backend_generator.BackendGenerator(model: DomainModel, http_methods: list = None, nested_creations: bool = False, output_dir: str = None)[source]#

Bases: GeneratorInterface

BackendGenerator is a class that implements the GeneratorInterface and is responsible for generating a Backend model code with a REST API using FAST API framework, SQLAlchemy and a Pydantic model based on the input B-UML model .

Parameters:
  • model (DomainModel) – An instance of the DomainModel class representing the B-UML model.

  • http_methods (list, optional) – A list of HTTP methods to be used in the REST API. Defaults to All.

  • nested_creations (bool, optional) – This parameter specifies how entities are linked in the API request. If set to True, the API expects identifiers and links entities based on these IDs. If set to False, the API handles the creation of new entities based on the data provided in the request. Defaults to True

  • output_dir (str, optional) – The output directory where the generated code will be saved. Defaults to None.

_abc_impl = <_abc._abc_data object>#
generate()[source]#

Generates Backend model code based on the provided B-UML model and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output_backend folder.

Returns:

None, but store the generated code as files main_api.py, sql_alchemy.py and pydantic_classes.py