- Go 88.7%
- HTML 8.9%
- Shell 1.1%
- Makefile 1%
- Dockerfile 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| cmd/server | ||
| demo | ||
| icons/university | ||
| internal | ||
| migrations | ||
| scripts | ||
| systemd | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LBS server TZ draft.pdf | ||
| lbs-server.env.example | ||
| LICENSE | ||
| Makefile | ||
| README.en.md | ||
| README.md | ||
LBS Server
A prototype Location-Based Service (LBS) server.
The project implements a geolocation server using cellular network data (GSM / WCDMA / LTE) and Wi‑Fi, IP, compatible with the Yandex Locator input format, using a third-party database at the PoC stage.
TODO:
- write a sample .env file and instructions for it
- custom errors
- properly add layers (add server layer)
The server receives radio network data from the client and attempts to determine coordinates:
-
First — from its own database (LocateDB)
-
Then — from an external database (ExternalDB, CSV / OpenCell dump)
-
When coordinates are found — saves the point to the session database
-
If no data is available — returns an error
There is also an /update endpoint that allows enriching the database with data received from clients.
PoC
Client
│
│ JSON (cells / wifi / ip)
▼
LBS Server (Go)
│
│ LocateDB -> ExternalDB
▼
PostgreSQL
Technologies
- Go
- PostgreSQL
- Docker / docker-compose
Project Structure
├── cmd/
│ └── server/ # точка входа
├── internal/
│ ├── app/ # HTTP handlers
│ ├── api/ # DTO + OpenCell client
│ └── db/ # DB, Logger
├── migrations/ # SQL миграции
├── docker-compose.yml
├── .env.example
└── README.md
Main API
POST /locate
Request Example
{
"sessionUUID": "optional",
"cell": [
{
"lte": {
"mcc": 310,
"mnc": 404,
"tac": 1,
"ci": 5632016
}
}
],
"wifi": []
}
If sessionUUID is not provided — the server generates it automatically.
Response
{
"sessionUUID": "generated-or-passed-uuid",
"location": {
"point": {
"lat": 41.366559,
"lon": -75.570403
},
"accuracy": 500
}
}
Running with Docker
docker-compose up -d
.env example:
# LocateDB (main database)
DB_DSN=postgres://admin:admin@localhost:55432/locatedb?sslmode=disable
# ExternalDB (CSV / OpenCell dump)
EDB_DSN=postgres://admin:admin@localhost:55433/externaldb?sslmode=disable
# UpdateDB
UDB_DSN=postgres://admin:admin@localhost:55434/updatedb?sslmode=disable
# Server
HTTP_ADDR=:8080
Migrations are applied manually:
psql postgres://admin:admin@localhost:55432/locatedb?sslmode=disable \
-f migrations/000001_create_sessions.up.sql
psql postgres://admin:admin@localhost:55432/locatedb?sslmode=disable \
-f migrations/000002_create_session_points.up.sql
Testing
curl -X POST http://localhost:8080/locate \
-H "Content-Type: application/json" \
-d '{
"cell": [
{ "lte": { "mcc": 310, "mnc": 404, "tac": 1, "ci": 5632016 } }
]
}'
Request Example
{
"sessionUUID": "deea0dba-0000-41a1-a1b4-8b6fc342b07d",
"cell": [
{
"lte": {
"mcc": 310,
"mnc": 404,
"tac": 1,
"ci": 5632016
}
}
]
}
Response Example
{
"sessionUUID": "deea0dba-0000-41a1-a1b4-8b6fc342b07d",
"location": {
"point": {
"lat": 41.366559,
"lon": -75.570403
},
"accuracy": 500
}
}
To import data into externaldb, use the following command:
COPY cells (
radio,
mcc,
mnc,
area,
cell,
unit,
strength,
lat,
lon
)
FROM '/external_data/cell.csv'
DELIMITER ','
CSV;