Skip to content

Commit

Permalink
Merge branch 'master' into Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287747 authored Apr 7, 2024
2 parents 753099b + e95e440 commit 9b0c1d8
Show file tree
Hide file tree
Showing 138 changed files with 71,449 additions and 18,782 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix question_generator ci
- run: npm --prefix questionservice ci
- run: npm --prefix gameservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix question_generator test
- run: npm --prefix questionservice test -- --coverage
- run: npm --prefix gameservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
Expand Down
66 changes: 63 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix question_generator ci
- run: npm --prefix questionservice ci
- run: npm --prefix gameservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix question_generator test
- run: npm --prefix questionservice test -- --coverage
- run: npm --prefix gameservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
Expand All @@ -35,6 +41,9 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix question_generator install
- run: npm --prefix questionservice install
- run: npm --prefix gameservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
Expand Down Expand Up @@ -93,6 +102,57 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice
docker-push-questiongenerationservice:
name: Push question generation service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es3b/questiongenerationservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: question_generator
docker-push-questionservice:
name: Push question service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es3b/questionservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questionservice
docker-push-gameservice:
name: Push game service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es3b/gameservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: gameservice
docker-push-gatewayservice:
name: Push gateway service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -113,7 +173,7 @@ jobs:
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp]
needs: [docker-push-userservice,docker-push-authservice,docker-push-questiongenerationservice,docker-push-questionservice,docker-push-gameservice,docker-push-gatewayservice,docker-push-webapp]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand All @@ -124,5 +184,5 @@ jobs:
command: |
wget https://raw.githubusercontent.com/arquisoft/wiq_es3b/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es3b/master/.env -O .env
docker compose down
docker compose --profile prod up -d
docker compose --profile prod down
docker-compose --profile prod up -d --pull always
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ This repo is a basic application composed of several components.

Both the user and auth service share a Mongo database that is accessed with mongoose.

App Link: http://172.187.201.54:3000/

## Quick start guide

### Using docker
Expand Down Expand Up @@ -91,7 +93,7 @@ The deploy action is the following:
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp]
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp,docker-push-questiongenerationservice, docker-push-questionservice]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand Down
63 changes: 62 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- "27017:27017"
networks:
- mynetwork
restart: always

authservice:
container_name: authservice-${teamname:-defaultASW}
Expand All @@ -24,6 +25,7 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
restart: always

userservice:
container_name: userservice-${teamname:-defaultASW}
Expand All @@ -38,6 +40,52 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
restart: always

questiongenerationservice:
container_name: questiongenerationservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es3b/questiongenerationservice:latest
profiles: ["dev", "prod"]
build: ./question_generator
ports:
- "8003:8003"
networks:
- mynetwork
environment:
QUESTIONS_SERVICE_URL: http://questionservice:8004
AUTH_SERVICE_URL: http://authservice:8002
restart: always

questionservice:
container_name: questionservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es3b/questionservice:latest
profiles: ["dev", "prod"]
build: ./questionservice
depends_on:
- mongodb
ports:
- "8004:8004"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/questionsdb
restart: always

gameservice:
container_name: gameservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es3b/gameservice:latest
profiles: ["dev", "prod"]
build: ./gameservice
depends_on:
- mongodb
ports:
- "8005:8005"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/gamesdb
USER_SERVICE_URL: http://userservice:8001
restart: always

gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
Expand All @@ -48,13 +96,20 @@ services:
- mongodb
- userservice
- authservice
- questiongenerationservice
- questionservice
- gameservice
ports:
- "8000:8000"
networks:
- mynetwork
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QUESTION_GENERATION_SERVICE_URL: http://questiongenerationservice:8003
QUESTIONS_SERVICE_URL: http://questionservice:8004
GAME_SERVICE_URL: http://gameservice:8005
restart: always

webapp:
container_name: webapp-${teamname:-defaultASW}
Expand All @@ -64,7 +119,13 @@ services:
depends_on:
- gatewayservice
ports:
- "3000:3000"
- "3000:3000"
environment:
GATEWAY_SERVICE_URL: http://gatewayservice:8000
restart: always
#volumes:
#- ./webapp:/app


prometheus:
image: prom/prometheus
Expand Down
Binary file added docs/images/06_game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/images/deployment_diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/level3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/src/03_system_scope_and_context.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ image::context.png["Context"]
==== Deployment diagram

image::deployment.png["Deployment"]

2 changes: 1 addition & 1 deletion docs/src/04_solution_strategy.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ This section addresses the fundamental decisions for the project's architecture.
| *Security* | User access control
| *Monitoring* | Prometheus and Grafana for monitoring

|===
|===
12 changes: 4 additions & 8 deletions docs/src/05_building_block_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,16 @@ Detailed structure of the system. Focused on the components of the _User Interfa
| *_Game_*
| Game screen where the user can play the game.

| *_Ranking_*
| It contains the best scores recorded in the game, including the user's highest score and the scores of other users belonging to their group.

| *_History_*
| *_Game Service_*
| Contains all user participations with the number of games played, correct/incorrect answers, and times.

| *_About_*
| Contains important information about the project, like the development method, the developers and how to contact them.

| *_Users Service_*
| Allows the client to create a new account for the application, log in and log out.

| *_Question service_*
| *_Question Generator Service_*
| Allows to ask him questions and receive the answers of them.

| *_Question Service_*
| Saves the questions.

|===
51 changes: 1 addition & 50 deletions docs/src/06_runtime_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,57 +40,8 @@ deactivate um

When the user starts a game, the app generates a question and request the correct answer to the WikiData API. When the user choose a posible answer, the app checks if it is the correct answer. Then, this process is repeated until the end of the game.

[plantuml,"sequencediagram-game",png]
----
actor User as user
participant WebApp as app
participant GameMS as gameMS
participant WikiDataAPI as api
activate app
user -> app: Start game
app -> gameMS: Generate question
gameMS -> api: Request correct answer\nfor the generated question
api --> gameMS: Correct answer
gameMS -> app:
app -> user: Show question and options
loop Until end of the game
user -> app: Choose possible answer
app -> gameMS: Verify answer\nselected by the user
gameMS --> app: Correct or incorrect answer
app -> user: Show result\nand current score
end
image::06_game.png["Game"]

user -> app: Finish game
app --> user: Show final score
deactivate app
----
=== Ranking
In this view, the user can watch different rankings:

- Ordered by accuracy percentage
- Ordered by number of questions answered correctly
- Ordered by quantity of game rounds

[plantuml,"sequencediagram-ranking",png]
----
actor User as user
participant RankingMS as MS
participant MongoDB as db
activate MS
user -> MS: Request ranking
MS -> db: Asks for the ranking
db -> MS: Gives the ranking with the best
MS -> user: Shows the ranking
deactivate MS
----
=== History
In this view, the user can watch this options about his past games:

Expand Down
23 changes: 11 additions & 12 deletions docs/src/07_deployment_view.adoc
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
ifndef::imagesdir[:imagesdir: ../images]

[[section-deployment-view]]


== Deployment View

=== Infrastructure Level 1
image::Diag_Comp.jpg[align="center",title="Deployment Diagram",link="Diag_Comp.jpg]
image::deployment_diagram.svg[align="center",title="Deployment Diagram"]

=== Motivation:

The system is based in microservices architecture with three independent services, each responsible for a specific aspect of the functionality. One service is the Graphic interface, this service handles the presentation layer of a web application. Another service is tasked with managing user-related functionalities. MongoDB, a NoSQL database, is used to store and manage user data efficiently. The third service utilizes Wikidata, a free open base, to automatically generate questions.
The system is based on a microservices architecture with six independent services, each responsible for a specific aspect of functionality. One service is the graphical interface (WebApp), which is responsible for the presentation layer of a web application. The user service is responsible for managing user-related functionalities, while the auth service is responsible for authenticating users. The question generation service uses Wikidata, a free and open database, to generate questions automatically. Finally, the question service allows to save and retrieve information from the generated questions and the game service does the same for game-related data and statistics. MongoDB, a NoSQL database, is used to store the information.

=== Quality and/or Performance Features::

The main reason we have chosen a microservices architecture is to achieve a fast and efficient application.. The availability and efficiency of the application will be affected by Wikidata's availability, but just in the question generation moment.
The main reason we have chosen a microservices architecture is to achieve a fast and efficient application, while allowing changes to be made to certain parts of the application without the need to bring it to a complete halt. The application is deployed in an Azure virtual machine and each of the application components is in a separate container thanks to the use of Docker.
The availability and efficiency of the application will be affected by the availability of Wikidata, but only at the time of question generation.

=== Mapping of Building Blocks to Infrastructure::
[cols="1,2" options="header"]
Expand All @@ -22,11 +21,11 @@ The main reason we have chosen a microservices architecture is to achieve a fast
| _Browser_ | _The browser on the user's device where they can access to the application._
| _WebApp_ | _The graphical interface through which users can interact._
| _API Gateway_ | _The API that comunicates the rest of the microservices with the graphical interface._
| _Question_Generator_ | _The microservice responsible for generating questions through Wikidata._
| _Question generation service_ | _The microservice responsible for generating questions through Wikidata._
| _Wikidata_ | _The Wikidata API that allows us to access its information._
| _Users_ | _The microservice responsible for managing users._
| _Question service_ | _The microservice responsible for saving and getting information about the questions._
| _Game service_ | _The microservice responsible for saving and getting information about the games._
| _User service_ | _The microservice responsible for managing users._
| _Auth service_ | _The microservice responsible for managing the authentication of the users._
| _MongoDB_ | _A NoSQL based database where we can save the user's data._
|===



|===
1 change: 1 addition & 0 deletions docs/src/08_concepts.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ifndef::imagesdir[:imagesdir: ../images]

[[section-concepts]]

## 1.0 Designs

### User Page
Expand Down
2 changes: 2 additions & 0 deletions gameservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
Loading

0 comments on commit 9b0c1d8

Please sign in to comment.