https://github.com/wilddev/geo
Restful geographic service
https://github.com/wilddev/geo
Last synced: 8 months ago
JSON representation
Restful geographic service
- Host: GitHub
- URL: https://github.com/wilddev/geo
- Owner: WildDev
- License: cc-by-sa-4.0
- Created: 2024-10-02T09:08:11.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-27T22:21:19.000Z (about 1 year ago)
- Last Synced: 2025-05-27T23:25:41.431Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 108 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Description
Geographic data related service. Currently, is only integrated with [ipstack](https://ipstack.com)
[](https://github.com/WildDev/geo/actions/workflows/maven.yml) [](https://github.com/WildDev/geo/actions/workflows/docker-image.yml)
### How it works
##### Find user location based on its ip
1. Configure proxy to set `X-Real-IP` header
2. Route traffic to the service
3. Send a request
Example:
```cmd
curl "https://test.website/location/find" -H "X-Real-IP: 127.0.0.1" -v
< HTTP/1.1 200
< Content-Type: application/json
<
{
"country": {
"code": "DE",
"name": "Germany"
},
"city": "Dusseldorf"
}
```
##### Search locations manually with the autocomplete
Use `q` request param to search predefined locations by a sample string. The search is performed in `startsWith` fashion on top of a qualifier with `city country` format:
Example
```cmd
curl "https://test.website/location/list?q=Istanbul&20Turk" -v
< HTTP/1.1 200
< Content-Type: application/json
<
[
{
"country": {
"code": "TR",
"name": "Turkey"
},
"city": "Istanbul"
},
{
"country": {
"code": "TR",
"name": "Turkey"
},
"city": "Istanbul Old Town"
},
{
"country": {
"code": "TR",
"name": "Turkey"
},
"city": "Istanbulbogazi"
}
]
```
> [!WARNING]
> The search is case sensitive
### Get started
Build requirements:
* latest JDK and Maven
Runtime stack:
* Java 20+ (none for the GraalVM image version)
* API credentials for [ipstack](https://ipstack.com)
Checkout the project and build it using `mvn package` command
An example run:
```cmd
java -jar -Xmx256M target/geo.jar \
--server.port=8000 \
--spring.cors.allowed-origins=https://test.website \
--spring.data.mongodb.uri="mongodb+srv://geo:test@mongodb.example.com/geo?tls=true&authSource=admin&replicaSet=mongodb" \
--integration.ipstack.url=https://api.ipstack.com \
--integration.ipstack.access-key=723953e7b0e27c762c38213b7c71fd77
```
Also available on [Docker Hub](https://hub.docker.com/r/wilddev/geo)