Project from the "Mastering REST APIs with FastAPI" course by Packt, edited by David Toscano.
- Python 3.11
- Redis (for background tasks)
- Docker and Docker Compose (optional)
-
Clone this repository:
git clone https://github.com/Dejatori/Store-API.git cd Store-API -
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt pip install -r requirements-dev.txt
# Alternative with Conda conda create --name fastapi python=3.11 conda activate fastapi conda install --file requirements.txt conda install --file requirements-dev.txt -
Start the server:
uvicorn storeapi.main:app --reload
# Ruff linter and automatic formatting
ruff check --select I --fix .
ruff format .
# Black formatting
black .
# Isort import sorting
isort .uvicorn storeapi.main:app --reload# Start Redis server
docker-compose up -d
# Check running containers
docker ps
# Stop services
docker-compose stop
# Restart services
docker-compose restart
# Remove containers and network
docker-compose down# Start Redis server
sudo service redis-server start
# Check status
redis-cli ping
sudo service redis-server status
# Restart server
sudo service redis-server restart
# Stop server
sudo service redis-server stopcelery -A storeapi.celery_app worker --pool=solo --loglevel=INFOstoreapi/
├── database/ # Database configuration and models
├── models/ # Pydantic models for data validation
├── routers/ # API endpoints
├── security/ # Authentication and authorization
├── tasks/ # Background tasks with Celery
└── main.py # Application entry point
The API documentation is available at the following routes once you start the server:
- 📝 Swagger UI: http://localhost:8000/docs
- 📘 ReDoc: http://localhost:8000/redoc
Documentation is also available in the project's docs/ directory.
- 📄 Project documentation in HTML: docs/build/html/index.html
- 📄 Project documentation in PDF: docs/build/latex/StoreAPI.pdf
Contributions are welcome. Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add an amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the terms of the MIT license. See the LICENSE file for more details.