A Sample Web App in Kotlin with Neo4j and GraphQL

View on Github

Aside from finding your exact question already answered on Stack Overflow, few things are more delightful in the world of programming than starting a new project. Maybe you think your code will eventually be used by Elon Musk or maybe you're just hoping to generate enough ad revenue to cover your late night fro-yo addiction. Regardless, you probably already know your tech is going to be something Richard Hendricks would marvel at.

For those who aren't already married to their stack, however, might I suggest 3 technologies to consider when writing a back-end application. These 3 technologies land somewhere in the middle on the spectrum of 'new hottness' to 'tried-and-true' which I believe is the right place to be when starting a new project.

  1. Kotlin. Kotlin is a programming language that runs on the JVM and is interoperable with Java (Android developers rejoice). Like most modern languages, Kotlin is less verbose, supports generics, includes functional syntax, and is strongly typed. This last feature, strong typing, is my #1 recommendation for anyone starting a new project. As you rapidly iterate on your new codebase, having a compiler that can tell you when you've done something stupid will save you hours of debugging that could otherwise be spent binge-watching Stranger Things. As a long time iOS developer this may sound like heresy, but coding in Kotlin is a much better experience than coding in Swift. Sorry Steve.

  2. GraphQL. We finally have the blueprint for how to write an API and it's called GraphQL. Not too long ago, when developing a client app that talked to a server, you would need to create a new version of your endpoint whenever the data your app needed would change. Or maybe the format of your response payload was unintuitive or undocumented. With GraphQL your server can expose one endpoint by which your data can be queried against in a typed and consistently formatted way, without the need for versioning, which can be very useful for immature projects.

  3. Neo4j. If your domain objects are related to one another, then your datamodel can be represented as a graph. Neo4j is a Graph DBMS that is very easy to get up and running and has a ton of documentation to help you along the way. While most developers instinctively choose a relational databases when it comes to data persistence, NoSQL and graph databases like Neo4j do offer a couple advantages. For one, NoSQL databases are horizontally scalable. Secondly, NoSQL means there are no schema migrations, which are most common during the early stages of an app's development (though, this doesn't mean the data being persisted wont need to change the representation in which it is stored). Neo4j also offers an object-graph-mapper (ogm) which makes using Neo4j look very similar to using a typical relational database with an orm.

To help you get started, I've posted an example app which uses these 3 technologies and exposes a Starwars based API.

View on Github

Show Comments