File size: 6,876 Bytes
f5af101
 
 
 
 
 
 
 
 
 
 
872bfc6
f5af101
872bfc6
f5af101
872bfc6
f5af101
872bfc6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
---

title: Dynamic-QR
emoji: πŸ”—
colorFrom: blue
colorTo: green
sdk: docker
sdk_version: "1.0"
app_file: Dockerfile
pinned: false
---


# Dynamic-QR: QR Code Management System

<div align="center">

![Dynamic QR Logo](https://img.shields.io/badge/Dynamic--QR-green?style=for-the-badge&logo=qr-code&logoColor=white)

[![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://python.org)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.104+-green.svg)](https://fastapi.tiangolo.com)
[![HuggingFace](https://img.shields.io/badge/πŸ€—%20HuggingFace-Spaces-yellow.svg)](https://huggingface.co/spaces/parthmax/dynamic-qr)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)

*A powerful, FastAPI-based system for generating, updating, and tracking **dynamic QR codes** with enterprise-ready APIs.*

[πŸš€ Live Demo](https://huggingface.co/spaces/parthmax/dynamic-qr) β€’ [πŸ“– Documentation](#documentation) β€’ [πŸ› οΈ Installation](#installation) β€’ [πŸ“Š API Reference](#api-reference)

</div>

---

## 🌟 Overview

Dynamic-QR provides a **centralized system for creating and managing QR codes** that can be updated anytime without re-printing.  
It includes scan tracking, redirection logic, and a simple **web dashboard + API interface** for enterprise use cases.

---

## ✨ Key Features

### πŸ”— **Dynamic QR Management**
- Create unique QR codes with short IDs  
- Update QR destination anytime without changing the QR image  
- Delete or deactivate codes when needed  

### πŸ“Š **Analytics & Tracking**
- Track scan counts in real time  
- Log last scan timestamp  
- Manage activity status (`active/inactive`)  

### πŸ–₯️ **Dashboard & APIs**
- Jinja2-powered dashboard to view all QR codes  
- REST APIs for integration with other systems  
- QR image generation endpoint for direct embedding  

### πŸ›‘οΈ **Enterprise Ready**
- CORS enabled  
- Health check endpoint  
- Extensible for database or authentication integration  

---

## πŸ—οΈ System Architecture

```



β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚  Web Dashboard    │◄───►│   FastAPI Backend  β”‚

β”‚  (Jinja2)         β”‚     β”‚   (app.py)         β”‚

β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”‚

β–Ό

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚  QR Generator     β”‚     β”‚   In-Memory Store  β”‚

β”‚  (qrcode lib)     β”‚     β”‚   (Dict, can use DB)β”‚

β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜



````

---

## πŸš€ Quick Start

### Option 1: Try Online (Recommended)
Visit the live demo: [πŸ€— HuggingFace Spaces](https://huggingface.co/spaces/parthmax/dynamic-qr)

### Option 2: Local Installation

#### 1. Clone the Repository
```bash

git clone https://github.com/parthmax2/dynamic-qr.git

cd dynamic-qr

````

#### 2. Setup Virtual Environment

```bash

python -m venv venv

source venv/bin/activate  # Linux/Mac

# venv\Scripts\activate   # Windows

```

#### 3. Install Dependencies

```bash

pip install -r requirements.txt

```

#### 4. Run the Server

```bash

uvicorn app:app --reload --host 0.0.0.0 --port 8000

```

πŸ‘‰ Visit [http://127.0.0.1:8000](http://127.0.0.1:8000)

---

## 🎯 Usage

### Web Dashboard

1. Open `/` to view all QR codes
2. Create a new QR by entering **title + redirect URL**
3. Update existing QR code targets anytime
4. Download the QR image and share

### API Examples

#### Create QR

```bash

curl -X POST "http://localhost:8000/create" \

  -F "title=My GitHub" \

  -F "redirect_url=https://github.com/parthmax2"

```

#### Redirect Scan

```bash

curl -i "http://localhost:8000/r/{qr_id}"

```

#### Get QR Image

```bash

curl -o qr.png "http://localhost:8000/qr/{qr_id}"

```

#### Get QR Metadata

```bash

curl "http://localhost:8000/api/qr/{qr_id}"

```

---

## πŸ“š API Reference

### Core Endpoints

| Method   | Endpoint          | Description          |
| -------- | ----------------- | -------------------- |
| `GET`    | `/`               | Dashboard UI         |
| `POST`   | `/create`         | Create new QR        |
| `POST`   | `/update/{qr_id}` | Update QR code       |
| `GET`    | `/r/{qr_id}`      | Redirect endpoint    |
| `GET`    | `/qr/{qr_id}`     | Get QR PNG image     |
| `DELETE` | `/delete/{qr_id}` | Delete QR code       |
| `GET`    | `/api/qr/{qr_id}` | Get QR metadata JSON |
| `GET`    | `/health`         | Health check         |

### Example QR Metadata Response

```json

{

  "id": "abc12345",

  "title": "My GitHub",

  "redirect_url": "https://github.com/parthmax2",

  "scan_count": 12,

  "created_at": "2025-08-31T10:45:00",

  "last_scanned": "2025-08-31T11:20:00",

  "is_active": true

}

```

---

## βš™οΈ Configuration

### Environment Variables

| Variable   | Description                      | Default                                             |
| ---------- | -------------------------------- | --------------------------------------------------- |
| `BASE_URL` | Base URL used for QR redirection | `https://huggingface.co/spaces/parthmax/dynamic-qr` |

> ⚠️ In production, configure `BASE_URL` to match your deployment domain.



---



## πŸ› οΈ Development



### Project Structure



```

dynamic-qr/

β”œβ”€β”€ app.py                # Main FastAPI application

β”œβ”€β”€ templates/            # Jinja2 templates (UI)

β”‚   └── index.html

β”œβ”€β”€ static/               # Static assets (CSS, JS)

β”œβ”€β”€ requirements.txt      # Python dependencies

└── README.md             # Documentation

```





---



## πŸ“Š Roadmap



* βœ… Dynamic QR CRUD

* βœ… Scan tracking

* πŸ”„ Persistent DB integration (SQLite/Postgres)

* πŸ”„ User authentication

* πŸ”„ Analytics dashboard with charts

* πŸ”„ Bulk QR generation & export



---



## πŸ”’ Security



* Input validation for URLs

* Configurable active/inactive state

* Ready for JWT auth integration

* Safe QR redirection logic



---



## πŸ“„ License



This project is licensed under the **MIT License**.

See the [LICENSE](LICENSE) file for details.



---



## πŸ‘€ Author



**Saksham Pathak** ([@parthmax2](https://github.com/parthmax2))

Generative AI Engineer | AI Apps & Developer Tools



---



<div align="center">



**[⭐ Star this repo](https://github.com/parthmax2/dynamic-qr)** if you find it useful!



Made with ❀️ by [parthmax](https://github.com/parthmax2)



</div>

```