Currently, supports python 3.12 and higher.
- Pull & install the project from github (pypi will be added in the future).
- Install project dependencies and extras (e.g. with poetry
poetry install --all-extras
)- this will add
gendalf
CLI to virtual environment, CLI code is here.
- this will add
- add
@entrypoint
decorators to top-level classes in your domain layer code ( e.g. greeter) - enter the root directory of your project (e.g. the directory of this readme file)
- enter the virtual env (e.g.
poetry shell
) - you can check which entrypoints & methods
gendalf
sees withgendalf --ignore-module-on-import-error src show
- run codegen with
gendalf gen src fastapi --ignore-module-on-import-error
(e.g. this will generatesrc/api
directory with python modules for this example project) - write server assembling code (e.g. greeter server)
- write client top-level code (e.g. greeter client)
- run server & client (don't forget to add src to python path, e.g. via env
PYTHONPATH=src
)PYTHONPATH=src poetry run uvicorn --factory my_service.test_server:create_app
PYTHONPATH=src poetry run python test_client.py
What’s Generated:
- api/models.py: Pydantic models for requests and responses that mirror the domain objects.
- api/client.py: Client classes with async methods, ready to make API calls with appropriate typings for request and response data.
- api/server.py: Server handler classes, which include data serialization and domain logic invocation.
The generated code is complete, with no need for additional modifications.