This project is a QR Code Generator application built using FastAPI. It provides a REST API for generating and retrieving QR codes, while storing metadata in a PostgreSQL database and utilizing Redis for caching. Additionally, it employs a Celery worker to manage expired QR codes.
- Generate QR codes using the
qrcodelibrary. - Store QR code metadata in a PostgreSQL database.
- Cache QR code data using Redis for improved performance.
- Background task management with Celery for cleaning up expired QR codes.
qr-code-generator-app
├── src
│ ├── api
│ │ ├── __init__.py
│ │ ├── main.py
│ │ ├── routes
│ │ │ └── qr_code.py
│ ├── services
│ │ ├── __init__.py
│ │ ├── qr_code_service.py
│ ├── db
│ │ ├── __init__.py
│ │ ├── models.py
│ │ ├── session.py
│ ├── cache
│ │ ├── __init__.py
│ │ ├── redis_cache.py
│ ├── worker
│ │ ├── __init__.py
│ │ ├── celery_worker.py
│ ├── utils
│ │ ├── __init__.py
│ │ ├── config.py
│ └── types
│ └── index.py
├── alembic
│ ├── env.py
│ ├── script.py.mako
│ └── versions
│ └── README
├── celeryconfig.py
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
├── alembic.ini
└── README.md
-
Clone the repository:
git clone <repository-url> cd qr-code-generator-app -
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` -
Install the required dependencies:
pip install -r requirements.txt -
Set up the database:
- Update the database configuration in
src/utils/config.py. - Run the Alembic migrations:
alembic upgrade head
- Update the database configuration in
-
Start the Redis server and Celery worker:
redis-server celery -A src.worker.celery_worker worker --loglevel=info -
Run the FastAPI application:
uvicorn src.api.main:app --reload
- Generate a QR Code: Send a POST request to
/qr-code/generatewith the necessary data. - Retrieve a QR Code: Send a GET request to
/qr-code/{id}to get the QR code by its ID.
This project is licensed under the MIT License. See the LICENSE file for more details.