Todolist aplication made with Python's FastAPI framework and Hexagonal Architecture.
This is a test repository for the purpose of testing FastAPI framework capabilities with DDD, functional programming and Hexagonal (or Ports and Adapters) arquitecture
This project is comprised of the following languages and libraries:
- Language: Python 3.8+
- Package management: Poetry
- Web framework: FastAPI
- Production web server: Uvicorn
- Relational database: Postgres
- Relational database async support: databases
- Relational database migrations: Alembic
- Relational ORM: SQLAlchemy
- Functional programming utilities: Toolz
- Password hashing utilities: Passlib
- Data parsing and validation: Pydantic
- Testing: Pytest
- Linter: Flake8
- Static type checker: Mypy
- Formatter: Black
Auxiliary libraries were omitted but can be found in the pyproject file.
To start development it is recommended to have these utilities installed in a local development machine:
For better development experience, it is recommended these tools:
Be certain that you are installing Poetry with the correct version of Python in your machine, that is, Python 3.
This project is already configured with VS Code IDE in mind. To have access of tools and code analysis utilities, you only need to install the project dependencies locally with poetry install
and to open the project workspace file on VS Code.
The IDE should be automatically configured with standard rules and options for optimal development experience.
To run the API in development mode, follow these steps:
- Start a container with:
plis start --service-ports app ash
- Inside the container run:
poetry install
- Start the web server with:
poetry run web_server
- Seed DB data with:
poetry run seeder
- Run migrations with:
alembic upgrade head
- Test the API with:
pytest
- Check code style with:
black --check todolist
- Format code with:
black todolist
- Lint the code with:
flake8 todolist tests
- Run static analysis with:
mypy job_form_api tests
A configured instance of PGAdmin for database monitoring and management is provided by default.
To start it, run: plis start pgadmin
Flake8 is the tool of choice for linting. It is configured to warn about code problems, complexity problems, common bugs and to help developers write better code.
Mypy is the tool of choice for static type checking. This project adopts gradual typing as the metodology for code typing. The rules of Mypy will be updated periodically to ensure that the entire code base is typed and consistent.
Black is the tool of choice for formating and code style guide. Black is an uncompromising formatter for Python code, that is, no code style discussions are necessary, the tool is always correct.
Linter and static type checking rules can be discussed and reviewed with the entire team. Any merge request that tries to change these rules without consent is automatically rejected and closed.