Skip to main content
Long Tran
💬
0 discussions

QR Processing Server

I. Introduction

The QR Processing Server is a critical component of the Qranty system, responsible for generating QR codes for product tracking and warranty registration. This document provides an overview of the QR Processing Server, detailing its architecture, functionality, and interactions with other components of the system.

II. Packages

1. Dependencies

Package NameDescriptionLinkVersion
@shortcm/qr-imageQR Code image generation library@shortcm/qr-image^9.0.4
adm-zipA Javascript implementation of zip for nodejsadm-zip^0.5.12
archiverA library for creating zip and tar archivesarchiver^7.0.1
axiosPromise based HTTP client for the browser and node.jsaxios^1.6.7
bcryptA library to help you hash passwordsbcrypt^5.1.1
bullPremium Queue package for handling distributed jobs and messages in NodeJSbull^4.12.2
canvasNode canvas is a Cairo backed Canvas implementation for NodeJScanvas^2.11.2
corsNode.js CORS middlewarecors^2.8.5
exceljsExcel Workbook Manager for JavaScriptexceljs^4.4.0
expressFast, unopinionated, minimalist web framework for nodeexpress^4.18.2
fix-esmA utility to fix ESM import/export issuesfix-esm^1.0.1
get-streamGet a stream as a string, buffer, or arrayget-stream^9.0.1
jsonwebtokenJSON Web Token implementation for node.jsjsonwebtoken^9.0.2
jspdfPDF Document creation from JavaScriptjspdf^2.5.1
mongooseElegant MongoDB object modeling for Node.jsmongoose^8.2.0
multerNode.js middleware for handling multipart/form-datamulter^1.4.5-lts.1
pdf-libCreate and modify PDF documents in JavaScriptpdf-lib^1.17.1
pdfkitA JavaScript PDF generation library for Node and the browserpdfkit^0.14.0
qrcodeQR code generatorqrcode^1.5.3
redisRedis client libraryredis^4.6.13
sharpHigh-performance image processing in Node.jssharp^0.32.6
tar-streamStreaming tar parser and generatortar-stream^3.1.7
zip-streamCreate zip archives on-the-flyzip-stream^6.0.1
zlibA library for handling zip archiveszlib^1.0.5

2. Dev Dependencies

Package NameDescriptionLinkVersion
@babel/cliBabel command line@babel/cli^7.23.4
@babel/coreBabel compiler core@babel/core^7.23.7
@babel/nodeBabel command line for Node.js@babel/node^7.22.19
@babel/plugin-proposal-class-propertiesBabel plugin for class properties@babel/plugin-proposal-class-properties^7.18.6
@babel/plugin-proposal-object-rest-spreadBabel plugin for object rest/spread@babel/plugin-proposal-object-rest-spread^7.20.7
@babel/preset-envBabel preset for compiling ES2015+@babel/preset-env^7.24.3
@types/adm-zipTypeScript definitions for adm-zip@types/adm-zip^0.5.5
@types/archiverTypeScript definitions for archiver@types/archiver^6.0.2
@types/bcryptTypeScript definitions for bcrypt@types/bcrypt^5.0.2
@types/bullTypeScript definitions for bull@types/bull^4.10.0
@types/corsTypeScript definitions for cors@types/cors^2.8.17
@types/crypto-jsTypeScript definitions for crypto-js@types/crypto-js^4.2.2
@types/expressTypeScript definitions for express@types/express^4.17.21
@types/jsonwebtokenTypeScript definitions for jsonwebtoken@types/jsonwebtoken^9.0.5
@types/multerTypeScript definitions for multer@types/multer^1.4.11
@types/pdfkitTypeScript definitions for pdfkit@types/pdfkit^0.13.4
@types/qrcodeTypeScript definitions for qrcode@types/qrcode^1.5.5
@types/tar-streamTypeScript definitions for tar-stream@types/tar-stream^3.1.3
dotenvLoads environment variables from .env filedotenv^16.3.1
nodemonSimple monitor script for use during development of a node.js appnodemon^3.0.2
pm2Production process manager for Node.js applications with a built-in load balancerpm2^5.3.1
rimrafA deep deletion module for noderimraf^5.0.5

III. Environment Variables

Variable NameDescriptionDefault Value
NODE_ENVEnvironment modedevelopment
PORTPort number for the server3998
MONGODB_URLMongoDB connection URLmongodb://localhost:27017/qrantty?authsource=admin
REDIS_HOSTRedis hostlocalhost
REDIS_PORTRedis port6379
REDIS_PASSWORDRedis password
PRIVATE_KEYPrivate key for JWT token same as the private key in Transportation ServerGcalls2023

IV. Source Tree

.
├── ecosystem.config.js - Configuration file for PM2 process manager
├── nodemon.json - Configuration file for Nodemon to manage file watching and automatic server restarts.
├── package.json - File defining the project's dependencies, scripts, and metadata.
├── package-lock.json - Auto-generated file that locks the dependencies to specific versions.
└── src - Source code directory.
├── app.js - Main application file.
├── configs - Configuration files for the application.
│ └── index.js
├── logos - Stores logo images.
│ ├── bomber.jpeg
│ ├── brother.png
│ └── index.js
├── middlewares - Middleware functions for handling requests and processing.
│ ├── excelStorage.js
│ ├── imageStorage.js
│ ├── storeFile.js
│ └── verify.js
├── models - Database models.
│ ├── Company.js
│ ├── Excels.js
│ ├── File.js
│ └── Models.js
├── routes - API route handlers.
│ └── Excel.js
├── services - Service layer for business logic.
│ ├── Excel.js
│ ├── QR.js
│ └── WarrantyFile.js
├── Storage - Storage-related functions and configurations.
│ └── index.js
└── utils - Utility functions and helper scripts.
├── CacheManager.js
├── index.js
├── PDFConvert.js
├── Queue
│ ├── CompressQueue.js
│ ├── ExcelQueue.js
│ ├── ExportQueue.js
│ ├── QrQueue.js
│ └── ZipQueue.js
├── reducePDF.js
├── splitToChunks.js
└── validateDomain.js

V. Data Flow Diagram

alt text