You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Start PostgreSQL
docker compose up db -d
# Run the application
go run cmd/api/main.go
# With BigQuery (requires GCP credentials)
GCP_PROJECT=your-project go run cmd/api/main.go
Design Decisions
Dual write (Cloud SQL + BigQuery): Cloud SQL is the source of truth for click logs. BigQuery receives an async copy for analytics, using goroutines to avoid impacting redirect latency.
Denormalized BigQuery schema: click_events stores short_code and original_url directly instead of url_id, eliminating JOINs for analytical queries.
Time partitioning: BigQuery table is partitioned by clicked_at to minimize scan costs and improve query performance.
Graceful degradation: If BigQuery is unavailable, redirects and click logging to Cloud SQL continue to work normally.
License
MIT
About
URL shortener API with click analytics — Go, Cloud Run, BigQuery