Skip to content

Backend repository for voluntary project in IDATT2105 full-stack application development

License

Notifications You must be signed in to change notification settings

EmilJohns1/idatt2105-project-backend

Repository files navigation

IDATT2105-PROJECT-BACKEND

Backend repository for voluntary project in IDATT2105 full-stack application development

Setup

This is the backend for a fullstack project. The project should be run using the docker-compose.yml file, as it requires multiple environment variables, as well as dev-certificates which are currently generated using the mkcert-tool.

This guide requires:

  • A pc with docker installed
  • The ability to set environment variables

Setting an environment variable is done by running set KEYSTORE_PASSWORD=changeit (Windows) or by export KEYSTORE_PASSWORD=changeit (Unix). If, for whatever reason, you are unable to set variables, you can edit the docker-compose.yml file and replace each occurence of ${KEYSTORE_PASSWORD} with your password (replace the entire thing).

The following environment variables are needed:

  • KEYSTORE_PASSWORD - Whatever value you want. THIS IS REQUIRED FOR THE PROJECT TO RUN
  • SMTP_PASSWORD
  • SMTP_EMAIL
  • SMTP_HOST
  • ENDPOINT_URL
  • ACCESS_KEY
  • SECRET_KEY
  • BUCKET_NAME

After this is done:

  1. Go to an empty folder where you want the project
  2. Put the docker-compose.yml file in this folder
  3. Clone the backend project into this folder: https://github.com/1Cezzo/idatt2105-project-backend
  4. Clone the frontend project as well: https://github.com/1Cezzo/idatt2105-project-frontend
  5. Run `docker compose up` (this will take several minutes the first time around)
The project should now be up and running, and can be accessed from https://localhost:5173 (note that it's https and not http). Your browser will likely alert you that the certificate is not trusted, due to the project using dev-certificates. This can be safely ignored by pressing advanced options and "continue to site", but you will have to allow insecure localhost connections as well to communicate with the backend:
  • Edge - Go to edge://flags/#allow-insecure-localhost and set the highligthed option to enabled
  • Chrome - Go to chrome://flags/#allow-insecure-localhost and set the highlighted option to enabled
  • Opera GX - From the terminal, run: "C:\path\to\opergx\launcher.exe" --allow-insecure-localhost
  • Firefox - There seems to be a lot of problems with how firefox handles self-signed certificates, so we do not recommend using firefox. Going to localhost:5173 and accepting the warning, then going to localhost:8443/# and accepting the warning, will get you to the site, but there might be problems loading images and such.

Notes

The backend is set up to fill the database with placeholder quizzes when it runs, this happens in the util/Dataloader.java class. Comment this class out if this is not desired.

To run the project you only need to set the KEYSTORE_PASSWORD environment variable, however you won't be able to upload pictures or send emails for password retrieval. To do this, you need to set the remaining environment variables. We created a simple guide on how to set this up for your own project here. The guide is simple to follow and it won't take long before you have these services set up for your own project!

Further Development

For a comprehensive understanding of the project's architecture and relationships between backend entities, we recommend reviewing the following resources:

  • Architecture Sketch - This sketch provides an overview of our project's frontend and backend architecture, including data flow and authorization processes.

  • Class Diagram - Our class diagram illustrates the structure and relationships of various classes in the backend codebase.

These resources will help you gain a deeper insight into our project's design and implementation.

API-doc:

For API documentation, run the project using the above guide, and then navigate to localhost:8443/swagger-ui/index.html in your browser. Log in with username:admin and password: password You will land on this page:

Swagger UI

Testing

The project uses JUnit tests, which can be run with Maven from the commandline with mvn clean test To see the test coverage - head to target > site > jacoco > index.html

As of version 1.2, the test coverage looks like this: The missing 15% of coverage is due to some of the built in lamba functions of the service classes in Spring Boot, which we don't use, and due to the equals, toString and hashcode methods that get automatically implemented when you use Lombok's Data annotation.

About

Backend repository for voluntary project in IDATT2105 full-stack application development

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages