QR-Code-Manager generates mug-specific QR codes, delivers them via email, and then lets recipients claim gifts by scanning the QR and verifying their Microsoft Forms submission.
- Form: Microsoft Forms collects employee responses and automatically syncs them to the linked Excel workbook in OneDrive for Business / SharePoint. Keep the workbook open in Excel for the web at least briefly so syncs can replay.
- Storage: The synced workbook acts as the canonical source of truth for completed submissions; the backend reads the “Email” column via Microsoft Graph instead of trying to call Forms directly.
- Backend: Node.js (Express) hashes email addresses from the workbook (
sha256) and compares them to the identifiers stored in MongoDB. When a match occurs, the respondent record flipshasCompletedSurveyandhasReceivedGift. - Frontend: Electron UI wraps Docker Compose controls, so operators can rebuild containers, restart the API, and wipe/regenerate the database.
- Languages: JavaScript
- Frameworks/Libraries: Express.js, Electron, MongoDB, Microsoft Graph API
- Tools: Docker Compose
- Azure AD App Registration (form owner account) – from the Microsoft 365 tenant with access to the form workbook:
- Register a new app in Azure AD (
https://portal.azure.com→ Azure Active Directory → App registrations → + New registration). - Record the Application (client) ID and Directory (tenant) ID (these become
AZURE_CLIENT_IDandAZURE_TENANT_ID). - Under Certificates & secrets, create a client secret and save its value as
AZURE_CLIENT_SECRET. - Under API permissions, add Application permissions
Files.Read.All(orSites.Read.Allif you need SharePoint drives), then click Grant admin consent.
- Register a new app in Azure AD (
- Share the workbook – make sure the Azure app can access the Excel file:
- If the workbook lives in a user’s OneDrive, note that user principal name and set
EXCEL_OWNER_UPN. - Optionally, if the workbook is on a SharePoint/Shared drive, populate
EXCEL_DRIVE_IDinstead.
- If the workbook lives in a user’s OneDrive, note that user principal name and set
- Find the Excel file details – use Microsoft Graph Explorer or PowerShell to retrieve the Drive Item ID (
EXCEL_FILE_ITEM_ID) for the synced workbook and set the worksheet name/range where the “Email” column lives (EXCEL_WORKSHEET_NAME,EXCEL_RANGE.) - Environment variables – create a
.envnext tobackend/.env.exampleand populate:MONGODB_URI="mongodb://mongodb:27017/QRCodeSystem" CSV_LOCATION="/usr/src/app/config/exampleList.csv" HOSTNAME="example-host.local" AZURE_TENANT_ID="..." AZURE_CLIENT_ID="..." AZURE_CLIENT_SECRET="..." EXCEL_FILE_ITEM_ID="..." EXCEL_WORKSHEET_NAME="Sheet1" EXCEL_RANGE="D2:D" EXCEL_OWNER_UPN="form.owner@tenant.onmicrosoft.com"
- Run
docker-compose up -dvia the Electron frontend (or runnpm startinsidebackend/). - Submit a Microsoft Form response; ensure the Excel workbook has been opened in Excel for the web so the sync can replay and the “Email” column is populated.
- Call
GET http://<host>:3000/validate/{token}(thetokenwas issued when the respondent was created). The backend hashes the workbook’s emails, finds the match, toggleshasCompletedSurvey, and serves a green/invalid message. - Check MongoDB: verify
hasCompletedSurveybecomes true andhasReceivedGifttoggles on the next validation.
- The form owner account must provide the Azure AD credentials (tenant ID, client ID, secret) as described above.
- The owner’s Graph path info (
EXCEL_OWNER_UPNorEXCEL_DRIVE_ID, plus the drive item ID) must be available before the backend can read the workbook. - The workbook must remain accessible to the app (the form owner can keep it in their OneDrive or a SharePoint library and share accordingly).
- Follow
MICROSOFT_MIGRATION_GUIDE.mdto configure Power Automate or rely on the workbook sync (the guide already explains the export and testing plan). - Call
/validate/:tokenafter you submit a form to confirm Graph can read the synced Excel rows and set the gift status. - Update the README or onboarding scripts if the backend or deployment environment changes (e.g., new hostnames or port mappings).