6396f4e6abce833e6ce8587a6edab0f73604f5c8
Trip Planner
A multimodal trip planning service that uses Yandex.Schedules API to provide routing across different transport modes (planes, trains, buses). The service implements lazy graph expansion to work within API quota constraints and provides route visualization on maps.
Technology Stack
- Backend: Go
- Database: PostgreSQL (with PostGIS optional for geometry)
- Cache/Queue: Redis (native TTL)
- Frontend Map: Leaflet + OpenStreetMap tiles
- Task Scheduler: cron (internal
cmd/cronor system cron)
Quick Start
Running Locally with Docker Compose
docker-compose up -d
This starts:
apiservice: Go HTTP server on port 8080cronservice: Go cron binary for reference data updates and station status detectionpostgres: PostgreSQL 15-alpine on port 5432redis: Redis 7-alpine on port 6379watchtower: nickfedor/watchtower for automatic container updates (interval: 60s)
Running the API Server Directly
go run ./cmd/api
Running Cron Jobs
go run ./cmd/cron
Deployment
Docker Deployment
The project uses a multi-stage Dockerfile:
- Builder stage:
golang:1.26-alpineto buildapiandcronbinaries - Runtime stage:
alpine:latestwith minimal footprint (~27MB)
CI/CD Pipeline
Gitea Actions workflow (.gitea/workflows/deploy.yml) provides:
- Checkout code
- Setup Go 1.22+
- Go modules cache
- Lint with golangci-lint v1.54.2
- Run tests with race detector:
go test -v -race ./... - Docker Buildx setup
- Docker login to registry
- Build and push Docker image with tags:
latestand commit SHA
API Endpoints
GET /v1/cities?query=— City autocompleteGET /v1/cities/{id}/stations— City stations (including neighbors if main closed)POST /v1/routes/search— Search for routes (Pareto-optimal results)GET /v1/routes/{search_id}/{route_id}/geojson— Get route geometry for mapGET /v1/stations/{id}/status— Station statusPOST /internal/admin/stations/{id}/status— Manual station status override (requires auth)GET /v1/preferences/saved-cities?user_id=— Get user's saved citiesPOST /v1/preferences/saved-cities?user_id=— Add a city to user's saved citiesDELETE /v1/preferences/saved-cities/{city_code}?user_id=— Remove a city from user's saved citiesGET /v1/preferences/search-history?user_id=— Get user's search historyPOST /v1/preferences/search-history?user_id=— Add a search to user's historyGET /metrics— Get observability metrics (cache hit rates, API quota, circuit breaker trips, search duration)
Description
Languages
Go
91.1%
JavaScript
4.9%
CSS
2.5%
HTML
1.1%
Dockerfile
0.4%