olech2412 / MensaHub

MensaHub is a multi-component project that manages and provides Mensa-related data and services. It supports the dispatch of a newsletter and offers further processing of the data by means of an interface.
GNU General Public License v3.0
2 stars 0 forks source link
api java json leipzig mensahub rest-api spring-boot vaadin vaadin-flow

MensaHub ๐Ÿ

Docker Image Version (latest semver) Docker Image Version (latest semver) Docker Image Version (latest semver)

Technologies

Java Spring Apache MariaDB Docker

Description ๐Ÿ“–

What is MensaHub?

MensaHub is an application family that consists out of three parts:

What is MensaHub-Gateway?

MensaHub-Gateway is an REST-API that provides access to data of the canteens of the Studentenwerk Leipzig. It can be used to get information about the canteens and the meals.

What is MensaHub-DataDispatcher?

MensaHub-DataDispatcher is a service that is responsible for fetching data from the Studentenwerk Leipzig and storing it in a database. It is the heart of the MensaHub application family and feeds the other services with data. Th DataDispatcher is also responsible for sending an email newsletter to the users that subscribed to it.

What is MensaHub-Junction?

MensaHub-Junction is a web application that allows users to subscribe to a newsletter that is sent out by the DataDispatcher. It also allows to create an api user that can be used to send votes for meals to the Gateway.

Information for developers ๐Ÿ‘จโ€๐Ÿ’ป

How to setup the development environment?

Requirements

Setup

  1. Clone the repository '''bash git clone https://github.com/olech2412/MensaHub.git '''
  2. Setup mavens settings.xml
    1. Add the following lines to your settings.xml
      <server>
      <id>github</id>
      <username>olech2412</username>
      <password>$PACKAGE_READ_KEY</password>
      </server>
    2. To get the key please create an issue with the 'key request' label.
  3. Resolve dependencies
    1. Run the following command in the root directory of the project
      mvn clean install
  4. Setup the configuration file
    1. Create the following file: /$USER_HOME/mensaHub/mensaHub.settings
    2. Add the following content to the file: mensaHub.settings
    3. Setup the file according to your needs
  5. Setup the encryption key
    1. Because the config file contains sensitive data, the application encrypts the file and checks that on every start.
    2. To encrypt and decrypt the file you have to provide an encryption key. This is done by environment variables.
    3. Add the following environment variable to your system: encryption.key=$YOUR_ENCRYPTION_KEY
    4. You can customize your key but it hast to be 32 characters long due to AES-256
      1. Example: S5o3qev2RKxYWNjhXSpuzkmwF3ZqvM!E
    5. Add the variable to your run configuration or if you are using docker to your docker-compose file
  6. Setup the database

    1. Sign in to your MariaDB instance and create a database
      CREATE DATABASE mensaHub;
    2. Create a user and grant him access to the database
    3. Because the application creates the tables on startup, you don't have to create them manually
      1. Start one application and wait until the tables are created (the startup process may propably fail)
    4. Execute the follwoing SQL script:
      
      INSERT INTO mensaHub.cafeteria_dittrichring (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=153&date=$date&criteria=&meal_type=all','Cafeteria Dittrichring');
      INSERT INTO mensaHub.mensa_academica (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=118&date=$date&criteria=&meal_type=all','Mensa Academica');
      INSERT INTO mensaHub.mensa_am_elsterbecken (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=115&date=$date&criteria=&meal_type=all','Mensa am Elsterbecken');
      INSERT INTO mensaHub.mensa_am_medizincampus (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=162&date=$date&criteria=&meal_type=all','Mensa am Medizincampus');
      INSERT INTO mensaHub.mensa_am_park (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=106&date=$date&criteria=&meal_type=all','Mensa am Park');
      INSERT INTO mensaHub.mensa_peterssteinweg (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=111&date=$date&criteria=&meal_type=all','Mensa Peterssteinweg');
      INSERT INTO mensaHub.mensa_schoenauer_str (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=140&date=$date&criteria=&meal_type=all','Mensa Schรถnauer StraรŸe');
      INSERT INTO mensaHub.mensa_tierklinik (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=170&date=$date&criteria=&meal_type=all','Mensa Tierklinik');
      INSERT INTO mensaHub.menseria_am_botanischen_garten (id,api_url,name) VALUES (1,'https://www.studentenwerk-leipzig.de/mensen-cafeterien/speiseplan?location=127&date=$date&criteria=&meal_type=all','Menseria am Botanischen Garten');

    This is the api user with the password: test123!

    INSERT INTO mensaHub.api_user (api_user_id,username,blocking_reason,creation_date,description,email,enabled_by_admin,last_login,password,role,verified_email,activation_code_id,deactivation_code_id) VALUES (1,'test123',NULL,'2024-01-12','Nur fรผr Test','test@test.de',1,'2024-01-12 09:22:38.215295','$2a$10$16jWSSzjRzEw2jvuQYxXX.VlqN1sejlEuah/PNKyC41FSkSEbg06C','ROLE_DEV',1,2,2);

    This is the user to login to the Junction with the password: password

    INSERT INTO mensaHub.users (user_id,enabled,password,role,username) VALUES (1,1,'$2a$12$tow0YBAKqgG1.4CA9L9QGuuVpKMfdGgyl6azBc1e.3g1empQJmML.','ROLE_ADMIN','user');

MensaHub-Models ๐Ÿ“ฆ

The MensaHub-Models module contains all models that are used in the MensaHub application family. It is used as a dependency in all other modules.

Deployment ๐Ÿš€

Deployment of the jar is done for the Gateway and the DataDispatcher with:

mvn clean package

Deployment of the Junction is done with:

mvn clean package -Pproduction

Docker ๐Ÿณ

All services can be deployed with docker-compose. The docker-compose file is located in the root directory of the project for all services including mariadb. If you want to deploy only one service, you can find the docker-compose file in the corresponding module.

Docker Hub ๐Ÿ’ก

Contribution ๐Ÿค

If you want to contribute to the project you are welcome to do so. Please create an issue with the 'key request' label to get the key for the maven settings.xml file. And lets get started! ๐Ÿš€