This guide outlines the setup, development, and testing processes for the Sample Project, a Python RESTful application implementing the Hexagonal Architecture pattern. It leverages FastAPI and SQLAlchemy for the backend, and is containerized using Docker for easy development and deployment.
Before starting, ensure you have the following tools installed:
- Docker
- Docker Compose
- Poetry (Python package manager)
- Development is managed using Poetry. Docker containers are built using
requirements.txt
. Use the following command to updaterequirements.txt
for Docker images as needed:pip freeze --local > requirements.txt
-
Clone the Repository: Clone this project to your local machine.
-
Environment Variables: Copy
.env.example
to.env
and modify as necessary. This file includes important configurations, such as database connection details. -
Synchronize Dependencies: Run
poetry export -f requirements.txt --output requirements.txt --without-hashes
to ensurerequirements.txt
is up-to-date with project dependencies, excluding hashes. -
Start the Development Environment: Launch the development environment with Docker Compose by running
docker-compose up --build
.
Execute the built-in unit tests by running pytest
in the project's root directory.
To update project dependencies and synchronize the Docker environment:
- Update dependencies with
poetry update
. - Export the updated dependencies to
requirements.txt
usingpip freeze --local > requirements.txt
. - Rebuild and start the Docker environment with
docker-compose up --build
to apply the updates.