aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: d5c9139e8db1b4ea1d88ea6e03503c338dd9a6f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Tracktrain

*experimental, don't expect things to work for now*

A thing to track trains via GPS (eventually), generating real-time data for use
in e.g. passenger information systems. Timetables are read in via GTFS.

## Server
I run a test-deployment of this at (tracktrain.stuebinm.eu)[https://tracktrain.stuebinm.eu].

### API
It self-generates an OpenAPI description of the currently implemented routes at
(`/api/openapi`)[https://tracktrain.stuebinm.eu/debug/openapi].

### Metrics
It offers prometheus-compatible metrics under /metrics. Run the server with `+RTS -T`
to also get metrics on the ghc runtime system (via the [prometheus-metrics-ghc](https://hackage.haskell.org/package/prometheus-metrics-ghc-1.0.1.2/docs/Prometheus-Metric-GHC.html
))
package.

## Routes
The entire app is written as a single monolithic webserver, so you might want
to restrict access via a reverse-proxy:
 - /api must be public (otherwise tracking won't work)
 - /api/openapi is a self-description of the API endpoints
 - /obu is the onboard-unit for tracking
 - /metrics is a prometheus-compatible metrics endpoint
 - everything else (including /) is part of the admin interface


## Packages & Modules

This project is split into a few haskell packages:
 - the tracktrain executable in `app/`, handling startup & config
 - the tracktrain library implementing the business logic in `lib/`
 - the gtfs realtime library (generated with `hprotoc` from the gtfs realtime 
   proto file, along with a very little glue code in `Servant.GTFS.Realtime`)
   in `gtfs/`
 - that's it for now, but there'll probably be more