# Build brief — a focused alternative to Bitly

> **Verdict:** Yes, for personal use · **Buildability:** 71/100 · **Category:** Analytics
> **Source:** https://www.canitbevibecoded.com/bitly
> Independent editorial assessment from Can It Be Vibe Coded? Not affiliated with, endorsed by, or derived from Bitly. Verify current pricing and capabilities before acting.

## Context

**Bitly** — Short links, branded back-halves, QR codes, and click analytics. It currently costs $35/mo.

A slug, a lookup, a 302, and a row in a table. Cloudflare Workers plus KV and D1 does the whole job on the free tier, and QR codes are one library call. The only thing you are really buying is that bit.ly resolves links created in 2012 and will presumably still resolve them in 2032, which is an institutional promise rather than a technical one. If the links are going in a magazine ad or on packaging, that promise is worth something. If they are going in this week's newsletter, it is worth nothing, and Growth is 420 USD a year.

This brief describes a focused, single-operator replacement for the part of Bitly that is genuinely reproducible. It is deliberately narrower than the product it replaces, and it says so in writing. Build the useful core; do not pretend to have rebuilt the rest.

## What you are building

Map a short slug to a destination, 302 to it, log the click with device and country, and render a QR code for any link.

- Ingest a known data source, calculate a focused metric set, and render a useful dashboard.
- A responsive interface with real empty, loading, success, and error states.

## Requirements

### Functional

- Cloudflare account (Workers, KV, D1).
- A domain you control.
- Wrangler CLI.

### Non-functional

- Accessibility: semantic markup, labelled controls, visible focus, and reduced-motion support.
- Security: server-side secrets, validated input, and no credentials in the client bundle.
- Reliability: retries with backoff on external calls, and a clear failure state when a provider is down.
- Portability: the operator can export their data and leave without losing it.

## Implementation brief

Build me a link shortener with click analytics and QR codes to replace Bitly. Requirements:

- Cloudflare Workers via wrangler: KV for the slug lookup, D1 for the click
  log. Free tier, and it runs on my own domain.
- A worker on go.mydomain.com/{slug} reads KV and 302s, writing the click to
  D1 inside ctx.waitUntil so the redirect never waits on the database.
- Slugs are random 6-character base62 by default, but I can set a custom
  back-half, and creating one that already exists fails loudly instead of
  overwriting it.
- Log per click: slug, timestamp, country and city from request.cf,
  device type parsed from the user-agent, and referer.
- Generate a PNG QR code for any link with the qrcode npm package, served at
  /qr/{slug} and cached, so print material points at the same tracked link.
- Optional expiry and a click cap per link · past either, 302 to a fallback
  URL I set instead of returning a 404.
- An /admin page behind one password (wrangler secret) listing links with
  clicks per day, plus top countries and device split per link.
- Secrets via wrangler secret, never in wrangler.toml. No accounts, no
  third-party analytics, no telemetry.
- README: wrangler setup, the KV namespace and D1 database, the DNS record,
  and a warning that these links die with the domain, so use a domain you
  intend to keep renewing.

## Delivery standard

- Inspect the repository first, then write a short implementation plan before writing code.
- Deliver the smallest complete end-to-end workflow first; every primary control must work against persisted data.
- Use real validation and storage; never substitute fake dashboards, decorative controls, hard-coded success states, or mock integrations.
- Include responsive layouts plus genuine empty, loading, success, validation, and failure states.
- Keep secrets server-side in environment variables, provide .env.example, and never commit credentials or user data.
- Add structured logs around every external call and return actionable errors without leaking sensitive details.
- Write unit tests for the core logic and one automated test of the main user journey.
- Finish with a README covering setup, architecture, data location, backups, tests, deployment, and known limitations.

## Acceptance criteria

- [ ] A clean install starts the app using only the README and .env.example.
- [ ] The primary journey works from first visit through saved result, reload, edit, export, and deletion where applicable.
- [ ] Invalid input, missing configuration, provider failure, and an empty database each have a usable state.
- [ ] The interface works at 390px and 1440px, is keyboard navigable, and shows visible focus on every control.
- [ ] Tests, type checking, linting, and a production build all pass with no ignored failures.
- [ ] No part of the interface implies a live integration, security guarantee, or scale capability that was not actually built and verified.

## Non-goals

Do not build these, and do not claim to have replaced them:

- Links that outlive your own infrastructure · a domain you stop renewing takes every link with it.
- Bit.ly's recognition in the link itself, which cuts both ways now that shorteners get spam-filtered.
- Bundled QR code management, landing pages, and campaign grouping.
- City-level and device-level analytics rollups without building them.
- Trust, audits, and counterparties matter more than feature parity.
- Reliability at the vendor's scale is an operations problem, not a prompt.

## What you still own after launch

- Run migrations, backups, restores, and dependency updates.
- Test the critical journey after every model, API, or hosting change.
- Monitor failures and fix the edge cases a first prompt will miss.

## Risk

**Operational risk.** The code is achievable; dependable data, integrations, and ongoing operations are the real cost.

Editorial confidence in this assessment: high. No independent one-shot implementation is linked yet.

## Prior art

Working open-source software you can read, fork, or borrow from before starting:

- [Dub](https://github.com/dubinc/dub) — The most complete open-source link platform · analytics, custom domains, QR codes. Self-hostable
- [Shlink](https://github.com/shlinkio/shlink) — Self-hosted URL shortener with a REST API, click stats, and QR codes
- [YOURLS](https://github.com/YOURLS/YOURLS) — The long-running PHP shortener · drop it on any LAMP host and it works

---

Generated by [Can It Be Vibe Coded?](https://www.canitbevibecoded.com) · Full report: https://www.canitbevibecoded.com/bitly
