Skip to content

Commit

Permalink
Merge pull request #229 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Entregable 4
  • Loading branch information
Pelayori authored Apr 28, 2024
2 parents 602600d + e382d8a commit f9701b0
Show file tree
Hide file tree
Showing 183 changed files with 3,828 additions and 976 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MYSQL_HOST=db
KEYSTORE_PATH=./testCert.p12
KEYSTORE_PASSWORD=123456
WIQ_IMAGE=pelayori/wiq_es04b
69 changes: 68 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,74 @@ on:
types: [published]

jobs:
app-tests-analyze:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:latest
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test_database
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v2

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: |
~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: '17'

- name: Add exec permission to mvnw
run: chmod +x mvnw

- name: Compile the application
run: ./mvnw -B clean install -DskipTests=true

- name: Start the application
run: |
./mvnw spring-boot:run > logs.txt 2>&1 &
echo $! > spring-boot-app.pid
sleep 5
env:
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/test_database
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.cj.jdbc.Driver
SPRING_PROFILES_ACTIVE: test
- name: Check listening ports
run: ss -tuln
- name: Run tests
run: |
./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent verify -Dspring.datasource.url=jdbc:mysql://localhost:3306/test_database -Dspring.datasource.username=root -Dspring.datasource.password=root -Dspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
env:
SPRING_PROFILES_ACTIVE: test
headless: true
EXCLUDE_JUNIT: true
- name: Show app logs
if: always()
run: |
cat logs.txt
- name: Shut down the application
run: |
kill $(cat spring-boot-app.pid)
- name: Collect Jacoco report and send to Sonar
run: |
./mvnw org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.projectKey=Arquisoft_wiq_es04b -Dsonar.organization=arquisoft -Dsonar.branch.name=${{ github.head_ref || github.ref_name }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dspring.profiles.active=test
build-and-push:
runs-on: ubuntu-latest
needs: app-tests-analyze
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -43,7 +109,8 @@ jobs:
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
script: |
wget https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/docker-compose.yml -O docker-compose.yml
docker-compose down
wget https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/prometheus.yml -O prometheus.yml
docker compose pull
docker-compose up -d
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ jobs:
kill $(cat spring-boot-app.pid)
- name: Collect Jacoco report and send to Sonar
run: |
./mvnw org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.projectKey=Arquisoft_wiq_es04b -Dsonar.organization=arquisoft -Dsonar.branch.name=${{ github.head_ref || github.ref_name }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dspring.profiles.active=test
./mvnw org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.projectKey=Arquisoft_wiq_es04b -Dsonar.organization=arquisoft -Dsonar.branch.name=${{ github.head_ref || github.ref_name }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dspring.profiles.active=test
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Build stage with Maven and JDK 17
FROM maven:3.8.4-openjdk-17-slim as build
WORKDIR /app
WORKDIR ./app
COPY pom.xml .
COPY src src/
# Use Maven directly instead of the Maven Wrapper
RUN mvn clean package -DskipTests

# Run stage with JDK 17
FROM openjdk:17-slim
COPY --from=build /app/target/*.jar app.jar
COPY --from=build ./app/target/*.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=prod","-jar","/app.jar"]
EXPOSE 443
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,34 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es04b&metric=alert_status)](https://sonarcloud.io/summary/overall?id=Arquisoft_wiq_es04b)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es04b&metric=coverage)](https://sonarcloud.io/summary/overall?id=Arquisoft_wiq_es04b)

### 🚀 TEAM
### 🚀 TEAM:

- **Pelayo Rojas Iñigo**
- **Álvaro Arias Martínez De Vega**
- **Ricardo Díaz Núñez**
- **Roberto Peña Goy**
- **Iker Álvarez Fernández**

### Local deployment instructions:

#### Without docker (slower):

1. Fist you have to clone the repository using a CMD and the following command: `git clone https://github.com/Arquisoft/wiq_es04b.git` or using an IDE with Git integration or any other app of your preference.

2. Then you have to execute the [runServer.bat](https://github.com/Arquisoft/wiq_es04b/blob/master/database/hsqldb/bin/runServer.bat) to start the local database.

3. With the database initialized you have to open a CMD in the project root directory and execute the following command `mvnw spring-boot:run`, to start the application.

4. When the application is started the web app uses the port 3000. You can access the app through any web client using the following URL: http://localhost:3000/.

5. If you wish to execute the tests you have to open a CMD in the project root directory (you could use the same you used before), you have to execute `set EXCLUDE_JUNIT=true` if you also want to execute the E2E tests. Then to execute the tests you have to use the following command: `mvnw org.jacoco:jacoco-maven-plugin:prepare-agent verify`.

6. If you want to obtain the report you have to torn off the app and in the same CMD as before execute the following command: `mvnw org.jacoco:jacoco-maven-plugin:report`.

#### With docker (faster):

> #### *Disclaimer: This method is faster but it is not recommended for development because it is harder to debug and to see the logs and it is harder to execute the tests.*
1. First you need to have installed [docker](https://www.docker.com/#build) and docker [compose](https://docs.docker.com/compose/install/).
2. Then you have to clone the repository using a CMD and the following command: `git clone https://github.com/Arquisoft/wiq_es04b.git` or using an IDE with Git integration or any other app of your preference.
3. Then you have to open a CMD in the project root directory and execute the following command: `docker-compose up`. This is going to deploy the docker image that is in our repository. This docker will contain the app, a MySql database, Graphana and Prometheus. The app will be available in the port 443 https.
43 changes: 37 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ services:
restart: always

wiq_es04b:
image: ghcr.io/arquisoft/wiq_es04b:latest
image: ${WIQ_IMAGE:-ghcr.io/arquisoft/wiq_es04b:latest}
environment:
MYSQL_HOST: ${MYSQL_HOST}
MYSQL_PORT: ${MYSQL_PORT}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE:-wiq_es04b}
MYSQL_USER: ${MYSQL_USER:-wiq_es04b}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-wiq_es04b}
MYSQL_PORT: ${MYSQL_PORT:-3306}
KEYSTORE_PATH: ${KEYSTORE_PATH}
KEYSTORE_PASSWORD: ${KEYSTORE_PASSWORD}
ports:
Expand All @@ -38,9 +38,40 @@ services:
volumes:
- ${KEYSTORE_PATH}:/certs/keystore.p12

prometheus:
image: prom/prometheus:latest
volumes:
- prometheus_data:/prometheus
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
networks:
- mynetwork
depends_on:
- wiq_es04b
restart: always

grafana:
image: grafana/grafana:latest
volumes:
- grafana_data:/var/lib/grafana
environment:
GF_AUTH_DISABLE_LOGIN_FORM: 1
GF_AUTH_ANONYMOUS_ENABLED: true
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
ports:
- "3000:3000"
networks:
- mynetwork
depends_on:
- prometheus
restart: always

volumes:
db_data:
prometheus_data:
grafana_data:

networks:
mynetwork:
driver: bridge
driver: bridge
Binary file added docs/images/ChangeLanguage/1000UsersLanguage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ChangeLanguage/1UserLanguage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ChangeLanguage/2000UsersLanguage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ChangeLanguage/250UsersLanguage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ChangeLanguage/5000UsersLanguage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ChangeLanguage/GeneralLanguage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ChangeLanguage/GraphicLanguage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/GlobalRanking/1000UsersGR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/GlobalRanking/1UserGR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/GlobalRanking/2000UsersGR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/GlobalRanking/250UsersGR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/GlobalRanking/5000UsersGR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/GlobalRanking/GeneralGR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/GlobalRanking/GraphicGR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Index/1000UsersIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Index/1UserIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Index/2000UsersIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Index/250UsersIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Index/5000UsersIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Index/GeneralIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Index/GraphicIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/LogOut/1000UsersLogout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/LogOut/1UserLogout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/LogOut/2000UsersLogout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/LogOut/250UsersLogout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/LogOut/5000UsersLogout.png
Binary file added docs/images/LogOut/GeneralLogout.png
Binary file added docs/images/LogOut/GraphicLogout.png
Binary file added docs/images/Login/1000UsersLogin.png
Binary file added docs/images/Login/1UserLogin.png
Binary file added docs/images/Login/2000UsersLogin.png
Binary file added docs/images/Login/250UsersLogin.png
Binary file added docs/images/Login/5000UsersLogin.png
Binary file added docs/images/Login/GeneralLogin.png
Binary file added docs/images/Login/GraphicLogin.png
Binary file added docs/images/PersonalRanking/1000UsersPR.png
Binary file added docs/images/PersonalRanking/1UserPR.png
Binary file added docs/images/PersonalRanking/2000UsersPR.png
Binary file added docs/images/PersonalRanking/250UsersPR.png
Binary file added docs/images/PersonalRanking/5000UsersPR.png
Binary file added docs/images/PersonalRanking/GeneralPR.png
Binary file added docs/images/PersonalRanking/GraphicPR.png
Binary file added docs/images/PlayGame/1000UsersGame.png
Binary file added docs/images/PlayGame/1UserGame.png
Binary file added docs/images/PlayGame/2000UsersGame.png
Binary file added docs/images/PlayGame/250UsersGame.png
Binary file added docs/images/PlayGame/5000UsersGame.png
Binary file added docs/images/PlayGame/GeneralGame.png
Binary file added docs/images/PlayGame/GraphicGame.png
Binary file added docs/images/ShowApiKey/1000UsersApiKey.png
Binary file added docs/images/ShowApiKey/1UserApiKey.png
Binary file added docs/images/ShowApiKey/2000UsersApiKey.png
Binary file added docs/images/ShowApiKey/250UsersApiKey.png
Binary file added docs/images/ShowApiKey/5000UsersApiKey.png
Binary file added docs/images/ShowApiKey/GeneralApiKey.png
Binary file added docs/images/ShowApiKey/GraphicApiKey.png
Binary file added docs/images/ShowProfile/1000UsersProfile.png
Binary file added docs/images/ShowProfile/1UserProfile.png
Binary file added docs/images/ShowProfile/2000UsersProfile.png
Binary file added docs/images/ShowProfile/250UsersProfile.png
Binary file added docs/images/ShowProfile/5000UsersProfile.png
Binary file added docs/images/ShowProfile/GeneralProfile.png
Binary file added docs/images/ShowProfile/GraphicProfile.png
12 changes: 10 additions & 2 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
include::src/config.adoc[]

= image:wiq-logo.png[wiq-image] WIQ es04b
:revnumber: 2
:revdate: March 2024
:revnumber: 3
:revdate: April 2024
:revremark: ASW - wiq_es04b
// toc-title definition MUST follow document title without blank line!
:toc-title: Table of Contents
Expand Down Expand Up @@ -101,4 +101,12 @@ include::src/11_technical_risks.adoc[]
// 12. Glossary
include::src/12_glossary.adoc[]

<<<<
// 13. Question Generation Strategy
include::src/13_question_generation_strategy.adoc[]

<<<<
// 14. Testing
include::src/14_testing.adoc[]


2 changes: 1 addition & 1 deletion docs/src/01_introduction_and_goals.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The overall goal of the application is to provide a fun and challenging experien
=== Quality Goals
[options="header",cols="1,2,2"]
|===
|Nº|Atributo|Motivacion
|Nº|Quality Goal|Motivation
| 1 | Efficiency | Access, creation of questions, and navigation between them should be fast to ensure user satisfaction.
| 2 | Usability | The application should be appealing to all fans of the original program while also offering a wide variety of questions.
| 3 | Manteinance | The application should ensure easy expansion and modification to provide users with new features.
Expand Down
122 changes: 88 additions & 34 deletions docs/src/03_system_scope_and_context.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,62 +9,116 @@ ifndef::imagesdir[:imagesdir: ../images]
@startuml
actor Player as user
actor "External Developers" as developers
component System [
component WebApp [
<<System>>
QuestionGame
Web game
]
component WikiData as wikidata
user -down-> System : Uses
System -left-> wikidata : Retrieves\nInformation to\nform questions\nand answers
developers -down-> System : Asks for Player\n& Question Data
System -----> developers : Provides\nPlayer &\n Question Data
component PlayerService [
<<System>>
Player Management
]
component QuestionService [
<<System>>
Question Management
]
component WikiData [
<<extern>>
Wikidata
]
user ...> WebApp: Plays
WebApp ---> PlayerService : Handles\nlogin and signup
WebApp -left-> QuestionService : Retrieves generated\nquestions for game
WebApp <-- WikiData : Retrieves\nInformation to\nform questions\nand answers
developers .right.> PlayerService : Modify\nplayer data
developers <.right. PlayerService : Retrieve\nplayer data
developers .right.> QuestionService : Modify questions
developers <.right. QuestionService : Retrieve question list
@enduml
----
* **Player:** Represents users who interact with the application to play games or view their history.
* **System (QuestionGame):** The main system that hosts the game logic and manages user interactions.
* **Question management:** The sytem that retrieves the questions generated from Wikidata.
* **Player management:** The system that manages player data, such as registration, login, and game history.
* **WikiData:** Component used to retrieve data from Wikidata and automatically generate questions.
* **Database:** Stores system information, such as user data, generated questions, game history, etc.
* **External Developers:** Represents developers who access the system's REST API to retrieve player and question data.
* **External Developers:** Represents developers who access the system to retrieve player and question data.

=== Technical Context

[plantuml,"Technical Context Diagram",png]
----
actor user
person developer
database Database
cloud WikiData
node "User Agent"
node "QuestionGame server"
user --> [User Agent]
[User Agent] --> [QuestionGame server]: HTTPS
[QuestionGame server] --> Database: Specific driver
[QuestionGame server] --> WikiData: HTTP
developer --> [QuestionGame server] : HTTPS
actor Player as user
actor "External Developers" as developers
component WebApp [
<<System>>
Web game
]
component PlayerService [
<<System>>
PlayerService
]
component QuestionService [
<<System>>
QuestionService
]
component WikiData [
<<extern>>
Wikidata
]
component QuestionGenerator [
<<system>>
QuestionGenerator
]
component RestApiService [
<<system>>
RestApiService
]
database Database [
Database
]
user .left.> WebApp: HTTPS
WebApp ---> PlayerService : Handles\nlogin, signup\nand game history
WebApp -left-> QuestionService : Retrieves generated\nquestions for game
QuestionGenerator <-up- WikiData : Get entity info\nfrom SPARQL HTTP
QuestionGenerator --> QuestionService : Generate questions\nwith entity data
QuestionService --> Database: Save\nquestion\nentities
QuestionService <-- Database: Retrieve\nsaved\nquestions
developers .up---.> RestApiService : HTTP\nPOST\nPUT\nDELETE
developers <.up. RestApiService : HTTP GET
RestApiService -up-> QuestionService: Retrieve/Modify questions
RestApiService ---> PlayerService: Retrieve/Modify player data
----

* **User Agent:** Represents the web or mobile interface used by users.
* **QuestionGame server:** The server-side components, including the Frontend, QuestionGame logic, User's API, and Question's API.
* **HTTPS:** Represents the communication channels, with HTTPS being the protocol used for secure communication.
* **Question Generation:** Represents the means used for question and answers generation.
* **Database:** Represents whichever system used for data persistence.
* **To be decided:** Indicates that specific details about the channels and protocols are yet to be determined.
* **Player:** Represents users who interact with the application to play games or view their history.
* **Question service:** The system that retrieves the questions generated from Wikidata.
* **Player service:** The system that manages player data, such as registration, login, and game history.
* **WikiData:** Component used to retrieve data from Wikidata
* **Question generator:** The system that generates questions based on the data retrieved from Wikidata.
* **External Developers:** Represents developers who access the system to retrieve player and question data.
* **Database:** The database that stores player data, game history, and questions.
* **Rest API Service:** The service that provides an API for external developers to access player and question data.

==== Input/Output Mapping Table

[options="header",cols="1,2,2"]
|===
|Component|Input/Output|Channel/Protocol
| User's API| User registration, game history| HTTPS
| Question's API| Question data retrieval| HTTPS
| RestApiService| External developer interactions| HTTPS
| Frontend| User interactions, game display| HTTPS
| Database| User data, game history, questions| Specific database driver
| WikiData| Data for question generation| HTTP
| Question Generator| Generated questions| In-memory
| Question Service| Questions for game| In-memory
| Player Service| Player data| In-memory
|===
Loading

0 comments on commit f9701b0

Please sign in to comment.