Practical work 3

Practical work 3

Link to the course

L. Delafontaine and H. Louis, with the help of GitHub Copilot.

This work is licensed under the CC BY-SA 4.0 license.

Practical work 3

Objectives (1/3)

  • Obtain a virtual machine on a cloud provider.
  • Access the virtual machine with SSH.
  • Install Docker and Docker Compose on the virtual machine.
  • Define some Docker Compose files to run the web application with a reverse proxy (Traefik).
Practical work 3

Objectives (2/3)

  • Deploy the simple CRUD API on the virtual machine.
  • Access the CRUD API from a domain name with HTTPS (Let's encrypt).
  • The CRUD API manages resources.
Practical work 3

Objectives (3/3)

  • You can choose what the CRUD API does/manages:
    • A music/video games/movies collection
    • A book library
    • A todo/groceries list
    • ...

The CRUD API must be accessible from the internet.

Practical work 3

Demo

The API for the demonstration is accessible at
https://heig-vd-dai-course.freeddns.org.

Practical work 3

Locally - Compile the project:

./mvnw clean package

Locally - Build the Docker image with Docker Compose:

docker build -t <docker tag> .

Locally - Publish the Docker image to the container registry:

docker push <docker tag>
Practical work 3

On the server - Pull the Docker image from the container registry:

docker compose pull

On the server - Start Traefik (the reverse proxy):

docker compose -f traefik/compose.yaml up -d

On the server - Start the CRUD API:

docker compose -f api/compose.yaml up -d
Practical work 3

Create a few drinks:

# Hot wine
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"name":"Hot wine","description":"Hot wine with spices","price":3.0}' \
  https://heig-vd-dai-course.freeddns.org/drinks

# Christmas tea
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"name":"Christmas tea","description":"Warm tea","price":2.0}' \
  https://heig-vd-dai-course.freeddns.org/drinks
Practical work 3

Get the list of drinks:

curl https://heig-vd-dai-course.freeddns.org/drinks

Output:

[
	{
		"id": 1,
		"name": "Hot wine",
		"description": "Hot wine with spices",
		"price": 3.0
	}
	// All the other drinks
]
Practical work 3

Filter the drinks with a price equal to 2.0 CHF:

curl https://heig-vd-dai-course.freeddns.org/drinks?price=2.0

Output:

[
	{
		"id": 2,
		"name": "Christmas tea",
		"description": "Warm tea",
		"price": 2.0
	}
]
Practical work 3

Get a specific drink:

curl https://heig-vd-dai-course.freeddns.org/drinks/1

Output:

{
	"id": 1,
	"name": "Hot wine",
	"description": "Hot wine with spices",
	"price": 3.0
}
Practical work 3

Update a drink:

curl -X PUT \
  -H "Content-Type: application/json" \
  -d '{"name":"Hot wine","description":"Nice hot wine","price":3.0}' \
  https://heig-vd-dai-course.freeddns.org/drinks/1

Output:

{
	"id": 1,
	"name": "Hot wine",
	"description": "Nice hot wine",
	"price": 3.0
}
Practical work 3

Delete a drink:

curl -X DELETE -i https://heig-vd-dai-course.freeddns.org/drinks/1

Output:

HTTP/2 204
content-type: text/plain
date: Sat, 16 Dec 2023 13:31:56 GMT

No content as we return a 204 (No Content) status code!

Practical work 3

Adding another drink with the same name:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"name":"Christmas tea","description":"Another tea","price":2.0}' \
  https://heig-vd-dai-course.freeddns.org/drinks

Output:

Conflict

Leads to a 409 (Conflict) status code as we want to keep the names unique.

Practical work 3

Get the schedules of the Baleinev hot wine week:

curl https://heig-vd-dai-course.freeddns.org/schedules

Output:

[
	{ "id": 0, "day": "MONDAY", "start": [10, 0], "end": [18, 0] },
	{ "id": 1, "day": "TUESDAY", "start": [10, 0], "end": [18, 0] },
	{ "id": 2, "day": "WEDNESDAY", "start": [10, 0], "end": [18, 0] },
	{ "id": 3, "day": "THURSDAY", "start": [10, 0], "end": [22, 0] },
	{ "id": 4, "day": "FRIDAY", "start": [10, 0], "end": [18, 0] }
]
Practical work 3

Group composition

More details for this section in the course material.

Practical work 3

Group composition

  • Two (2) or three (3) students per group.
  • Create a GitHub Discussion to:
    • Announce your group members.
    • Announce your idea (even a draft is fine).
  • You must do it before the next course, otherwise you will be penalized (check the Constraints for details).
Practical work 3

Idea validation

More details for this section in the course material.

Practical work 3

Idea validation

  • You must state your idea on your GitHub Discussion.
  • We might ask you to change your idea if it is too simple or too complex.
  • We will help you to find a good idea if needed.
  • You must do it before the next course!
Practical work 3

Grading criteria

More details for this section in the course material.

Practical work 3

Grading criteria

Based on 25 criteria and a three-point scale:

  • 0 point - The work is missing, off-topic, or shows a very limited understanding of the subject.
  • 0.1 point - The work shows partial understanding: some key elements are missing, unclear, or poorly implemented.
  • 0.2 point - The work is complete, accurate, and shows a clear and thorough understanding of the subject.

Maximum grade: 25 criteria * 0.2 + 1 = 6.

Practical work 3

Constraints

More details for this section in the course material.

Practical work 3

Constraints (1/3)

  • A demonstration of your web application is expected during the presentation.
  • The whole team must contribute to the project and all members must be able to explain it in details if asked.
  • A GitHub Discussion must be opened during the first week of the project to explain the idea of the project so the teachers can validate the idea.
Practical work 3

Constraints (2/3)

  • The GitHub Discussion must be updated with the link to the repository and a related commit hash before the deadline - every 24 hours after the deadline will result in a -1 point penalty on the final grade.
  • The web application can only use the HTTP/HTTPS protocols.
  • The web application must use the Javalin dependency to create the API.
  • The application must be slightly more complex and slightly different than the examples presented during the course (we emphasize the word slightly, no need to shoot for the moon).
Practical work 3

Constraints (3/3)

  • You must state your sources if you have used elements that you are not the author (code from the Internet, code generated from AI tools, etc.). You must also state for which usage you did use the source(s)/tool(s) in your README. If you plagiarize the code of another group, all groups involved will receive a grade of 1.
  • Elements that are supposed to be acquired through the teaching unit or previous practical work(s) must not be omitted, forgotten or poorly implemented (you must continue to use the Git/GitHub workflow, allow users to understand your application, etc.).
Practical work 3

Submission

More details for this section in the course material.

Practical work 3

Submission

Your work is due as follows:

  • DAI-TIC-C (Wednesday mornings): Tues. 20.01.26 at 23:59.
  • DAI-TIC-B (Wednesday afternoons): Wed. 21.01.26 at 11:59.
  • DAI-TIC-A (Thursdays): Wed. 21.01.26 at 23:59.

Update the GitHub Discussion with the link to your repository as mentioned in the course material.

If you do not submit your work on time and/or correctly, you will be penalized (-1 point on the final grade for each day of delay).

Practical work 3

Presentations

More details for this section in the course material.

Practical work 3

Presentations (1/2)

The practical work presentations will take place on:

  • DAI-TIC-C (Wednesday mornings): Wednesday 21.01.26 starting at 08:30 in room B51a.
  • DAI-TIC-B (Wednesday afternoons): Wednesday 21.01.26 starting at 13:00 in room B38.
  • DAI-TIC-A (Thursdays): Thursday 22.01.26 starting at 08:30 in room B51a.

The exact schedule will be communicated once the groups are known.

Practical work 3

Presentations (2/2)

We only have 8 minutes per group. You decide what you want to show us and how you want to present it. Come 5 minutes before your time slot with your computer. You will have access to a video projector.

The presentation order is random and is stated in the next tables:

Practical work 3

Grades and feedback

Grades will be entered into GAPS, followed by an email with the feedback.

The evaluation will use exactly the same grading grid as shown in the course material.

Each criterion will be accompanied by a comment explaining the points obtained, a general comment on your work and the final grade.

If you have any questions about the evaluation, you can contact us!

Practical work 3

Tips

More details for this section in the course material.

Practical work 3

Tips (1/2)

You are allowed to reuse your Bases de données relationnelles (BDR) project for this practical work.

You can decide to merge the two projects into one if you want or keep the idea and implement it in a different way (in memory for example, as you will see in the course materials).

Practical work 3

Tips (2/2)

However, you must ensure that you meet all the criteria of this practical work and that you respect all the constraints.

In our experience, it might be easier to start from scratch with a new idea. But you are welcome to try!

Practical work 3

Questions

Do you have any questions?

Practical work 3

Find the practical work

You can find the practical work for this part on GitHub.

Practical work 3

Finished? Was it easy? Was it hard?

Can you let us know what was easy and what was difficult for you during this practical work?

This will help us to improve the course and adapt the content to your needs. If we notice some difficulties, we will come back to you to help you.

➡️ GitHub Discussions

You can use reactions to express your opinion on a comment!

Practical work 3

Sources

(Un)comment the following lines to hide/show the note about the presentations

(Un)comment the following lines to hide/show the note about the presentations