Skip to content

Commit

Permalink
Finished points 5 and 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Mario committed Mar 26, 2024
1 parent 2a920c9 commit e2e658e
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 149 deletions.
28 changes: 15 additions & 13 deletions docs/src/05_building_block_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,28 @@ In this level of descomposition we separate the main services of our system show


Contained Building Blocks::
* *_WIQ_ HOME* : Service which will collect the user interaction and redirect it to the corresponding service.
* *_WIQ_ USER MANAGEMENT* : Service that will manage the user information, login, authentication, etc.
* *_WIQ_ QUESTION GAME* Service that will generate and show the different questions for our game.
* *_Webapp_* : The web part of our application that will use the wiq services to let the user play.
* *Gateway service* : Service that will redirect every call to our endpoints to the specific one.
* *_WIQ Services_* : Our collection of endpoints that will attend any need of our Webapp as well as giving support to external calls.

=== Level 2

image::5-Level2.svg["Level 2"]

Motivation::

In this level of descomposition of the system we start to identify the different microservices of the system.
In this level of descomposition of the system we identify the different views of the webapp and microservices of the WIQ services.


Contained Building Blocks::
* *_HOME_ WELCOME PAGE* : Microservice that will welcome the user giving a small explanation about the game and facilate the registration/login process.
* *_USER MANAGEMENT_ USERSERVICE* : Microservice that will allow the user create an account for the user and let him access the game.
* *_USER MANAGEMENT_ AUTHSERVICE* : Microservice that will login the user in the system and let him access the game.
* *_HOME_ GAMEMODE PAGE* : Microservice that will let the user start a game.
* *_QUESTION GAME_ GAME CONFIGURATION* Microservice that will let the user customize some game parameters (amount of questions, time to respond a question, etc).
* *_QUESTION GAME_ QUESTION RESTAPI* Microservice that will work as our open API allowing other systems to retrieve information like:
** Random questions and corresponding answers.
* *_QUESTION GAME_ QUESTION GENERATOR* Microservice that will generate the different questions for our game communicating with wikidata.
* *_QUESTION GAME_ GAME* Microservice that will show the different questions for our game and manage the user answers in order to give a final score.
* *_Webapp_ Home* : First view of the webapp.
* *_Webapp_ Log in and Register* : Views of the webapp that allow the user to get into the application.
* *_Webapp_ Game menu* : Intermediate view between the records and the actual game.
* *_Webapp_ User's games records* : View where the user will be able to see different statistics of the games played (Correct answers, points, total games).
* *_Webapp_ Question Game* : Game view where the user will be able answer the random question by choosing 1 of 4 posibilities.

* *_WIQ Services_ Authentication service* : Microservice that will let the user log in a created account.
* *_WIQ Services_ User service* : Microservice that will let the user create an account.
* *_WIQ Services_ Record service* : Microservice that will manage the records of all users and will let anyone get the records of an user.
* *_WIQ Services_ Question service* Microservice that will get some random questions for an user game. It will also let anyone get random questions outside our system.
* *_WIQ Services_ Question generator* Microservice that will generate the random questions accesing wikidate and load them into the system.
279 changes: 143 additions & 136 deletions docs/src/06_runtime_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,142 +36,149 @@ There are many notations for describing scenarios, e.g.
See https://docs.arc42.org/section-6/[Runtime View] in the arc42 documentation.
****

=== Runtime Scenario: Retrieval of questions

[plantuml,"Retrieval of questions",png]
----
actor User
entity Frontend as "Webapp Frontend"
entity Backend as "Webapp Backend"
database Wikidata
User -> Frontend: next question
Frontend -> Backend: get question
Backend -> Wikidata: request data\n(1s timeout)
Wikidata -> Backend: receive data
Backend -> Backend: generate question
Backend -> Frontend: return question and answers
Frontend -> User: show question
----

=== Runtime Scenario: Answer questions

[plantuml,"Answer questions",png]
----
actor User
entity Frontend as "Webapp Frontend"
entity Backend as "Webapp Backend"
database DB
User -> Frontend: answer\n(30s timelimit)
Frontend -> Frontend: process answer
Frontend -> Backend: forward result
Backend -> DB: store result\n(1s timeout)
Backend -> Frontend: answer
Frontend -> User: show correctness
----

=== Runtime Scenario: Login successful

[plantuml,"Login successful",png]
----
actor User
entity Frontend as "Webapp Frontend"
entity Backend as "Webapp Backend"
database DB
User -> Frontend: send credentials
Frontend -> Backend: forward credentials
Backend -> DB: query for username\n(1s timeout)
DB -> Backend: retrieve user data
Backend -> Backend: validate password
Backend -> Frontend: login successful
Frontend -> User: login successful
----

=== Runtime Scenario: Login failure

[plantuml,"Login failure",png]
----
actor User
entity Frontend as "Webapp Frontend"
entity Backend as "Webapp Backend"
database DB
User -> Frontend: send credentials
Frontend -> Backend: forward credentials
Backend -> DB: query for username\n(1s timeout)
DB -> Backend: retrieve user data
Backend-> Backend: validate password
Backend -> Frontend: wrong password
Frontend -> User: ask for credentials
User -> Frontend: send credentials
Frontend -> Backend: ...
----

=== Runtime Scenario: Signup successful

[plantuml,"Signup successful",png]
----
actor User
entity Frontend as "Webapp Frontend"
entity Backend as "Webapp Backend"
database DB
User -> Frontend: send signup form
Frontend -> Backend: forward signup form
Backend -> DB: check if username exists\n(1s timeout)
DB -> Backend: answer
Backend -> DB: insert data\n(1s timeout)
Backend -> Frontend: signup successful
Frontend -> User: signup successful
----

=== Runtime Scenario: Signup failure

[plantuml,"Signup failure",png]
----
actor User
entity Frontend as "Webapp Frontend"
entity Backend as "Webapp Backend"
database DB
User -> Frontend: send signup form
Frontend -> Backend: forward signup form
Backend -> DB: check if username exists\n(1s timeout)
DB -> Backend: answer
Backend -> Frontend: error: username in use
Frontend -> User: username in use
User -> Frontend: send new username
Frontend -> Backend: forward new username
Backend -> DB: ...
----

=== Runtime Scenario: Wikidata error

[plantuml,"Wikidata error",png]
----
actor User
entity Frontend as "Webapp Frontend"
entity Backend as "Webapp Backend"
database Wikidata
User -> Frontend: next question
Frontend -> Backend: get question
Backend -> Wikidata: request data
Wikidata -> Backend: error/timeout
Backend -> Backend: error handling
Backend -> Frontend: wikidata error
Frontend -> User: show error message
----

=== Runtime Scenario: DB error

[plantuml,"DB error",png]
In this section we will focus on developing which views of the webapp uses which microservices from the WIQ Services.
Mind that some of these processes works the same way when called from outside the system (look for them at the API docs)

=== Runtime Scenario: Signup

[plantuml,"Signup",png]
----
entity Webapp as "Sign in view"
entity Gateway_service as "Gateway service"
entity Microservice as "Authentication service"
database Users_database
Webapp -> Gateway_service: Sends signup form
Gateway_service -> Microservice: Forward the petition\nto the specific microservice
Microservice -> Microservice : Checks the petition
alt data is valid
Microservice -> Users_database : Check if username or email exists
Users_database --> Microservice: Answers
alt email is not registered nor username
Microservice -> Microservice: Creates a respond with user's data
Microservice --> Gateway_service: Forwards the respond
Gateway_service --> Webapp : Responds to the petition
Webapp -> Webapp : Logs into the application
else email or username exists
Microservice --> Gateway_service: Responds with an error
Gateway_service --> Webapp : Forwards the petition
Webapp -> Webapp : Show the error
end
else data is invalid
Microservice --> Gateway_service: Responds with some error(s)
Gateway_service --> Webapp: Forwards the respond
Webapp -> Webapp: Shows the error(s)
end
----
=== Runtime Scenario: Login

[plantuml,"Login",png]
----
entity Webapp as "Log in view"
entity Gateway_service as "Gateway service"
entity Microservice as "User service"
database Users_database
Webapp -> Gateway_service: Sends log in form
Gateway_service -> Microservice: Forward the petition\nto the specific microservice
Microservice -> Microservice : Checks the petition
alt data is valid
Microservice -> Users_database : Check if username exists
Users_database --> Microservice: Answers
alt users exists
Microservice -> Microservice: Creates a respond with user's data
Microservice --> Gateway_service: Forwards the respond
Gateway_service --> Webapp : Responds to the petition
Webapp -> Webapp : Logs into the application
else users does not exist
Microservice --> Gateway_service: Responds with an error
Gateway_service --> Webapp : Forwards the petition
Webapp -> Webapp : Show the error
end
else data is invalid
Microservice --> Gateway_service: Responds with some error(s)
Gateway_service --> Webapp: Forwards the respond
Webapp -> Webapp: Shows the error(s)
end
----

=== Runtime Scenario: Generation of questions

[plantuml,"Generation of questions",png]
----
entity Microservice as "Question generator"
entity Wikidata as "Wikidata"
database Questions_database
group Repeats after some time
Microservice -> Wikidata : Asks for information\nto generate questions
alt Wikidata is working
Wikidata --> Microservice : Returns the information
Microservice -> Microservice : Generates the question,\ncorrect answer and distractors
group Transaction
Microservice -> Questions_database : Removes questions that exist
Questions_database --> Microservice : Confirms remove operation
Microservice -> Questions_database : Saves the new questions
Questions_database --> Microservice : Confirms add operation
end group
end alt
Microservice -> Microservice : Goes to sleep
end group
----

=== Runtime Scenario: Play a game

[plantuml,"Play a game",png]
----
actor User
entity Frontend as "Webapp Frontend"
entity Backend as "Webapp Backend"
database DB
User -> Frontend: request
Frontend -> Backend: request
Backend -> DB: request
DB -> Backend: error/timeout
Backend -> Backend: error handling
Backend -> Frontend: DB error
Frontend -> User: show error message
entity Webapp as "Question game"
entity Gateway_service as "Gateway service"
entity Microservice1 as "Question service"
entity Microservice2 as "Record service"
database DB as "Questions database"
database UDB as "Users database"
Webapp -> Gateway_service: Sends a petition for questions\nwith some parameters
Gateway_service -> Microservice1: Forwards the petition
Microservice1 -> DB : Select some questions\nfor those parameters
alt Database is working
DB --> Microservice1 : Retrieve some questions
Microservice1 -> Microservice1 : Formats the questions retrieved\ninto JSON format
Microservice1 --> Gateway_service: Responds with the JSON
Gateway_service --> Webapp : Forwards the respond
Webapp -> Webapp : Process the JSON and\nstarts the game
loop Till there are no more questions
alt Time has not run out
User -> Webapp : Clicks an answer
Webapp -> Webapp : Checks the answer
end alt
Webapp -> User : Show correct answer
end loop
Webapp -> User : Shows use the game statistics
Webapp -> Gateway_service : Sends the statistics of the game\nFire and forget
Gateway_service -> Microservice2 : Forwards the message
Microservice2 -> UDB : Saves the record
alt Users database is not working
Microservice2 -> Microservice2 : Saves the record\nwill try with next request\nto save both records
end alt
else Database is not working
Microservice1 --> Gateway_service : Responds with an error
Gateway_service --> Webapp : Forwards the respond
Webapp -> Webapp : Process the error
Webapp --> User : Advise in a friendly way\n(Oven cannot bake\nquestions right now)
end
----

=== Runtime Scenario: Accessing a record
[plantuml,"Accessing a record",png]
----
entity Webapp as "Record view"
entity Gateway_service as "Gateway service"
entity Microservice as "Record service"
database DB as "Users_database"
Webapp -> Gateway_service: Asks for the record\nof the logged user
Gateway_service -> Microservice: Forward the petition\nto the specific microservice
Microservice -> DB : Finds the user's record
DB --> Microservice : Returns the user's record
Microservice --> Gateway_service : Sends the respond
Gateway_service --> Webapp : Forwards the respond
Webapp -> Webapp : Parses the record\nand shows it
----

0 comments on commit e2e658e

Please sign in to comment.