diff --git a/README.md b/README.md index 2cb3d0e..c3e4ddf 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ It uses **Spring Boot** for the backend, **Vaadin** for the frontend, and **Mari ## Requirements -- **Java 23** or later -- **Maven** (if not integrated) +- **Java 21** or later +- **Maven** - **MariaDB** (for production use) ## Installation @@ -22,50 +22,58 @@ If you want to run the application in production mode, you can skip to [Producti ### Testing -To run the application in a test environment, you can use an embedded H2 database. This is useful for development and testing purposes. +You can run the application in test mode without setting up a database or authentication. In this mode, any page of +the app is available to any user without a login. -To build the project and run the application with the embedded H2 database, use the following commands: +The result data will be stored in an in-memory H2 database. You can change the test data by modifying the `data.sql` file +or just delete it for a clean slate. + +To start the application in test mode, run: ```sh -mvn clean package mvn spring-boot:run -Ptest ``` +The app can then be accessed at `http://localhost:8080`. + ### Production -The application requires a database to store the data. If MariaDB is already installed, make sure the database and -credentials are correctly configured in `application-prod.properties` and skip to step [Build the project](#build-the-project). +In production mode, the application requires an external database to store the data. If MariaDB is already installed, make sure the +credentials are correctly configured in `application-prod.properties` and the database conforms to the schema given in `schema.sql`. -#### Set up database +#### Set up the database -You can quickly start a database using Docker and update its schema using the provided `update-schema.sql` file. +If you don't have a database, you can quickly start one using Docker and update its schema using the provided `schema.sql` file: ```sh docker run --name kickerelo-db -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=kickerelo -p 3306:3306 -d mariadb:latest -docker exec -i kickerelo-db mysql -u root -p kickerelo < update-schema.sql +docker exec -i kickerelo-db mysql -u root -p kickerelo < schema.sql ``` +#### Set up authentication +In order for the application to start up in production mode, an OIDC provider must be configured in `application-prod.properties`. +Some pages of the app are inaccessible without a login. #### Build the project -To generate the file `target/kickerelo.jar`: +To generate the file `kickerelo.jar` target, run: ```sh -mvn clean package -Pproduction +mvn package -Pproduction ``` -### Run the application +#### Run the application You can run the application in two ways: -1. Using Maven: +1. Directly using Maven: ```sh mvn spring-boot:run -Dspring-boot.run.profiles=prod ``` -2. Using the built .jar file: +2. Using the .jar file: ```sh java -jar target/kickerelo.jar --spring.profiles.active=prod diff --git a/src/main/java/org/kickerelo/kickerelo/data/update-schema.sql b/src/main/java/org/kickerelo/kickerelo/data/update-schema.sql deleted file mode 100644 index c056b5d..0000000 --- a/src/main/java/org/kickerelo/kickerelo/data/update-schema.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE SEQUENCE ergebnis1vs1_seq INCREMENT BY 50 START WITH 1; - -CREATE SEQUENCE ergebnis2vs2_seq INCREMENT BY 50 START WITH 1; - -CREATE SEQUENCE spieler_seq INCREMENT BY 50 START WITH 1; - -CREATE TABLE ergebnis1vs1 -( - id BIGINT NOT NULL, - gewinner INT NOT NULL, - verlierer INT NOT NULL, - tore_verlierer SMALLINT NOT NULL, - zeitpunkt datetime NULL, - CONSTRAINT pk_ergebnis1vs1 PRIMARY KEY (id) -); - -CREATE TABLE ergebnis2vs2 -( - id BIGINT NOT NULL, - gewinner_vorn INT NOT NULL, - gewinner_hinten INT NOT NULL, - verlierer_vorn INT NOT NULL, - verlierer_hinten INT NOT NULL, - tore_verlierer SMALLINT NOT NULL, - zeitpunkt datetime NOT NULL, - CONSTRAINT pk_ergebnis2vs2 PRIMARY KEY (id) -); - -CREATE TABLE spieler -( - id INT NOT NULL, - name VARCHAR(255) NOT NULL, - elo1vs1 FLOAT NOT NULL, - elo2vs2 FLOAT NOT NULL, - elo_alt FLOAT NULL, - CONSTRAINT pk_spieler PRIMARY KEY (id) -); - -ALTER TABLE spieler - ADD CONSTRAINT uc_spieler_name UNIQUE (name); - -ALTER TABLE ergebnis1vs1 - ADD CONSTRAINT FK_ERGEBNIS1VS1_ON_GEWINNER FOREIGN KEY (gewinner) REFERENCES spieler (id); - -ALTER TABLE ergebnis1vs1 - ADD CONSTRAINT FK_ERGEBNIS1VS1_ON_VERLIERER FOREIGN KEY (verlierer) REFERENCES spieler (id); - -ALTER TABLE ergebnis2vs2 - ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_GEWINNER_HINTEN FOREIGN KEY (gewinner_hinten) REFERENCES spieler (id); - -ALTER TABLE ergebnis2vs2 - ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_GEWINNER_VORN FOREIGN KEY (gewinner_vorn) REFERENCES spieler (id); - -ALTER TABLE ergebnis2vs2 - ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_VERLIERER_HINTEN FOREIGN KEY (verlierer_hinten) REFERENCES spieler (id); - -ALTER TABLE ergebnis2vs2 - ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_VERLIERER_VORN FOREIGN KEY (verlierer_vorn) REFERENCES spieler (id); \ No newline at end of file