# akshayp47/qr_generator-l- architecture

> Architecture diagram of the GitHub repository akshayp47/qr_generator-l-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akshayp47/qr_generator-l-
- Repository: https://github.com/akshayp47/qr_generator-l-

## Overview

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: [`backend/app.py`](https://github.com/akshayp47/qr_generator-l-/blob/main/backend/app.py) (POST /api/qr), [`client/script.js`](https://github.com/akshayp47/qr_generator-l-/blob/main/client/script.js) (script.js), [`client/index.html`](https://github.com/akshayp47/qr_generator-l-/blob/main/client/index.html) (index.html), [`client/style.css`](https://github.com/akshayp47/qr_generator-l-/blob/main/client/style.css) (style.css)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_client_index["index.html<br/>document<br/>[index.html]"]
  node_client_script["script.js<br/>controller<br/>[script.js]"]
  node_client_style["style.css<br/>styles<br/>[style.css]"]
end

subgraph group_backend["Backend"]
  node_api_endpoint{{"POST /api/qr<br/>HTTP API<br/>[app.py]"}}
  node_backend_app["app.py<br/>Flask service<br/>[app.py]"]
  node_qr_pipeline[("QR pipeline<br/>in-memory flow<br/>[app.py]")]
end

node_browser(("Browser<br/>runtime"))
node_qr_lib["QR library<br/>dependency"]

node_browser -->|"loads"| node_client_index
node_browser -->|"applies"| node_client_style
node_browser -->|"runs"| node_client_script
node_client_script -->|"fetch JSON"| node_api_endpoint
node_api_endpoint -->|"handled by"| node_backend_app
node_backend_app -->|"delegates"| node_qr_pipeline
node_qr_pipeline -->|"uses"| node_qr_lib
node_qr_pipeline -->|"returns data_url"| node_api_endpoint
node_api_endpoint -->|"responds"| node_client_script

click node_client_index "https://github.com/akshayp47/qr_generator-l-/blob/main/client/index.html"
click node_client_script "https://github.com/akshayp47/qr_generator-l-/blob/main/client/script.js"
click node_client_style "https://github.com/akshayp47/qr_generator-l-/blob/main/client/style.css"
click node_api_endpoint "https://github.com/akshayp47/qr_generator-l-/blob/main/backend/app.py"
click node_backend_app "https://github.com/akshayp47/qr_generator-l-/blob/main/backend/app.py"
click node_qr_pipeline "https://github.com/akshayp47/qr_generator-l-/blob/main/backend/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_index,node_client_script,node_client_style toneBlue
class node_api_endpoint,node_backend_app,node_qr_pipeline toneAmber
class node_browser,node_qr_lib toneNeutral
```

## Components

### Frontend

Static browser UI and interaction logic

- [index.html](https://github.com/akshayp47/qr_generator-l-/blob/main/client/index.html): document · Page shell for the QR generator UI · `client/index.html`
- [script.js](https://github.com/akshayp47/qr_generator-l-/blob/main/client/script.js): controller · Collects form values, calls the API, and updates the image/link · `client/script.js`
- [style.css](https://github.com/akshayp47/qr_generator-l-/blob/main/client/style.css): styles · Visual presentation for the browser UI · `client/style.css`

### Backend

Flask service that generates QR images

- [POST /api/qr](https://github.com/akshayp47/qr_generator-l-/blob/main/backend/app.py): HTTP API · Single request/response boundary for QR generation · `backend/app.py`
- [app.py](https://github.com/akshayp47/qr_generator-l-/blob/main/backend/app.py): Flask service · Accepts JSON, coordinates QR creation, and returns the result · `backend/app.py`
- [QR pipeline](https://github.com/akshayp47/qr_generator-l-/blob/main/backend/app.py): in-memory flow · Builds the QR image and encodes it as a PNG data URL · `backend/app.py`

### Other components

- **Browser**: runtime · Runs the static UI and sends QR requests
- **QR library**: dependency · Library used to create the QR code image

## Connections

- 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
