Building an API

for Icelandic

You need some data

The Database of Modern Icelandic Inflection

tala;424804;so;alm;talar;GM-FH-NT-2P-ET

6.005.343

You need a database

  • One table, 6 columns
  • Read-only
  • Indexes

LevelDB is a light-weight, single-purpose library for persistence with bindings to many platforms.

  • Key-value storage
  • Keys are sorted lexicographically
  • Snappy compression
tala;424804;so;alm;talar;GM-FH-NT-2P-ET

Choosing a key

tala;424804;so;alm;talar;GM-FH-NT-2P-ET
 talar~tala;424804;so;alm;talar;GM-FH-NT-2P-ET
424804~tala;424804;so;alm;talar;GM-FH-NT-2P-ET

Creating indexes

# Raw data
% ls -lh ./data/all.csv
284M    ./data/all.csv

# LevelDB database
% du -h ./db
171M	./db

Creating the API

Deploying

Package apps with their environment

 

Run multiple apps on the same server without conflicts.

Heroku approach: git push

App builds inside the container

AppEngine approach: rsync

App builds locally.

Built files are stored in the container.

Dockerfiles

FROM busybox
VOLUME /code/db
ADD ./db /code/db
CMD /bin/sh

LevelDB database

FROM nodesource/node:latest
WORKDIR /code
ADD . /code
RUN npm install
EXPOSE 8000
CMD npm start

API

FROM nginx

COPY nginx.conf /etc/nginx/nginx.conf
COPY dist /usr/share/nginx/html

Ember app

# deploy.sh

eval "$(boot2docker shellinit)"
docker build -t davidblurton/tala-api . 
docker push davidblurton/tala-api
curl -X POST https://dashboard.tutum.co/api/...

@davidblurton

github.com/davidblurton/tala-api

slides.com/davidblurton/tala

api.tala.is

Building an API for Icelandic

By David

Building an API for Icelandic

  • 700