Skip to content

Real GeoIP behind a feature flag #14

@Yentec

Description

@Yentec

Context

src/shared/geo/geo.ts currently returns null. Shipping a MaxMind GeoLite2 database would bloat the repo and require a license key, making the project harder to clone (ADR omitted; this is documented in code comments).

Goal

Make geolocation work in production without imposing it on local development.

Approach

  • Add MAXMIND_DB_PATH (optional) and MAXMIND_LICENSE_KEY env vars.
  • If both set, lazy-load the maxmind reader on startup and resolve country from IP.
  • Otherwise, keep returning null (current behavior).
  • Document in the README how to fetch GeoLite2-Country.mmdb.

Acceptance criteria

  • Env vars validated by Zod (both optional, but error if one without the other)
  • Reader cached at module level (lazy init), no per-request file I/O
  • Unit test with a fixture .mmdb (small, freely available)
  • README updated with setup instructions

Notes

The MaxMind reader is synchronous and CPU-light — safe to run in the click worker without extracting to a separate service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions