Prerequisites
- Go 1.24 or later
- Git
Quick start
Set required environment variables
Dubly requires two environment variables to start:
For local development, use
localhost:8080 as one of your domains. This allows you to access both the API and admin UI on http://localhost:8080.One-line dev server
Combine build and run:go run (rebuilds on every start):
Environment variables for development
All configuration is through environment variables. Here’s a typical development setup:Project structure
Testing
Run all tests:Testing philosophy
Dubly uses real infrastructure instead of mocks:- Every test gets a fresh in-memory SQLite database (
:memory:) - Handler tests use a real chi router wired identically to production
- No third-party testing frameworks (standard library only)
internal/models/link_test.go:
CLAUDE.md in the repository for detailed testing principles.
Development workflow
Database during development
Dubly createsdubly.db in the working directory by default. To reset your database:
GeoIP in development
Geo lookups are optional. Without a GeoIP database, Dubly runs normally but skips geographic data in analytics. To test GeoIP locally:Get a MaxMind license
Sign up for a free license at maxmind.com/en/geolite2/signup
Seeding test data
The repository includes a seeding tool:Benchmarking
Test redirect performance:Hot reload during development
For automatic rebuilds on file changes, use a tool like air:.air.toml:
Debugging
Enable request logging
The chi logger middleware is already enabled. Every request logs to stdout:Use Delve for breakpoints
Install Delve:Common development tasks
Add a new API endpoint
- Add handler method to
internal/handlers/links.go - Register route in
cmd/server/main.go: - Test with curl
Modify database schema
- Edit migrations in
internal/db/migrations.go - Delete
dubly.dbto rebuild from scratch - Update model methods in
internal/models/ - Add tests for new schema behavior
Change redirect logic
- Edit
internal/handlers/redirect.go - Update cache invalidation if needed
- Run
go test ./internal/handlers -v - Test manually:
Contributing
Before submitting a pull request:- Run tests:
go test ./internal/... -v - Run go fmt:
go fmt ./... - Check for issues:
go vet ./... - Update tests if you changed behavior
- Document any new environment variables
Next steps
Features
Explore all of Dubly’s capabilities
API Reference
Complete API documentation for all endpoints
Configuration
Learn about environment variables and settings
Deployment
Deploy to production with automated setup