The blog application is a fictitious blog system demonstrating microservices as well as domain-driven-design.
The system provides the functionality of creating blogs, posts and comments as well as user authentification and authorisation. Furthermore, statistics over activities are kept.
The following diagram shows an overview of the blog microservices, datastores and the interaction between these components, as well as the used technologies of each.
Microservices and components running in a Kubernetes Cluster:
-
The Config Service backend is a Spring Cloud Config server. It provides the configuration for most of the microservices. On any time, they can pull their configuration.
-
The Blog Service backend is a Spring Boot application. It is the core domain and manages the blogs and posts. On startup it loads the configuration of the Config Service. To store the blog data, it uses the
Blog Database
, a Google Cloud Datastore and caches the blog data inBlog Cache
a Google Cloud Memorystore for Redis. It also interacts with theEvent Bus
, a Google Cloud PubSub, where other microservices can subscribe to. -
The Auth Service backend is a Spring Boot application. It is responsible for the creation and verification of user accounts over JSON Web Tokens (JWT). On startup it loads the configuration of the Config Service. To store the user data, it uses the
User Database
, a PostgreSQL database in Google Cloud SQL. -
The Comment Service backend is a Spring Boot application. It is responsible for the comments of the blog posts. On startup it loads the configuration of the Config Service. To store the comment data, it uses the
Blog Database
. -
The Statistic Service backend is a Spring Boot application. It is responsible for keeping statistic over blog activities, such as viewing a blog post. On startup it loads the configuration of the Config Service and subscribes to the
Event Bus
to get the events. To store the statistic data, it uses theStatistic Database
, a Google Cloud Datastore. -
The Gateway / Router backend is a Spring Cloud Gateway server. It is responsible for the routing to the Frontend as well to the microservices. On startup it loads the configuration of the Config Service. The Gateway / Router is accessible through the
HTTP Router
, a Google Cloud Ingress. -
The Frontend is a static Angular webpage with Bootstrap, served by a NGINX webserver.
The detailed instruction for each service can be found in the README file of the associated subfolder.
- Docker installed and runnable without
sudo
(https://docs.docker.com/install/linux/linux-postinstall/) - Google Cloud SDK installed
- Google Cloud Account (You'll get a 300$ test budget if you connect a new account to GCP)
- Java 8 installed
- Node (npm) installed
Authorize gcloud:
gcloud auth login
gcloud auth application-default login
Install kubectl
gcloud components install kubectl
Configure docker
gcloud auth configure docker
Make sure that the prequisites are fullfilled
Open variables.properties
and change GCP_PROJECT_NAME
to a unique name, which isn't used in any other google cloud project.
NOTE: The
setup-local
script may take up to 5 minutes.
- Run
setup-local
- The script will open the webbrowser for your project to activate payment for this project. Press any key to continue.
- Navigate to http://localhost:8181 to open the Blog-Application.
The local build will generate following:
- Google Cloud Project with name and zone configured in
variables.properties
and payment enabled - App Engine
- Enable datastore.googleapis.com API
- Run projects locally
The Google Cloud Project is on the local build only needed for the Datastore
.
NOTE: The
setup-cloud
script may take up to 20 minutes.
- Run
setup-cloud.bat
orsetup-cloud.sh
- The script will open the webbrowser for your project to activate payment for this project. Press any key to continue when payment is activated.
- Go to https://console.cloud.google.com to your project (you may must reload the whole page to see kubernetes cluster).
Navigate to
Kubernetes Engine > Services
and click on thegateway-microservice
url to open the Blog-Application.
The cloud build will generate following:
- Google Cloud Project with name and zone configured in
variables.properties
and payment enabled - App Engine
- Enable
compute.googleapis.com
API - Enable
container.googleapis.com
API - Enable
datastore.googleapis.com
API - Enable
storage-component.googleapis.com
API - Enable
pubsub.googleapis.com
API - Enable
redis.googleapis.com
API - Enable
sqladmin.googleapis.com
API - Create Kubernetes Cluster
application
- Deploy all microservices
To prevent the project to constantly create you costs, you can simply delete the whole project and you won't have any further costs:
gcloud projects delete [GCP_PROJECT_NAME]
If you are inerested in what development tools could be used, have a look at the Devtools Folder.
- Moritz Habegger
- Micha Schena
This project is made available under the MIT License. See the LICENSE file for the full license.
The logos used in the diagrams are registered trademarks of Google LLC (Google Cloud), Pivotal Software Inc (Spring), Docker Inc. (Docker), Salvatore Sanfilippo (Redis) and Igor Sysoev (nginx).