QR Code Generator
This project is the backend of a QR Code Generator built using Java and AWS services
README
QR Code Generator
A Spring Boot application that generates QR codes and stores them in AWS S3. This project demonstrates the integration of Google's ZXing library for QR code generation and AWS S3 for storage.
Table of Contents
How to Use
This section provides comprehensive instructions for setting up and running the QR Code Generator application.
Prerequisites
- Java 21 JDK
- Maven
- Docker
- AWS Account with S3 access
- AWS CLI configured with appropriate credentials
Environment Variables
Create a .env file in the project root with the following variables:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=your_region
AWS_BUCKET_NAME=your_bucket_name
Running the Application
Local Development
- Create the
.envfile as described above - Build the project:
mvn clean package - Run the application:
mvn spring-boot:run
Docker Deployment
-
Build the Docker image:
docker build -t qrcode-generator:X.X .Remember to replace the version and image name if you want
-
Run the container:
docker run --env-file .env -p 8080:8080 qrcode-generator:X.X
Remember to replace the .env file path to the path of your environment file that you created.
AWS S3 Configuration
- Create an S3 bucket in your AWS account
- Update the
AWS_BUCKET_NAMEin your.envfile or Docker run command - Ensure your AWS credentials have appropriate permissions to access the S3 bucket
Application Flow
Note: This diagram was built on Mermaid Online Editor.
API Endpoints
POST /qrcode
Generate a QR code from the provided text and store it in AWS S3. The QR code will be generated as a PNG image with dimensions of 200x200 pixels.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
text |
required | string | The text content to be encoded in the QR code. This can be any string value that you want to convert into a QR code. |
Response
{
"url": "https://your-bucket.s3.your-region.amazonaws.com/random-uuid"
}
Error Response
If an error occurs during QR code generation or S3 upload, the API will return a 500 Internal Server Error.
Example Usage
curl -X POST http://localhost:8080/qrcode \
-H "Content-Type: application/json" \
-d '{"text": "https://example.com"}'
License
This project is licensed under the MIT License - see the LICENSE file for details.
