Overview
Discover what makes Geo2tz powerful
Geo2tz is a lightweight, self‑hosted microservice written in Go that resolves geographic coordinates to IANA time zone identifiers. It leverages the high‑resolution polygon data from **evansiroky/timezone-boundary-builder** and exposes a single HTTP endpoint (`GET /tz/{lat}/{lon}`) that returns JSON. The service is designed for performance, low memory footprint, and strict privacy guarantees—coordinates never leave the host.
Fast lookup
Updatable data
Error handling
Version endpoint
Overview
Geo2tz is a lightweight, self‑hosted microservice written in Go that resolves geographic coordinates to IANA time zone identifiers. It leverages the high‑resolution polygon data from evansiroky/timezone-boundary-builder and exposes a single HTTP endpoint (GET /tz/{lat}/{lon}) that returns JSON. The service is designed for performance, low memory footprint, and strict privacy guarantees—coordinates never leave the host.
Key Features
- Fast lookup: In‑memory spatial index (R‑tree) enables sub‑millisecond queries on a machine with 8 GB RAM.
- Updatable data: The database is bundled as a ZIP of GeoJSON files; new releases can be swapped by re‑initializing the container or restarting the binary.
- Error handling: Validates latitude/longitude ranges and returns descriptive HTTP 400 responses.
- Version endpoint:
/tz/versionexposes the underlying timezone boundary release and download URL for auditability. - Optional token auth: Basic query‑string token protection (
?token=…) for simple access control.
Technical Stack
| Layer | Technology |
|---|---|
| Language | Go 1.22+ (compiled binary) |
| Web framework | Standard library net/http with minimal middleware for logging and auth |
| Spatial index | github.com/tidwall/geom + custom R‑tree implementation |
| Data source | GeoJSON polygons from timezone-boundary-builder (GitHub releases) |
| Packaging | Docker image (noandrea/geo2tz) with Alpine base for minimal size (~15 MB) |
| Testing | Go’s testing package, CI via GitHub Actions (quality.yml) |
The codebase is deliberately small (~2 k LOC) to keep the attack surface low and simplify maintenance.
Core Capabilities
- REST API: Single endpoint for time‑zone lookup; no authentication headers needed unless configured.
- Query Parameters: Optional
tokenfor simple bearer‑style protection; no OAuth or JWT support. - Extensibility hooks: The binary exposes a
mainpackage that can be imported into larger Go applications; the lookup logic is encapsulated in atzpackage with an interface that can be swapped for alternative data sources. - Metrics: Exposes basic Prometheus metrics (request count, latency) via
/metricswhen the-prometheusflag is enabled.
Deployment & Infrastructure
Geo2tz is designed for self‑hosting in any environment that can run Docker or a native Go binary:
- Containerization: Official image is available on Docker Hub; can be run behind a reverse proxy (NGINX, Traefik) with TLS termination.
- Resource footprint: Requires < 100 MB RAM and a single CPU core for 99.9% of requests; the GeoJSON database (~50 MB uncompressed) is loaded into memory at startup.
- Scalability: Stateless, so horizontal scaling is trivial. Auto‑scaling can be orchestrated by Kubernetes or Docker Swarm.
- Persistence: No external database needed; all data is read‑only and stored in the container’s filesystem.
Integration & Extensibility
- API consumption: Any language can call the endpoint; Go clients are provided in the
clientsubmodule. - Webhook: Not built‑in, but can be added by wrapping the service in a proxy that triggers downstream events on lookup.
- Plugin system: No plugin architecture; however, the
tzpackage can be forked and extended to support custom polygon sources or caching layers. - Custom data: Replace the GeoJSON ZIP with a locally modified file; rebuild the image or mount the data volume.
Developer Experience
- Documentation: Inline GoDoc is comprehensive; external README covers usage, CI status, and API examples.
- Testing: Unit tests cover boundary cases (invalid coordinates) and performance benchmarks; CI enforces code quality via
golangci-lint. - Community: Active GitHub repository with issue tracking; contributors can submit PRs for new features or bug fixes.
- Licensing: MIT license—free to use, modify, and redistribute in commercial or open‑source projects.
Use Cases
| Scenario | Why Geo2tz? |
|---|---|
| Privacy‑first geolocation services | Keeps raw coordinates on‑premise; no external API calls. |
| Time‑zone conversion in microservices | Lightweight lookup service that can be called from multiple services without duplicating logic. |
| Embedded devices | Small binary size and no external dependencies make it suitable for edge deployments. |
| Compliance‑driven environments | Meets GDPR/CCPA requirements by avoiding third‑party data leaks. |
| Testing & CI pipelines | A mock time‑zone resolver that can be spun up locally for integration tests. |
Advantages Over Alternatives
- Zero external dependencies: No reliance on third‑party APIs or paid services.
- Performance: In‑memory R‑tree lookup outperforms many RESTful alternatives by an order of magnitude.
- Transparency: Uses openly available boundary data; the source code is fully auditable.
- Simplicity: Single endpoint, no authentication overhead unless explicitly configured.
- Cost‑effective: Runs on a single low‑cost VM or container; no recurring service fees.
Geo2tz offers developers a robust, privacy‑centric solution for
Open SourceReady to get started?
Join the community and start self-hosting Geo2tz today
Related Apps in other
Immich
Self‑hosted photo and video manager
Syncthing
Peer‑to‑peer file sync, no central server
Strapi
Open-source headless CMS for modern developers
reveal.js
Create stunning web‑based presentations with HTML, CSS and JavaScript
Stirling-PDF
Local web PDF editor with split, merge, convert and more
MinIO
Fast, S3-compatible object storage for AI and analytics
Weekly Views
Repository Health
Information
Explore More Apps
Cockpit CMS
Headless content platform for any front‑end
Polaris
Self-hosted music streaming for any device
WeeChat
Lightweight, extensible chat client for multiple protocols
Roundcube
Webmail client for modern browsers
Syndie
Self-hosted apis-services
Plainpad
Secure, self‑hosted note taking for any device