How isreeharim/qrsree works
Purpose and system shape
QR Manager is a two-part dynamic QR platform. Printed codes resolve to a stable backend URL, while administrators can later change the stored destination. The backend owns authentication, QR lifecycle, scan telemetry, and redirects; the React frontend is an authenticated management console.
Runtime entry points
• Express API/server bootstrap: backend/server.js; MongoDB connection setup: backend/config/db.js.
• React/Vite client bootstrap and root composition: frontend/src/main.jsx, frontend/src/App.jsx.
• Initial administrator provisioning is a separate process: backend/seed/createAdmin.js.
• Deployment configuration exists for independent frontend/backend Vercel deployments: backend/vercel.json, frontend/vercel.json.
Identity and protected administration
JWT-based admin authentication is implemented through auth routes/controllers and enforced middleware. Password hashing is handled server-side; the client retains auth state and gates protected routes.
• Backend boundary: backend/routes/authRoutes.js, backend/controllers/authController.js, backend/middleware/auth.js.
• Frontend auth/session boundary: frontend/src/context/AuthContext.jsx, frontend/src/components/ProtectedRoute.jsx, frontend/src/api/auth.js.
• User administration is a distinct protected domain: backend/routes/userRoutes.js, backend/controllers/userController.js, frontend/src/pages/UserList.jsx.
QR code lifecycle
Administrators create, list, inspect, update, and delete QR definitions. Each QR record has a generated short code and a mutable destination, making the encoded public URL stable while redirect behavior remains database-driven.
• QR domain model and shortcode generation: backend/models/QRCode.js, backend/utils/generateShortCode.js.
• Protected QR API orchestration: backend/routes/qrRoutes.js, backend/controllers/qrController.js.
• Client data access and main management views: frontend/src/api/qr.js, frontend/src/pages/QRList.jsx, frontend/src/pages/QRDetail.jsx.
• QR rendering/export UI is separated into reusable presentation components: frontend/src/components/QRCodeDisplay.jsx, frontend/src/components/QRFormModal.jsx.
Public scan and redirect pipeline
A scanned code targets PUBLIC_BASE_URL/q/:shortCode, not the final URL. The unauthenticated public handler resolves the QR code, records a scan, increments its aggregate scan count, serves a temporary GPS-permission page, and redirects to the current destination. A separate public PATCH endpoint attaches coordinates to the scan created by that request.
• Public routing and scan control flow: backend/routes/publicRoutes.js, backend/controllers/scanController.js.
• Persistent telemetry: backend/models/ScanLog.js, backend/models/QRCode.js.
• IP-derived geography is an outbound integration boundary: backend/utils/geoLookup.js calls ip-api.com.
Analytics and dashboard
Dashboard aggregation exposes total QR/scan metrics and recent scan activity, while per-QR scan history supports detail analysis. These read models depend on QR and ScanLog persistence rather than a separate analytics service.
• Backend dashboard endpoint: backend/routes/dashboardRoutes.js, backend/controllers/dashboardController.js.
• Client dashboard integration and view: frontend/src/api/dashboard.js, frontend/src/pages/Dashboard.jsx.
• QR-specific scan history remains under backend/controllers/qrController.js and is presented from frontend/src/pages/QRDetail.jsx.
Infrastructure and cross-cutting boundaries
MongoDB Atlas via Mongoose is the system of record. Express middleware centralizes JWT checks, request validation, async/error translation, and CORS-facing API behavior.
• Cross-cutting backend handling: backend/middleware/validate.js, backend/middleware/errorHandler.js, backend/utils/AppError.js.
• Frontend HTTP boundary is centralized in frontend/src/api/axios.js; all feature API modules consume it.
• Production requires HTTPS for browser geolocation and a correctly configured public backend origin because that origin is embedded in QR codes.
Main entry points: axios.js HTTP client · server.js Express server · dashboardRoutes.js Dashboard aggregation · App.jsx React app shell
Components 20
Backend API
Express service for administration and public QR resolution.
- Express server
backend/server.js - MongoDB connection
backend/config/db.js - Auth API · Issues JWTs and handles server-side password authentication.
backend/routes/authRoutes.js - JWT guard
backend/middleware/auth.js - User administration
backend/routes/userRoutes.js - QR lifecycle API · Creates and manages stable short-code QR definitions and scan history.
backend/routes/qrRoutes.js - QR codes · Stores short codes, mutable destinations, and aggregate scan counts.
backend/models/QRCode.js - Public scan redirect · Resolves /q/:shortCode, records a scan, requests GPS, then redirects.
backend/routes/publicRoutes.js - Scan logs · Persistent per-scan telemetry including later coordinates.
backend/models/ScanLog.js - IP geolocation · Looks up approximate geography through ip-api.com.
backend/utils/geoLookup.js - Dashboard aggregation · Builds totals and recent activity from QR and scan records.
backend/routes/dashboardRoutes.js - Validation & errors · Central validation and async/error translation.
backend/middleware/validate.js - Admin provisioning · Creates the initial administrator independently of the server.
backend/seed/createAdmin.js
Management Console
React/Vite authenticated administrator UI.
- React app shell · Composes the management console and protected pages.
frontend/src/App.jsx - Auth session · Retains client auth state and gates administration routes.
frontend/src/context/AuthContext.jsx - HTTP client · Shared transport consumed by feature API modules.
frontend/src/api/axios.js - QR management UI · Manages QR definitions, rendering/export, and per-QR scan history.
frontend/src/pages/QRList.jsx - Dashboard UI
frontend/src/pages/Dashboard.jsx - User management UI
frontend/src/pages/UserList.jsx
Data & External
System-of-record persistence and IP geolocation dependency.
- MongoDB Atlas
Connections 32
- Express server → MongoDB connection: initializes
- MongoDB connection → MongoDB Atlas: connects
- Express server → Auth API: mounts
- Express server → QR lifecycle API: mounts
- Express server → Public scan redirect: mounts public /q route
- Express server → Dashboard aggregation: mounts
- Express server → Validation & errors: uses
- Auth API → JWT guard: JWT enforced by
- JWT guard → User administration: protects
- JWT guard → QR lifecycle API: protects
- JWT guard → Dashboard aggregation: protects
- QR lifecycle API → QR codes: manages
- Public scan redirect → QR codes: resolves and increments
- Public scan redirect → Scan logs: creates and patches GPS
- Public scan redirect → IP geolocation: enriches from IP
- Dashboard aggregation → QR codes: aggregates
- Dashboard aggregation → Scan logs: reads activity
- QR codes → MongoDB Atlas: persists
- Scan logs → MongoDB Atlas: persists
- Admin provisioning → MongoDB Atlas: creates initial admin
- React app shell → Auth session: provides session
- Auth session → HTTP client: supplies JWT
- React app shell → QR management UI: routes to
- React app shell → Dashboard UI: routes to
- React app shell → User management UI: routes to
- QR management UI → HTTP client: uses QR API
- Dashboard UI → HTTP client: uses dashboard API
- User management UI → HTTP client: uses user API
- HTTP client → Auth API: auth requests
- HTTP client → QR lifecycle API: QR requests
- HTTP client → Dashboard aggregation: analytics requests
- HTTP client → User administration: user requests