Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



31 Commits

Repository files navigation

flightranker-backend is the back-end code for This was largely an experiment in software organization, so there are actually three back-ends:

All three are functionally identical. You can read more about it on my blog.

Set up


You will need to set up and populate a MySQL database before running either backend. For local development, try:

docker run -d -p 3306:3306 --name=flightdb -e MYSQL_ROOT_PASSWORD=flightdb -e MYSQL_USER=flightdb -e MYSQL_PASSWORD=flightdb -e MYSQL_DATABASE=flightdb mysql/mysql-server:5.7

The files in the sql directory will set up the schema and populate the airports and carriers tables:

cat sql/*.sql | mysql -uflightdb -pflightdb -h flightdb

The load program will populate the flights table. See load/ for details. The test data was generated from a database loaded with only the following months:

After the data has been loaded, run the SQL files in sql/updates:

cat sql/updates/*.sql | mysql -uflightdb -pflightdb -h flightdb


All configuration is read from environment variables, each backend reads the following:

  • MYSQL_ADDRESS: Network address for the database (e.g.
  • MYSQL_DATABASE: Database name
  • MYSQL_USER: Username for MySQL
  • MYSQL_PASS: Password for MySQL
  • CORS_ALLOW_ORIGIN: Value to return in the Access-Control-Allow-Origin header. If this variable is not set, the header is omitted.


Each backend can be run in the usual Go way:

cd backendA && go install && backendA
cd backendB && go install && backendB
cd backendC && go install && backendC


Database tests in all the backends require the same set of environment variables as the backend server.

MYSQL_USER=flightdb MYSQL_PASS=flightdb MYSQL_ADDRESS= MYSQL_DATABASE=flightdb go test ./...


There is a Dockerfile in root of the repository that can be used for either backend.

For backendA:

docker build . -t flightranker-backend-a --build-arg which=backendA

For backendB:

docker build . -t flightranker-backend-b --build-arg which=backendB

For backendC:

docker build . -t flightranker-backend-c --build-arg which=backendC


On-Time performance data are provided by the US Bureau of Transportation Statistics.

The list of airports was taken from


No description, website, or topics provided.






No releases published


No packages published