Type: BE
Component: backend/src/routes/bets.js
Context
Certain prediction market categories (political elections, sports betting) are regulated or illegal in specific jurisdictions. The platform needs the ability to restrict access to specific markets based on the user's IP geolocation to comply with local regulations and reduce legal risk.
Implementation Guide
- Add a restricted_countries column to the markets table: an array of ISO 3166-1 alpha-2 country codes (e.g. ['US', 'GB']).
- Add the geoip-lite package to package.json for IP-to-country lookup.
- In POST /api/bets, look up the requester's country from their IP address using geoip-lite.
- If the market has restricted_countries and the requester's country is in the list, return 403 with error: This market is not available in your region.
- Log all geo-restriction blocks with market_id, country_code, and IP hash (not full IP) for compliance reporting.
Guidelines
- Security: log IP hash only, never the full IP address, for privacy compliance.
- Key requirement: geoip-lite / restricted_countries Column / 403 on Block / Compliance Log / IP Hash.
Definition of Done
PR and Checkout
git checkout -b feat/geo-restriction
git add .
git commit -m "feat: implement IP-based geo-restriction for regulated market categories"
git push origin feat/geo-restriction
Open a PR against main and include the issue number in the PR description.
Type: BE
Component: backend/src/routes/bets.js
Context
Certain prediction market categories (political elections, sports betting) are regulated or illegal in specific jurisdictions. The platform needs the ability to restrict access to specific markets based on the user's IP geolocation to comply with local regulations and reduce legal risk.
Implementation Guide
Guidelines
Definition of Done
PR and Checkout
git checkout -b feat/geo-restriction
git add .
git commit -m "feat: implement IP-based geo-restriction for regulated market categories"
git push origin feat/geo-restriction
Open a PR against main and include the issue number in the PR description.