It‘s useful to learn Js, but you already know how to do this in Java and can build it today.
Fawn was right. Most Android engineers have the skills to build basic backend apps given the best practices and libraries they already have. For instance, Retrofit can be used to make network requests with RxJava to handle the stream of incoming and outgoing data and do advanced manipulations while keeping the code bloat free with Kotlin. Using this approach I’ve started deploying backend instances to collect and manipulate data from multiple APIs. I’m working with Google Cloud Platform’s (GCP) AppEngine with Firebase integration to save data that can be accessed easily from a mobile/web client. Firebase can also integrate directly with Google’s BigQuery for further analytics (From Firestore to BigQuery with Firebase Functions).
Google Cloud Platform is easy to use once setup and insanely powerful. That said, knowing what you need to know is a research project in itself. After you have a rough outline of the steps required for your project then you can begin filtering through documentation and guides for the ones that match the end goal. The hope is that the steps and resources below save you a significant portion of time and allow you to jump right to the execution phase.
Hosting a Kotlin server app appears to have more setup than what I’ve seen advertised for Node.js with “one-click” deploys as seen on Digital Ocean, but once the process is setup with IntelliJ it takes under a minute to start the deploy. If you get into more complex computation there is also the inherit benefit of multi-threading with Kotlin/Java.
Figuring out the required steps required a scavenger hunt. I sifted through overlapping Google and IntelliJ documentation and guides regarding AppEngine Flexible vs Standard (still unsure of the important difference, I just know Flexible integrates well with both IntelliJ and GCP), Apache and Maven integration, Java website hosting, etc. None of the notes simply outlined how a Kotlin/Java needs to be formatted in order to be hosted onto a server.
Now into the details…
The good news is after an app is setup for the first time you can skip to Step 4: Managing The Server which takes less than 1 minute to setup a redeploy.
1. Follow the steps for Install the latest Cloud Tools…
a) Unzip directory and store in Library directory > call one level outside of cloud directory.
b) Restart Terminal for gcloud commands to work.
2. Install App Engine and Login.
sudo gcloud components install app-engine-java
gcloud auth application-default login
For current open project: choose Tools > Google Cloud Tools > Add AppEngine Support > Google AppEngine Flexible> select to create .yaml when given the choice and make sure it’s under src/main/appengine/app.yaml > when adding framework support choose projectModuleName (not projectName_main or projectName_test)
If the app is handling a task in order to populate data for a backend service that does not process user network requests than making sure only one instance is running is important. Otherwise multiple instances can populate the backend with duplicate data. (see Configuring your App with app.yaml)
File > Project Structure > Project Settings > Artifacts > + > Jar > From modules with dependencies…
Start/Stop server: You can control your server in the Google Cloud Console under AppEngine > Versions.
Redeploy future versions
AppEngine will take care of scaling automatically so it is important to understand the pricing and monitor the app if you are doing more than just prototyping.
I’m Adam Hurwitz — hit the clapping hands icon and check out the rest of my writing if you enjoyed the above. Thanks for reading!