This project was designed to leverage several Google Cloud Platform
cloud services to create a robust and automated system which can be interacted with via C++
code.
Why C++
? The use case of that programming language specifically in the context of this project would be, for example, to have a physical device which runs on C++
pull from the cloud the latest firmware
it needs. Or any kind of data.
Ultimately, a secure API to pull data from a BigQuery
database table was designed and it can actually be called by any programming language as long as the correct credentials get sent in json
format to the Auth_Func
.
The programming language Python
is utilized to create the entire backend component on Google Cloud Platform
.
Firebase
is also utilized as part of the authentication system.
Looker Studio
data visualization dashboard for viewing data from the BigQuery
table located here.
For testing of the API, if there is interest reach out directly via email here.
Google Cloud Platform
technologies:
-
Artifact Registry
- Stores the latest Docker image builds forCloud Run
-
BigQuery
- Data warehouse which stores the table of data we interact with -
Cloud Build
- Monitors GitHub repo and automates the process of deploying new code into the cloud -
Cloud Functions (Gen 2)
- The backend for the project. Within each Cloud Function is thePython
code. -
Cloud Run
- Generation 2 ofCloud Functions
is actuallyCloud Run
behind the scenes. ThereforePython
code executes here. -
Cloud Scheduler
- Cron job scheduler for any job in the cloud -
Cloud Storage
- Stores the latestPython
code for theCloud Functions
-
Looker Studio
- Data visualization tool -
Secret Manager
- Secure storage system for sensitive data
Firebase
technologies:
Authentication
- Stores the user account data
C++
--> Auth_Func
--> Compute_Func
--> BigQuery
Values of the 5 most recent records from the BigQuery table get returned to the C++
code in the end.
Auth_Func
- Publically Accessible (could be private as well)Compute_Func
- PrivateInsert_Int_Func
- Private
Let's talk about each:
Auth_Func
The authentication system.
-
Everything starts here. Way before any data can be extracted from the
BigQuery
database table, arequest
from the user has to pass multiple tests before the code can proceed. -
- The
request
cannot be empty and thejson
must have the correct keys,email
andpassword
.
- The
-
- The value of the
email
key of thejson
must be a string.
- The value of the
-
- The format of the value of the
email
key of thejson
must be in the correct format e.g."name@domain.com"
.
- The format of the value of the
-
- The value of the
password
key of thejson
must be a string.
- The value of the
-
- The
email
andpassword
must correlate to an existing user withinFirebase Authentication
.
- The
-
If everything checks out, then the
Compute_Func
Cloud Function
gets called directly from theAuth_Func
.
Compute_Func
The computation system. Computation in the sense of enumerating, listing out.
- The job of the
Compute_Func
is to simply extract the values of the 5 most recent records from aBigQuery
table. - Those values are then placed into a list.
- That list is converted to a string and then the string is returned to the
Auth_Func
.
Insert_Int_Func
The data insertion system.
- The
Insert_Int_Func
operates independently from theAuth_Func
andCompute_Func
and its automated. Insert_Int_Func
is triggered every 6 hours byCloud Scheduler
- A randomized integer between the ranges of 0-75 is inserted into a
BigQuery
table
Python
Programming Language
Backend was designed with Python
version 3.9
.
Libraries:
google-cloud-secret-manager==2.12.6
- PyPi url
google-cloud-bigquery==3.5.0
- PyPi url
python-dotenv==0.21.0
- PyPi url
Pyrebase4==4.5.0
- PyPi url
pyarrow==11.0.0
- PyPi url
pandas==1.5.3
- PyPi url
C++
Programming Language
Code tested and compiled on MacOS Ventura.
- Compiler:
g++
C++
Standard:17
How to run C++
code:
Be aware that preset credentials will be required to access the API.
- Open terminal
- Navigate to
C++/Cloud_Caller/src
folder - Type
g++ -o main main.cpp -lcurl
in terminal - Type
./main
in terminal
Libraries:
libcurl
- https://curl.se/libcurl/