The eight queens puzzle The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal. There are 92 solutions. The problem was first posed in the mid-19th century. In the modern era, it is often used as an example problem for various computer programming techniques.
- Develop the 8 queens algorithm in python, the project uses Python version 3.11.
- Use FastApi to build the api.
- Use ORM as flyway and make migrations.
- Store the solutions in postgres
- Implement actions for the connection of postgres and flyway
- Return answers to solutions with pagination
- Docker y Docker Compose
- python
- venv
- postman
- visual studio code
hight-queens-puzzle-python
├── .cz.toml
@@ -38,7 +34,6 @@ hight-queens-puzzle-python
├── src
│ ├── app.py
│ ├── application
│ │ └── queens
│ │ └── eight_queens.py
│ ├── domain
@@ -48,15 +43,21 @@ hight-queens-puzzle-python
│ │ └── repositories
│ │ └── eight_queens_repository.py
│ └── infrastructure
│ │ └── entity_manager.py
│ └── utils
│ └── error_messages.py
│ └── serealize_queen.py
│ └── success_messages.py
└── tests
└── test_app.py
└── test_eight_queens.py
└── test_eight_repository.py
└── test_entity_manager.py
- Dockerfile: file with the configuration to create the image of the worker service
- Makefile: file to facilitate the compilation of the containers
- docker-compose.yml: file with the configuration to start the worker service @@ -75,69 +76,54 @@ hight-queens-puzzle-python
- tests: folder to store the unit tests
- application: folder to store the tests service logic unit tests
- test_business.py: file with service logic unit tests
- utils: Folder that stores auxiliary functions
# If you are using python 3.11
# create python environment
make create-venv
# activate python environment
source venv/bin/activate
# disable python environment
deactivate
# install pip
make pip
# install dependencies
make install-
Makefile commands for: build, start, stop, restart, status, rebuild, logs, and bash
# To ensure all dependencies are correctly installed, especially uvicorn and fastapi. # Before doing make test run this command: export PYTHONPATH=$PYTHONPATH:$(pwd)/src make test-requirements # Build image make build # Start services with Docker Compose make up # Stop services make down # Delete volumes and images and rebuild the entire container make rebuild # Running tests with pytest make run-tests
-
Platforms to make http requests
- Postman
- Queens API
-
To obtain the data GET
-
To create data POST: http://localhost:8080/queens/
{
"n": 8,
"context": {
"email": "mir@mail.com"
}
}- Instructions for Configuring
pre-commitThis project uses pre-commit to automate the execution of Git hooks before making a commit. This ensures that quality tasks, such as code formatting, are performed before any changes are confirmed.
- Install dependencies:
pre-commitis installed automatically along with other libraries when you run:pip install -r requirements.txt
- Prepare changes: Add the modified files to the staging area using
git add . git add 'file'
- Make the commit: Use the command to create a standardized commit message with Commitizen
cz c cz commit
- Push the code: Send your changes to the remote repository using
git push origin "branch"
- By following these steps, you ensure that commit messages follow a standard format and that the code passes quality checks before being pushed.