Skip to content

feat:[BACKEND] Implement QR Code / Barcode Generator Module #296#334

Merged
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom
OlufunbiIK:feat/Implement-QR-Code-Barcode-Generator-Module-#296
Oct 2, 2025
Merged

feat:[BACKEND] Implement QR Code / Barcode Generator Module #296#334
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom
OlufunbiIK:feat/Implement-QR-Code-Barcode-Generator-Module-#296

Conversation

@OlufunbiIK
Copy link
Contributor

Title

Add QR/Barcode generation and retrieval for assets

Description

This PR introduces a new QR/Barcode module that allows each asset to have a unique QR code and barcode for physical tracking and scanning. The implementation provides the ability to generate, store, retrieve, and verify codes.

Key Changes

Added new columns to the Asset entity for storing QR and barcode data (qrCodeBase64, barcodeBase64, qrCodeFilename, barcodeFilename).

Created QrBarcodeService with methods to:

Generate QR codes as base64 data URLs.

Generate barcodes using bwip-js.

Persist base64 representations or save PNG files to disk.

Retrieve stored codes for a given asset.

Verify scanned payloads against existing assets.

Added QrBarcodeController with endpoints to:

Generate and store codes for an asset (POST /assets/:id/generate-code).

Retrieve stored codes as JSON (GET /assets/:id/codes).

Fetch QR or barcode images directly (GET /assets/:id/code/qr, GET /assets/:id/code/barcode).

Verify scanned payloads (GET /assets/verify?payload=...).

Created database migration to add new code-related columns to the assets table.

Integrated the new module into AppModule.

Expected Behavior

When an asset is created or updated, codes can be generated and stored via the API.

Codes are stored in the database as base64 strings, with optional file saving to disk.

Codes can be retrieved via dedicated endpoints.

Verification endpoint ensures scanned codes correspond to valid assets.

Notes

Images are currently stored as base64 in the database; this can be extended to cloud storage if needed.

QR codes embed a JSON payload containing the asset id and name.

Barcode generation uses Code128 format by default.

@vercel
Copy link

vercel bot commented Oct 2, 2025

Someone is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@yusuftomilola yusuftomilola merged commit cf73033 into DistinctCodes:main Oct 2, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants