sbt (Kalix) and typescript based multiproject as a template for frontend with microservices backend
Domain documentation that will (eventually) generate code for services
Includes common objects used for creating protobuf messages
A library for common Scala functions & service extensions (Auth)
This template includes 2 Kalix services to be customized as desired to create microservices The template offers example of how to create service types, either by deploying together (bounded-context) or as a separate deployable (service3)
bounded-context
- Service 1 (Action w/ Event Sourced Entity that is consumed by NoDataView)
- Service 2 (just an Action)
- Service 3 (Value Entity w/ View)
The Kalix Gateway will serve as the interface between the client & the microservices The Gateway contains integration tests for all services
The front-end client PWA (typescript)
Email & OIDC/JWK capabilities
integration-testkit
contains extensions to the Kalix testkit that allow for testing a multi-deployment system
integration-testkit-tests
contains the tests themselves
Includes ScheduledTaskAction
, a trait implementing Start
, Run
, and RunForTest
, which allows for enabling
scheduled actions
In the example, every 2 hours, DoNothingService1
implements a DoNothingAction
call to Service1
and then reads
from NoDataView
npm install --global protoc-gen-js
For more info, see link
After downloading an appropriate image, execute
$ sudo mv ~/Downloads/protoc-gen-grpc-web-1.5.0-darwin-x86_64 \
/usr/local/bin/protoc-gen-grpc-web
$ chmod +x /usr/local/bin/protoc-gen-grpc-web
for Mac or a similar command for Lunix.
See grpc-web docs more thorough instructions
To run any of the Kalix services locally, use the following command:
sbt "{service-name}/runAll -Dlogback.configurationFile=logback-local.xml -Dconfig.resource=integration-test.conf"
So for example, to run the gateway
service locally, run:
sbt "gateway/runAll -Dlogback.configurationFile=logback-local.xml -Dconfig.resource=integration-test.conf"
The integration tests can be run locally via the command sbt "integration-test/test"
In order to publish and deploy the Kalix services to the Kalix cloud, you'll need to perform the following:
-
Setup Kalix auth and Kalix / docker integration locally.
- Follow the instructions here: https://docs.kalix.io/projects/container-registries.html
-
Create a Kalix auth token and
export
it in your shell environment.- Run
kalix projects tokens create --description "Some token description"
after authentication to create the token - Export the token via
export KALIX_TOKEN="{the token data}"
(Note: the environment variable name must matchKALIX_TOKEN
exactly!)
- Run
-
Use sbt to build and publish container images for all deployable services.
- Simply run
sbt publishContainers
- Simply run
-
Use sbt to deploy the built and published containers
- Simply run
sbt deployServices
- Simply run
-
Use the "health-check" to verify that the services are running.
- Run
grpcurl -d '{}' api.off-the-top.io:443 com.ott.gateway.Gateway/HealthCheck
from your shell if you havegrpcurl
installed - Alternatively, you can curl or browse:
https://api.off-the-top.io/health-check
- Run
Note: there is also a compound command publishAndDeploy
which will run steps #3 and #4 back to back for you.
Make sure first to run the script proto-gen
. Then use the command npm start
to get the app running in browser.
- Copy the local configuration template file from
gateway/src/user-local.conf.template
togateway/src/user-local.conf
Don't worry, it is in the.gitignore
, so your local changes will not be pushed up to the git server! - Follow the instructions in
gateway/src/Test-Setup-Instructions.md
- Profit!
Simply run this command:
sbt "gateway/test:runMain com.example.gateway.LocalCorsProxy"
...after the Gateway and related services are started.