Skip to content

Repository files navigation

🚀 QBar

QBar is a lightweight Spring Boot service for generating QR codes and barcodes.
It supports Redis caching to improve performance for repeated requests.
The service exposes a REST API that returns PNG images.

✨ Features

  • Generate QR codes and all ZXing-supported barcode formats (CODE 128, EAN, UPC, etc.)
  • Configurable width and height
  • Redis caching to speed up repeated requests
  • Ready to run in Docker
  • Configurable via Spring profiles (application.properties and application-docker.properties)
  • Uses ImageUtils for optimized image-to-byte conversion

🛠️ Technologies Used

  • Java 21
  • Spring Boot 3.5
  • Spring Cache + Redis
  • ZXing (QR and barcode generation)
  • Docker / Docker Compose

🏁 Getting Started

Prerequisites

  • Docker & Docker Compose
  • Java 21 (optional if running outside Docker)
  • Maven (optional if running outside Docker)

🐳 Run with Docker

# Build and start services
docker-compose up --build

📬 API Endpoint

Generate QR / Barcode

POST /api/codes/generate

Content-Type: application/json
Accept: image/png

📝 Request JSON

{
  "text": "HelloWorld",
  "type": "QR",
  "width": 300,
  "height": 300
}
  • text ✏️: The data you want to encode.
  • type 🔢: Barcode type (QR, CODE_128, EAN_13, UPC_A, etc.)
  • width 📏: Width of the image in pixels.
  • height 📐: Height of the image in pixels.

🖼️ Response

Content-Type: image/png
Body: PNG image of the generated QR code or barcode.

Example with cURL:

curl -X POST http://localhost:8081/api/codes/generate \
     -H "Content-Type: application/json" \
     -H "Accept: image/png" \
     -d '{"text":"HelloWorld","type":"QR","width":300,"height":300}' \
     --output qr.png

The generated QR code image will be saved as qr.png ✅

🔢 Example for Code 128 Barcode

{
  "text": "1234567890",
  "type": "CODE_128",
  "width": 400,
  "height": 150
}

Saves the generated barcode as barcode.png using the same cURL command with updated JSON.


🛣️ Roadmap

  • Support additional barcode formats (e.g., EAN, UPC)
  • Add custom colors and logo overlays for QR codes 🎨
  • Implement rate limiting to avoid abuse 🚦
  • Add API key authentication for secure access 🔑
  • Provide online frontend for quick QR/barcode generation 🌐
  • Enable dynamic TTL for cached codes ⏳
  • Add unit & integration tests for all endpoints ✅

About

Spring Boot REST API for generating QR codes and barcodes with ZXing, Redis caching, and containerized deployment.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages