CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlite-go-best-practices

SQLite best practices for Go — WAL mode, foreign_keys, busy_timeout, SetMaxOpenConns, context-aware queries, transactions, migrations

98

2.36x
Quality

99%

Does it follow best practices?

Impact

97%

2.36x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-5/

URL Shortener Service

Problem/Feature Description

A developer is building a simple URL shortener service in Go with SQLite for persistence. The service should handle moderate traffic (a few hundred requests per minute) and run as a single binary with no external dependencies.

The service needs to support:

  • Creating a short URL: accepts a long URL and an optional custom short code. If no custom code is provided, generate a random 7-character alphanumeric code. Return the short code and full short URL.
  • Redirecting: given a short code, look up the original URL and redirect (HTTP 301). Increment a click counter on each redirect.
  • Getting stats for a short URL: return the original URL, short code, click count, creation date, and last accessed date.
  • Listing all URLs with their stats, sorted by creation date
  • Deleting a short URL by code

Each URL has: id, short_code (unique), original_url, click_count (default 0), created_at, last_accessed_at.

The click counter update on redirect must be efficient since it happens on every redirect request.

Output Specification

Produce:

  • main.go -- HTTP server with routes
  • db.go -- Database setup and migrations
  • store.go -- URL storage operations
  • handlers.go -- HTTP handlers for all endpoints
  • go.mod -- Module file

The code should be complete Go with no placeholders or TODO comments.

evals

tile.json