https://github.com/dejatori/store-api
Complete REST API built with FastAPI and Python 3.11. Features JWT authentication, background task processing with Celery and Redis, automatic Swagger documentation, and unit tests. Implements post creation, image generation, file uploads to B2, and email notifications.
https://github.com/dejatori/store-api
async backend background-tasks celery docker fastapi jwt-authentication microservices pydantic pylint python redis rest-api sqlalchemy testing
Last synced: 2 months ago
JSON representation
Complete REST API built with FastAPI and Python 3.11. Features JWT authentication, background task processing with Celery and Redis, automatic Swagger documentation, and unit tests. Implements post creation, image generation, file uploads to B2, and email notifications.
- Host: GitHub
- URL: https://github.com/dejatori/store-api
- Owner: Dejatori
- License: mit
- Created: 2025-04-14T05:08:17.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-09T22:36:36.000Z (about 1 year ago)
- Last Synced: 2025-06-03T20:15:13.622Z (about 1 year ago)
- Topics: async, backend, background-tasks, celery, docker, fastapi, jwt-authentication, microservices, pydantic, pylint, python, redis, rest-api, sqlalchemy, testing
- Language: Python
- Homepage:
- Size: 6.32 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ Mastering REST APIs with FastAPI
[](https://www.python.org/downloads/)
[](https://fastapi.tiangolo.com/)
[](https://opensource.org/licenses/MIT)
Project from the "Mastering REST APIs with FastAPI" course by Packt, edited by David Toscano.
## ๐ Contents
- [Requirements](#requirements)
- [Installation](#installation)
- [Useful Commands](#useful-commands)
- [Project Structure](#project-structure)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)
## ๐ง Requirements
- Python 3.11
- Redis (for background tasks)
- Docker and Docker Compose (optional)
## ๐ป Installation
1. Clone this repository:
```bash
git clone https://github.com/Dejatori/Store-API.git
cd Store-API
```
2. Create a virtual environment and install dependencies:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
```
```bash
# Alternative with Conda
conda create --name fastapi python=3.11
conda activate fastapi
conda install --file requirements.txt
conda install --file requirements-dev.txt
```
3. Start the server:
```bash
uvicorn storeapi.main:app --reload
```
## ๐ ๏ธ Useful Commands
### ๐งน Code Cleaning and Formatting
```bash
# Ruff linter and automatic formatting
ruff check --select I --fix .
ruff format .
# Black formatting
black .
# Isort import sorting
isort .
```
### ๐ Server Execution
```bash
uvicorn storeapi.main:app --reload
```
### ๐ Redis Management
#### Windows (using Docker)
```bash
# 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
```
#### Linux
```bash
# 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 stop
```
### ๐ Celery for Background Tasks
```bash
celery -A storeapi.celery_app worker --pool=solo --loglevel=INFO
```
## ๐ Project Structure
```
storeapi/
โโโ 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
```
## ๐ Documentation
The API documentation is available at the following routes once you start the server:
- ๐ **Swagger UI**: [http://localhost:8000/docs](http://localhost:8000/docs)
- ๐ **ReDoc**: [http://localhost:8000/redoc](http://localhost:8000/redoc)
Documentation is also available in the project's `docs/` directory.
- ๐ **Project documentation in HTML**: [docs/build/html/index.html](docs/build/html/index.html)
- ๐ **Project documentation in PDF**: [docs/build/latex/StoreAPI.pdf](docs/build/latex/StoreAPI.pdf)
## ๐ค Contributing
Contributions are welcome. Please follow these steps:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add an amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## ๐ License
This project is licensed under the terms of the MIT license. See the `LICENSE` file for more details.