DEV Community

Philip Damwanza
Philip Damwanza

Posted on

Building QrStamp: A Lightning-Fast QR Code & Analytics Tracker in Go

Need a lightweight, self-hosted service to generate trackable QR codes without dealing with third-party SaaS limits? I built QrStamp—a minimalist, high-performance web application powered by Go, SQLite, and vanilla web tech.

Why Go & SQLite?
Go (net/http): Delivers blazing-fast server execution and concurrency for handling redirects and stats tracking effortlessly.

SQLite (modernc.org/sqlite): Provides zero-config, embedded data storage so the entire app runs as a single portable file.

QR Generation: Uses github.com/skip2/go-qrcode to encode PNG assets on the fly.

Core Backend Architecture
The heart of QrStamp relies on atomic database transactions. When someone scans a unique tracking link (e.g., /qr/{id}), the server immediately looks up the destination URL and increments the scan counter in a single step:

Go
func (db *DB) ScanAndGetURL(id string) (string, error) {
tx, err := db.Begin()
if err != nil {
return "", err
}
defer tx.Rollback()

var originalURL string
err = tx.QueryRow(`SELECT original_url FROM qrcodes WHERE id = ?`, id).Scan(&originalURL)
if err != nil {
    return "", err
}

_, err = tx.Exec(`UPDATE qrcodes SET scans = scans + 1 WHERE id = ?`, id)
if err != nil {
    return "", err
}

return originalURL, tx.Commit()
Enter fullscreen mode Exit fullscreen mode

}
The Result
With a modern dark-mode UI, instant QR rendering, and a real-time scan metrics counter, QrStamp is the ultimate quick utility project for anyone looking to sharpen their backend skills in Go.

Top comments (0)