How akshayp47/qr_generator-l- works
1. This repo is a two-part QR code generator: a Python backend in backend/ and a static browser frontend in client/. The architecture is deliberately split at the HTTP boundary.
2. The backend is a small Flask service (backend/app.py). Its main responsibility is to accept QR-generation requests, create the QR image, and return the result as JSON. It is the only component that knows how to produce the PNG.
3. The frontend is a minimal static UI (client/index.html, client/script.js, client/style.css). It runs entirely in the browser and handles user interaction, form inputs, and DOM updates. There is no frontend build system or client-side framework.
4. The key integration point is the API endpoint POST /api/qr. The browser sends JSON with fields such as text, size, box_size, fill_color, and back_color, and the backend responds with a JSON object containing a data_url.
5. Data flow starts with the user entering text and options in the page. script.js collects those values, sends them over fetch() to the Flask API, then takes the returned data_url and assigns it to an <img> element and download link.
6. The backend’s internal flow is: parse incoming JSON from the request, generate the QR image in memory, encode it as a Base64 PNG data URL, and send it back via jsonify(...). The response is meant to be directly consumable by the browser without an extra file download step.
7. Cross-origin access matters here because the frontend may be opened separately from the Flask server. The README indicates CORS is enabled in the backend, so the browser is allowed to read the API response even if the page and API are on different origins.
8. The repository has no persistent storage, job queue, or database. Each QR code is generated on demand per request, returned immediately, and discarded after the response.
9. The runtime boundary is simple: Python/Flask on the server side, plain HTML/CSS/JavaScript in the browser. The frontend does not call Python directly; it only speaks HTTP/JSON to the backend.
10. Operationally, the repo is designed for local development by starting the Flask app on port 5000 and opening client/index.html directly in a browser. The README also suggests the API URL can be switched to a deployed backend without changing the overall architecture.
11. From a diagram perspective, the main nodes are: browser UI, Flask API, QR-generation logic inside the backend, and the in-memory PNG/Base64 response path. The only external dependency that materially affects behavior is the QR-generation library used by the backend, plus CORS support for browser access.
Main entry points: app.py POST /api/qr · script.js script.js · index.html index.html · style.css style.css
Components 8
Frontend
Static browser UI and interaction logic
- index.html · Page shell for the QR generator UI
client/index.html - script.js · Collects form values, calls the API, and updates the image/link
client/script.js - style.css · Visual presentation for the browser UI
client/style.css
Backend
Flask service that generates QR images
- POST /api/qr · Single request/response boundary for QR generation
backend/app.py - app.py · Accepts JSON, coordinates QR creation, and returns the result
backend/app.py - QR pipeline · Builds the QR image and encodes it as a PNG data URL
backend/app.py
Other components
- Browser · Runs the static UI and sends QR requests
- QR library · Library used to create the QR code image
Connections 9
- Browser → index.html: loads · The browser opens the static page
- Browser → style.css: applies · The page uses the stylesheet for presentation
- Browser → script.js: runs · JavaScript executes in the browser
- script.js → POST /api/qr: fetch JSON · Sends text and QR options to the backend
- POST /api/qr → app.py: handled by · Flask route processes the request
- app.py → QR pipeline: delegates · Request parsing leads into QR generation
- QR pipeline → QR library: uses · Backend relies on the QR generation library
- QR pipeline → POST /api/qr: returns data_url · Produces the Base64 PNG response payload
- POST /api/qr → script.js: responds · Browser receives the generated image data