This repository contains an example system consitig of three web services that highlights the usage of Collector, Analyst, and Presenter in combination with the Apodini framework using ApodiniCollector and ApodiniAnalystPresenter. It features a database web service, a processing web service, and a gateway that offers the public API of the web service. All web services collect metrics and traces using the Collector framework. A client application allows developers to observe inisights generated using Analyst and pesented using Presenter:
You can start the web services on any system that supports docker and docker compose. Follow the instructions on https://docs.docker.com/compose/install/ to install docker and docker compose.
Xcode 13 (only available on macOS) is required to build and run the example client application. Follow the instructions on https://developer.apple.com/xcode/ to install the latest version of Xcode.
- Start the web services by running the
$ docker compose up
command in the root of the repository. It compiles and starts up all three web services as well as adjacently deployed Jaeger and Prometheus instances. - You can now interact with the API using your favorite tool to explore RESTful APIs. The section System Functionality includes a detailed description of the API endpoints.
- Start the client application by opening the Example.xcodeproj in the Client folder. Once the project you can start the application by following the instructions on Running Your App in the Simulator or on a Device
The system can collect locations shared by users and generates hotspots indicating frequently visited places. Please note that this is a demo system and does not include any authentication or authorization mechanisms.
Create a new location entry:
POST
at /v1/user/{userID}/location
, e.g. http://localhost/v1/user/1/location
with a payload encoded in JSON (header Content-Type
set to application/json
) that encodes a location: {"latitude": 0.0, "longitude": 0.0}`.
You can try out the following curl command to set a request to the gateway:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"latitude": 42.0, "longitude": 24.0}' \
http://localhost/v1/user/1/locations
Get hotspots
GET
at /v1/user/{userID}/hotspots
, e.g. http://localhost/v1/user/1/hotspots
that returns the calculated hotspots.
You can try out the following curl command to get a list of hotspots:
curl http://localhost/v1/user/1/hotspots
Metrics and Presenter Handler
In addition, the gateway includes a /v1/metrics
endpoint to deliver metrics information to Prometheus and a /v1/metrics-ui
endpoint that delivers the Presenter UI to the client application.
To easily continue developing the example system, you can open the Example.xcworkspace found at the root of the repo using Xcode. The workspace bundles all three web services and the client application. You can run and build the client application and web services as described in Running Your App in the Simulator or on a Device by selecting the corresponding scheme.
To test the collection of metrics and traces, you can run the $ docker compose -f docker-compose-development.yml up
command in the root of the repo start-up adjacently deployed Jaeger and Prometheus instances used by the web services. All web services are configured to connect to the instances started using the $ docker compose -f docker-compose-development.yml up
command.
To test the setup defined in docker-compose.yml
setup you can run the $ docker compose -f docker-compose-locally.yml up
to build all files locally using the source code in this repository while using the same setup as defined in docker-compose.yml
.
Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.
This project is licensed under the MIT License. See License for more information.