No description
  • Go 88.7%
  • HTML 8.9%
  • Shell 1.1%
  • Makefile 1%
  • Dockerfile 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-07-29 15:23:12 +03:00
cmd/server add rate limiting for escaping ddos attacking (#3) 2026-05-18 11:45:12 +03:00
demo PoC: реализация ручек locate и update (#2) 2026-04-27 21:21:32 +03:00
icons/university Загрузить файлы в «icons/university» 2026-07-29 15:23:12 +03:00
internal add rate limiting for escaping ddos attacking (#3) 2026-05-18 11:45:12 +03:00
migrations Po c (#4) 2026-05-20 14:26:39 +03:00
scripts PoC: реализация ручек locate и update (#2) 2026-04-27 21:21:32 +03:00
systemd PoC: реализация ручек locate и update (#2) 2026-04-27 21:21:32 +03:00
.gitignore add rate limiting for escaping ddos attacking (#3) 2026-05-18 11:45:12 +03:00
docker-compose.yml add rate limiting for escaping ddos attacking (#3) 2026-05-18 11:45:12 +03:00
Dockerfile PoC: реализация ручек locate и update (#2) 2026-04-27 21:21:32 +03:00
go.mod PoC: реализация ручек locate и update (#2) 2026-04-27 21:21:32 +03:00
go.sum add rate limiting for escaping ddos attacking (#3) 2026-05-18 11:45:12 +03:00
LBS server TZ draft.pdf PoC: реализация ручек locate и update (#2) 2026-04-27 21:21:32 +03:00
lbs-server.env.example add rate limiting for escaping ddos attacking (#3) 2026-05-18 11:45:12 +03:00
LICENSE init commit 2025-11-16 22:48:48 +03:00
Makefile add rate limiting for escaping ddos attacking (#3) 2026-05-18 11:45:12 +03:00
README.en.md Машинный перевод файла README.md 2026-07-29 15:22:21 +03:00
README.md PoC: реализация ручек locate и update (#2) 2026-04-27 21:21:32 +03:00

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:

  1. First — from its own database (LocateDB)

  2. Then — from an external database (ExternalDB, CSV / OpenCell dump)

  3. When coordinates are found — saves the point to the session database

  4. 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;