All Projects → CodingDoug → backends-for-android

CodingDoug / backends-for-android

Licence: Apache-2.0 license
Sample project to accompany my conference talk "Easy, scalable backends for Android"

Programming Languages

kotlin
9241 projects
shell
77523 projects
Dockerfile
14818 projects
typescript
32286 projects

Projects that are alternatives of or similar to backends-for-android

nx-extend
Nx Workspaces builders and tools
Stars: ✭ 67 (+252.63%)
Mutual labels:  cloud-functions, cloud-run
Angularfire
The official Angular library for Firebase.
Stars: ✭ 7,029 (+36894.74%)
Mutual labels:  cloud-functions
functions-framework-php
FaaS (Function as a service) framework for writing portable PHP functions
Stars: ✭ 186 (+878.95%)
Mutual labels:  cloud-functions
spica
Spica is a development engine to build fast & efficient applications.
Stars: ✭ 77 (+305.26%)
Mutual labels:  cloud-functions
dataflow-contact-center-speech-analysis
Speech Analysis Framework, a collection of components and code from Google Cloud that you can use to transcribe audio files to create analytics.
Stars: ✭ 46 (+142.11%)
Mutual labels:  cloud-functions
end-to-end-machine-learning-with-google-cloud
End to End Machine Learning with Google Cloud Platform
Stars: ✭ 39 (+105.26%)
Mutual labels:  cloud-functions
firebase-jest-testing
Firebase back-end testing, using Jest.
Stars: ✭ 21 (+10.53%)
Mutual labels:  cloud-functions
cloud-functions-boilerplate
An ever-evolving, opinionated architecture, starter kit, and development environment for writing and structuring google cloud functions for firebase.
Stars: ✭ 40 (+110.53%)
Mutual labels:  cloud-functions
Miniprogram Demo
微信小程序组件 / API / 云开发示例
Stars: ✭ 5,207 (+27305.26%)
Mutual labels:  cloud-functions
tyfon
typed functions over network
Stars: ✭ 38 (+100%)
Mutual labels:  cloud-functions
universal-translator
Demo app using Firebase and Google Cloud products to implement a "universal translator"
Stars: ✭ 37 (+94.74%)
Mutual labels:  cloud-functions
argon
Campaign Manager 360 and Display & Video 360 Reports to BigQuery connector
Stars: ✭ 31 (+63.16%)
Mutual labels:  cloud-functions
node-starter-kit
Node.js / GraphQL project template pre-configured with TypeScript, PostgreSQL, login flow, transactional emails, unit tests, CI/CD workflow.
Stars: ✭ 76 (+300%)
Mutual labels:  cloud-functions
app
Source code of intencje.pl website and mobile/desktop apps based on Angular, Firebase, and Capacitor.
Stars: ✭ 12 (-36.84%)
Mutual labels:  cloud-functions
container-builder-github-ci-status
Google Cloud Function responds to PubSub events on the cloud-builds topic to update GitHub CI status.
Stars: ✭ 23 (+21.05%)
Mutual labels:  cloud-functions
fireschema
Strongly typed Firestore framework for TypeScript
Stars: ✭ 193 (+915.79%)
Mutual labels:  cloud-functions
barber-shop
Vue + Firebase (cloud functions, auth, firestore, hosting) reservations system
Stars: ✭ 47 (+147.37%)
Mutual labels:  cloud-functions
fb-watson
Hands-on developing an application using IBM Watson services with Facebook Messenger integrated through serverless functions
Stars: ✭ 19 (+0%)
Mutual labels:  cloud-functions
hnpwa-api
CDN cached Hacker News API
Stars: ✭ 73 (+284.21%)
Mutual labels:  cloud-functions
cloudrun-tutorial
A tutorial showing some of the features of Cloud Run
Stars: ✭ 79 (+315.79%)
Mutual labels:  cloud-run

Easy, scalable backends for Android developers

This is the sample project to accompany my conference talk "Easy, scalable backends for Android developers". There are two primary use cases illustrated here, with both frontend and backend code provided. The frontend is an Android app that uses Kotlin, coroutines, Jetpack architecture components, and MVVM. The backend is hosted on Firebase / Google Cloud.

The top-level components in this repo are:

The information and instructions here require that you're familiar with these processes:

  1. Creating a Firebase / Google Cloud project and adding an Android app to it (documentation)
  2. Deploying code to Cloud Functions using the Firebase CLI
  3. Deploying code to Cloud Run using the Google Cloud SDK (gcloud)

Please note that a Firebase project is a Google Cloud project. If you create a Firebase project, you are also implicitly creating a Google Cloud project, and you have all the features and benefits of Google Cloud available in your Firebase project. To better understand the relationship between Firebase and Google Cloud, read this blog.

Cloud Functions: Firebase callable function (TypeScript, nodejs)

This repo contains sample code that shows how an Android app can invoke a Firebase callable function using the provided SDKs.

Note that it's possible to deploy and run this code on the Firebase free Spark plan.

To run this sample:

  1. Create a Firebase project and add the Android app in this repo to it.
  2. Deploy the Cloud Functions code using the Firebase CLI.
  3. Launch the Android app and press the "invoke callable sum" button.

Deployment with the Firebase CLI goes like this:

cd cloud-functions-ts
firebase deploy

The output should show that the function called "sum" was successfully deployed.

In the Android app, when you ress the "invoke callable sum" button, it will use the Firebase Functions SDK to invoke the function and get a sum of two integers, as defined in the client source code.

Cloud Run: HTTP endpoints (Kotlin, coroutines, ktor, kotlinx.serialization)

This repo contains sample code that shows how an Android app can invoke a backend deployed to Cloud Run using Kotlin and ktor.

Your Firebase project must be on a payment plan in order to deploy and run this sample. For basic experimentation, you are highly unlikely to incur any actual costs, as there is a perpetual free allowance for all of the Firebase and Google Cloud products in use here. If you a concerned about future charges, then you can simply delete the project or disable billing after you're done experimenting with it.

Summary of steps to run the sample:

  1. Create a Firebase / Google Cloud project, or reuse the one from the prior sample.
  2. Build and deploy the Cloud Run code using gcloud (using the commands in the provided deploy.sh script)
  3. Note the base URL of the deployment in the output. It will have a domain of "run.app".
  4. Edit android/app/src/main/res/values/strings.xml and copy the base URL into the cloud_run_root string resource.
  5. Run the Android app and press the "invoke cloud run endpoint" button.

Note that it can be time-consuming to get started with Google Cloud if you don't have an experience with it, and the instructions here are not comprehensive. You will likely need to spend some time sorting through the documentation in order to get acquainted with how Google Cloud and its CLI and console work. You should also study the Cloud Run documentation to better understand how to navigate the product and the Google Cloud console.

You should have the Google Cloud SDK (particularly, the gcloud CLI) installed and configured to deploy the backend code to Cloud Run. You will also need a unique name for your app to put in place of the $APP_NAME variable below in order to build and deploy a container to Cloud Run:

cd cloud-run
./deploy.sh $PROJECT_NAME $APP_NAME

$PROJECT_NAME is the name of your project, and $APP_NAME is the name of your Cloud Run app (also called a "service"). Examine the deploy.sh shell script to see the gcloud commands that it runs to build and deploy a docker image to Cloud Run. If the Cloud Run app you named here doesn't exist, it will be created. If you are prompted for anything during deployment, take the defaults.

If you are running an OS that can't run unix shell scripts, you will have to reverse-engineer the gcloud commands in build.sh for build and deployment.

When the deployment finishes, you will recevie a base URL for your HTTP endpoints. For example, the last line of output should look like this:

Service [helloworld] revision [helloworld-00008-sih] has been deployed and is serving 100 percent of traffic.
Service URL: https://helloworld-jtdztnhypa-uc.a.run.app

Cloud Functions: HTTP function (Kotlin)

This repo contains sample code that shows how to write an HTTP Cloud Function using Kotlin and deploy it with gcloud.

  • Cloud Functions / Kotlin code in package under cloud-functions-kt.
  • Android / Kotlin code is the same as in the Cloud Run example above. It just needs to be configured to hit the Cloud Functions endpoint rather than Cloud Run.

Your Firebase project must be on a payment plan in order to deploy and run this sample. For basic experimentation, you are highly unlikely to incur any actual costs, as there is a perpetual free allowance for all of the Firebase and Google Cloud products in use here. If you a concerned about future charges, then you can simply delete the project or disable billing after you're done experimenting with it.

Summary of steps to run the sample:

  1. Create a Firebase / Google Cloud project, or reuse the one from the prior sample.
  2. Build and deploy the Cloud Functions code using gcloud (using the commands in the provided deploy.sh script)
  3. Note the base URL of the deployment in the output. It will have a domain of "cloudfunctions.net".
  4. Edit android/app/src/main/res/values/strings.xml and copy the base URL into the cloud_run_root string resource (without the /nextVersion path).
  5. Run the Android app and press the "invoke cloud run endpoint" button.

You should have the Google Cloud SDK (particularly, the gcloud CLI) installed and configured to deploy the backend code to Cloud Run.

cd cloud-functions-kt
./deploy.sh $PROJECT_NAME $FUNCTION_NAME $ENTRY_POINT

$PROJECT_NAME is the name of your project, $FUNCTION_NAME is the name of the function to deploy (e.g. nextVerion), and $ENTRY_POINT is the full name of the class the handles execution (com.hyperaware.bfa.cloudfunctions.NextVersion). Examine the deploy.sh shell script to see the gcloud commands that it runs to deploy the function.

If you are running an OS that can't run unix shell scripts, you will have to reverse-engineer the gcloud commands in build.sh for build and deployment.

When the deployment finishes, you will recevie a base URL for your HTTP endpoints. For example, there should be output that looks like this:

httpsTrigger:
  url: https://us-central1-$PROJECT_NAME.cloudfunctions.net/$FUNCTION_NAME
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].