Kurs Parallele und Verteilte Systeme (Distributed Systems) WS23-24
-
Adding the Application logic (for demo purposes)
-
Add Controller(with ResponseEntity), Entity, Repo and Service
-
Using MongoDB, MongoCompass and Postman
-
Test Backend part
-
Implement OpenAPI Swagger
-
Create Fronted with React or Angular
-
Try out ReactJS and Create UI with Logic
-
Create Dockerfile for SpringAPI and ReactJS
-
Create a docker-compose.yml file
-
Use implementation language which is supported by OTel: https://opentelemetry.io/docs/instrumentation/
-
Using Java as implementation Language
-
Implemented OpenTelemetry and Jaeger for tracing
-
Implement Chakra UI for Frontend: https://chakra-ui.com/getting-started
The AnimalController
class is a part of the Animal Registry API and is responsible for handling various HTTP requests related to animals.
- Base URL Path:
/api/v1/animal
- Cross-Origin Requests: Allowed from any origin ("*")
- HTTP Method: POST
- Endpoint:
/save
- Description: Save an animal.
- Request Body: JSON object representing an
Animal
. - Response: The unique identifier (
animalid
) of the saved animal.
- HTTP Method: GET
- Endpoint:
/allanimals
- Description: Retrieve a list of all animals.
- Response: An
Iterable
collection ofAnimal
objects, representing a list of all animals in the registry.
- HTTP Method: PUT
- Endpoint:
/edit/{id}
- Description: Update an existing animal by its ID.
- Path Variable:
id
- Animal ID. - Request Body: JSON object representing an
Animal
. - Response: The updated animal.
- HTTP Method: DELETE
- Endpoint:
/delete/{id}
- Description: Delete an animal by its ID.
- Path Variable:
id
- Animal ID. - Response: No data. The animal is deleted.
- HTTP Method: GET
- Endpoint:
/search/{id}
- Description: Retrieve an animal by its ID.
- Path Variable:
id
- Animal ID. - Response: JSON object representing the retrieved
Animal
.
saveAnimal
: Save anAnimal
by callinganimalServices.saveorUpdate(animals)
and returning theanimalid
.getAnimals
: Get all animals by callinganimalServices.listAll()
.update
: Update anAnimal
by callinganimalServices.saveorUpdate(animal)
and returning the updatedAnimal
.deleteAnimal
: Delete anAnimal
by callinganimalServices.deleteAnimal(animalid)
.getAnimal
: Retrieve anAnimal
by its ID by callinganimalServices.getAnimalById(animalid)
.
AnimalServices
: Provides business logic and services related to animals. It likely includes methods for saving, updating, deleting, and retrieving animals.
This documentation provides an overview of the AnimalController
class in the Animal Registry API and its associated endpoints and methods.
This documentation provides an overview of the Docker Compose configuration used for your project. The Docker Compose file defines multiple services and their configurations.
- Image: mongo:latest
- Container Name: my-mongodb
- Ports: Maps host port 27017 to container port 27017
- Volumes: Maps a host directory
./data
to/data/db
in the container - Environment Variables: Configures the MongoDB root username and password
- Network: Attached to the
my-network
Docker network
- Build: Builds the Spring API from the specified Dockerfile context
- Container Name: my-app
- Ports: Maps host port 8081 to container port 8081
- Depends On: Requires MongoDB service to be running
- Environment Variables: Configures MongoDB URI, database name, and OpenTelemetry parameters
- Network: Attached to the
my-network
Docker network
- Build: Builds the React app from the specified Dockerfile context
- Container Name: react-app
- Ports: Maps host port 3000 to container port 3000
- Depends On: Requires Spring API service to be running
- Environment Variables: Configures the API URL
- Network: Attached to the
my-network
Docker network
- Image: jaegertracing/all-in-one:latest
- Ports: Maps host ports 16686 and 14250 to container ports
- Network: Attached to the
my-network
Docker network
- Network: Defines a custom Docker network named
my-network
to connect the services and enable communication between them.
- The Docker Compose file defines three services: MongoDB, Spring API, and React App.
- MongoDB is used to provide a database for your Spring API.
- The Spring API is built from the
./AnimalRegistry
context and connects to the MongoDB service using environment variables. - The React App is built from the
./animalui
context and connects to the Spring API service. - The services have interdependencies based on the order of execution.
This Docker Compose configuration sets up your project environment, allowing the Spring API and React App to interact with a MongoDB database.
# Getting Started with Your Project
This guide will walk you through the steps to start your project using Docker Compose. Ensure you have Docker and Docker Compose installed on your system before proceeding.
## Prerequisites
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)
## Initial Setup
1. Clone the project repository to your local machine:
```shell
git clone https://github.com/your-username/your-project.git
cd your-project
-
Create a
.env
file in the project directory to specify environment variables. Here's an example of what the.env
file might look like:# MongoDB MONGO_INITDB_ROOT_USERNAME=root MONGO_INITDB_ROOT_PASSWORD=example # Spring API SPRING_DATA_MONGODB_URI=mongodb:https://root:example@mongodb:27017 SPRING_DATA_MONGODB_DATABASE=animaldb # React App REACT_APP_API_URL=http:https://spring-api:8081
- Make sure you have Docker installed on your system.
-
Clone Your Project:
- If you haven't already, clone your AnimalRegistry project to your local machine.
-
Navigate to the Project Directory:
- Open a terminal or command prompt and navigate to your project's root directory.
-
Update Your Docker Compose File:
- Ensure that your
docker-compose.yml
file is properly configured according to the Docker Compose configuration you've shared.
- Ensure that your
-
Build and Run Your Docker Compose:
- Run the following command to build and start your services:
docker-compose up
This command will start your MongoDB, Spring API, React app, OpenTelemetry collector, and Jaeger services.
- Run the following command to build and start your services:
-
Access Your Application:
- After the services are up and running, you can access your application as follows:
- Your Spring API should be available at: http:https://localhost:8081
- Your React app should be available at: http:https://localhost:3000
- Jaeger UI for tracing can be accessed at: http:https://localhost:16686
- After the services are up and running, you can access your application as follows:
-
Access Jaeger Traces:
- To view traces in Jaeger, navigate to http:https://localhost:16686 in your web browser. You should be able to see traces as you use your application.
-
Test Your Application:
- Interact with your application (e.g., make HTTP requests, submit data, etc.) to generate traces.
-
View Traces in Jaeger UI:
- In Jaeger UI, you should see traces generated by your application. You can filter, search, and analyze the traces to monitor the behavior of your services.
-
Stop Your Project:
- When you're done, you can stop your project using the following command:
docker-compose down
This will stop and remove the containers, but it won't remove the data volume you've created for MongoDB. To remove that as well, you can use
docker-compose down -v
. - When you're done, you can stop your project using the following command:
And that's it! You should now have your project up and running with OpenTelemetry and Jaeger for tracing. You can interact with your application and analyze traces using Jaeger UI.