September 1, 2014

MonMet: ionic experiment

This is a weekend project, I wanted to use ionic framework for a complete little project. I discovered that the Met (official bus company in Metz) official application is completely bloated, you can’t search easily for bus stations, the UI is SLOW, and you can’t save favorites, nor see easily the timetable.

So here it is, a small weekend project using ionic, spring boot and redis. The code is available on Github.

Big problem was that the official site does not provide an API to fetch the timetables, the bus stops and so on.

MonMet

MonMet is a free mobile application that let user saves the time tables of his favorite bus stops and have a quick look on them whenever he wants.

The application is composed of:

  • A mobile application using ionic framework.
  • A backend using spring boot and redis.

Screenshots

Home page Bus stop view

Dependencies

  • Java 7
  • Maven 3+
  • Redis
  • ionic framework

Running the Backend

Run redis

redis-server

Init redis

cat src/main/resources/init.redis | redis-cli --pipe

Run the backend

mvn package
nohup java -jar target/MonMet*.jar &

REST API

Method Path Description
GET /api/lines Get the available lines bus lines.
GET /api/lines/{lineId} Get the available heads (directions) for a specific line
GET /api/lines/{lineId}/{head} Get the available stops for a specific line and head
GET /api/tt/{lineId}/{head}/{stopId}?stopName={stopName} Get the timetable for a specific line, head and stop
GET /api/coords/{lineId}/{stopName} Get the coordinates for a specific stop of a bus line.

Sample JSON

GET /api/lines

{
    "Mettis": [
        {
            "id": "998",
            "name": "A",
        },
        {
            "id": "999",
            "name": "B",
        }
    ],
    ...
}

GET /api/lines/{lineId}

{[
    "CITE U",
    "MATERNITE",
    ...
]

GET /api/lines/{lineId}/{head}

[
    {
        "id": "21327",
        "name": "REPUBLIQUE",
    },
    {
        "id": "31329",
        "name": "CITE U",
    },
    ...
]

GET /api/tt/{lineId}/{head}/{stopId}?stopName={stopName}(&timestamp={timestamp})

{
    "week": [
        "05:18",
        "05:36",
        "06:10",
        "06:28",
        "06:43",
        ...
    ],
    "saturday": [
        "05:18",
        "05:36",
        "06:06",
        "06:36",
        ...
    ],
    "sunday": [
        "05:18",
        "06:36",
        "07:12",
        "08:05",
        "08:35",
        ...
    ],
    "nextRides": [
        "19:06",
        "19:16",
        "19:26"
     ]
}

GET /api/coords/{lineId}/{stopName}

{
    "lat": 49.121565,
    "lon": 6.175176
}

Alexandre Grison - //grison.me - @algrison