The goal of this project is to create a sudoku API using FastAPI. We could have developed a sudoku solver manually, but we decided to use a great module called PySudoku to focus on the API development and deployment.
We highly reccomend for new developers to try to develop their own sudoku solver, it's a great exercise! You will learn great concepts like backtracking and recursion. There are lots of resources online.
- Sudoku Solver Library: PySudoku:
- Uses recursive backtracking to solve sudoku puzzles.
- Backend: FastAPI:
- FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
- Deployment: Docker, Docker Compose:
- Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.
- Docker Compose is a tool for defining and running multi-container Docker applications.
- Development Tools:
- Poetry:
- Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
- Pre-commit:
- A framework for managing and maintaining multi-language pre-commit hooks.
- Black:
- The uncompromising Python code formatter.
- Isort:
- A Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.
- Ruff:
- Python linter written in Rust.
- Pytest:
- The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.
- Poetry:
- Docker
- Docker Compose
- Clone the repository
- Run
docker-compose up --build
- Go to
http://localhost:8000/docs
to see the API documentation - Enjoy!
FastAPI provides a great documentation interface. You can access it by going to http://localhost:8000/docs
after running the application.
To run the tests, you can run docker-compose exec server pytest
after running the application.
.
├── Dockerfile # Docker configuration
├── LICENSE # MIT License
├── README.md # This file
├── docker-compose.yml # Docker Compose configuration
├── pyproject.toml # Poetry configuration
├── .pre-commit-config.yaml # Pre-commit configuration
├── main.py # FastAPI Application
├── toolbox.py # Typer CLI Application
├── .github # Github Actions
└── test.py # Tests
main.py
contains the FastAPI application with the endpoints, schemas and the business logic. It's only 200 lines of code! We kept everything in one file to make it easier to understand for new developers.toolbox.py
contains the Typer CLI application. We used Typer to showcase PySudoku abilities.test.py
contains the tests for the FastAPI application. We used Pytest to write the tests. We have 100% coverage.Dockerfile
contains the Docker configuration for the application.docker-compose.yml
contains the Docker Compose configuration for the application.pyproject.toml
contains the Poetry configuration for the application..pre-commit-config.yaml
contains the Pre-commit configuration for the application.LICENSE
contains the MIT License for the application.README.md
contains the README for the application.
This project is licensed under the MIT License - see the LICENSE file for details.
It's an open source project mainly for educational purposes. Feel free to use it however you want.