Skip to content

Commit

Permalink
Merge pull request #203 from Arquisoft/develop
Browse files Browse the repository at this point in the history
actualizar master para probar despliegue
  • Loading branch information
bidof authored Apr 9, 2024
2 parents d96e1b9 + 3e0763c commit ed6ddd7
Show file tree
Hide file tree
Showing 82 changed files with 8,319 additions and 1,624 deletions.
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"github.copilot"
]
}
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Visit our app : http://20.68.253.187:3000/
[![Deploy on release](https://github.com/Arquisoft/wiq_es05c/actions/workflows/release.yml/badge.svg)](https://github.com/Arquisoft/wiq_es05c/actions/workflows/release.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es05c&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es05c)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es05c&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es05c)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es05c&metric=bugs)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es05c)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es05c&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es05c)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es05c&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es05c)
[![SQALE Rating](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es05c&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es05c)

This is a base repo for the [Software Architecture course](http://arquisoft.github.io/) in [2023/2024 edition](https://arquisoft.github.io/course2324.html).

Expand All @@ -19,15 +23,12 @@ Both the user, auth service and questions service share a Mongo database that is

## Members of the group

Sonia Moro Lauda

Lucía Villanueva Rodríguez

Pedro Castro Montes

Adrián Santamarina Romero

David González González
| Nombre | Identificador |
|-----------------------------|---------------|
| Sonia Moro Lauda | UO282189 |
| Lucía Villanueva Rodríguez | UO283535 |
| Pedro Castro Montes | UO288120 |
| David Alvarez Diaz | UO283196 |

## Quick start guide

Expand Down
Binary file removed docs/images/05-BussinesLogic-Level2.png
Binary file not shown.
Binary file removed docs/images/05-Database-Level2.png
Binary file not shown.
Binary file removed docs/images/05-Level1.png
Binary file not shown.
Binary file removed docs/images/05-ScopeAndContext.png
Binary file not shown.
Binary file removed docs/images/05-UserInterface-Level2.png
Binary file not shown.
Binary file removed docs/images/Level2Databases.png
Binary file not shown.
Binary file removed docs/images/Level2Services.png
Binary file not shown.
Binary file removed docs/images/Level2Webapp.png
Binary file not shown.
Binary file modified docs/images/level1.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/level2-History.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/level2-Question.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/level2-Users.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions docs/src/02_architecture_constraints.adoc
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
[[section-architecture-constraints]]
== Architecture Constraints

Each of the following constraints plays a crucial role in the formation of the software architecture and in determining the best practices
for the development team. Next, we will explain the ones that the team must comply with.

1.Technical Constraints
[options = "header", cols = "1,2"]
|===
| Constraint | Description
| Wikidata | Wikidata is a knowledge base that provides data sources, used to obtain information for the game. In this case, it is mandatory.
| Docker | Software that allows automating the deployment of applications. The application will be running on a Docker host.
| GitHub | Platform that allows us to have a repository where to develop the project and perform different actions such as creating issues or tasks.
| GitHub | A cloud storage service for collaborative application development, which facilitates effective communication,
manages the tracking of different project versions, and distributes responsibilities equitably among team members.
|===

2.Organizational Constraints
[options = "header", cols = "1,2"]
|===
| Constraint | Description
| Team | A team formed by 5 individuals who will need to learn to work and coordinate together.
| Time | We need to learn how to manage time effectively as we must optimize the time between meetings, in-class work, and homework. The lack of experience and the learning curve associated with new technologies can lead to issues.
| New Technologies | The majority of technologies are new to us, and we need to learn how to work with them.
| Communication Difficulties | The lack of familiarity within the team can lead to misunderstandings or a lack of communication and coordination.
| Time | The team will need to present the project with new advancements, adapting to the anticipated delivery dates,
as well as what has been established in the minutes taken during the weekly team meetings.
| Meetings | Every week there will be a meeting among the team members where problems will be discussed, the work that each member
should do for the next meeting will be established, and the work done to date will be reviewed.
|===

3.Convention Constraints
[options = "header", cols = "1,2"]
|===
| Constraint | Description
| Documentation | Arc42 is a template for architecture documentation. It is the one we should use to generate the documentation.
| Code | The code should follow an order that does not pose any problem when understanding it for another team member.
| Clean Code | he code should follow an order that does not pose any problem for another team member to understand. In addition, good practices such as naming conventions should be followed.
| Structure | The project must follow a fixed structure, both the documentation and the code must be done under the same standards.
|===
44 changes: 22 additions & 22 deletions docs/src/05_building_block_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ image::level1.png["Level 1"]

Motivation::

The motivation for undertaking this decomposition is to gain a clear vision of the system developed for the WIQ application.
By breaking down the system into its constituent building blocks, we aim to establish a comprehensive understanding of its structure and functionality.
The motivation for undertaking this decomposition is to gain a clear vision of the system developed for the WIQ application.
By breaking down the system into its constituent building blocks, we aim to establish a comprehensive understanding of its structure and functionality.

The motivation for performing this decomposition is to obtain a clear view of the system developed for the WIQ application.
By breaking the system down into its basic components, we aim to establish a comprehensive understanding of its structure and functionality.

Contained Building Blocks::

Expand All @@ -26,45 +23,48 @@ Contained Building Blocks::
| **Name** | **Responsibility**
| Webapp | Provides the interface to register, play and check participation history
| Gateway service | Facilitates communication between the different ports of the application
| Databases | Stores information about users, games, questions and correct/failed answers
| Services | They receive requests from the gateway service and execute the corresponding operations
| Authservice | Allows a user to create an account in our application
| Userservice | Allows a user to access our application to play and view their history
| Roomservice | Service that handles multiplayer gaming in rooms
| Historyservice | Service that is responsible for saving and returning the history of user games
| Questionservice | It calls the Wikidata API using queries to retrieve questions, then stores them in the database. Additionally, it retrieves questions from the database when needed.
| Databases | Stores information about users, games, questions and history
|===


=== Level 2

==== White Box User Interface
==== White Box Users Services

image::Level2Webapp.png["Level 2 Webapp"]
image::level2-Users.png["Level 2 Users Services"]

[cols="1,2" options="header"]
|===
| **Name** | **Responsibility**
| homepage | Allows a user to log in or sign up an account
| gamepage | Allows a user to play the game
| participation history | Allows the user to consult the history of their participation in the system
| authservice | The authentication service validates user credentials by verifying their existence in the database and ensuring the correctness of the provided password.
| userservice | The registration service validates user registration details by checking the uniqueness of the email and username in the database, as well as verifying the format and correctness of the provided password, ensuring it matches the repeated entry.
| userdb | The user database stores user information, including their email, username, and hashed password. Each user have their credentials securely stored for authentication purposes.
|===

==== White Box Services
==== White Box Questionservice

image::Level2Services.png["Level 2 Business Logic"]
image::level2-Question.png["Level 2 Questionservice"]

[cols="1,2" options="header"]
|===
| **Name** | **Responsibility**
| authservice | Allows a user to create an account in our application
| userservice | Allows a user to access our application to play and view their history
| questionsService | It calls the Wikidata API using queries to retrieve questions, then stores them in the database. Additionally, it retrieves questions from the database when needed.
| questionservice | The questionservice automatically generates questions by making a call to the Wikidata API, retrieving relevant information, and subsequently saving the generated question in the database. Additionally, it is responsible for providing questions tailored for each type of game available in the application.
| questionsdb | Database that stores the question along with their correct answer, the category to which the question belongs, the type of the question and the answers to those questions.
|===

==== White Box Databases
==== White Box Historyservice

image::Level2Databases.png["Level 2 Database"]
image::level2-History.png["Level 2 Historyservice"]

[cols="1,2" options="header"]
|===
| **Name** | **Responsibility**
| usersdb | Store all the information of the users
| questionsdb | Store all the information of the questions
|===
| historyservice | The historyservice is responsible for storing data for each normal game played and providing access to this data in two formats. It offers two types of data retrieval: one that returns all normal games played with their respective data, and another that returns the complete history, encompassing all data related to every game played.
| historydb | The historydb stores user data and maintains a record of each normal game played. For every game, it saves essential details including the game number, the number of correct questions, the number of failed questions, the time taken to complete the game, and the date on which it was played.


3 changes: 2 additions & 1 deletion docs/src/08_concepts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ In development...

=== Development concepts

* Test: Realizadas pruebas de testing del microservicio gateway-service y del componente de webapp Game,
* Test: To test the correct operation of the system, we have decided to carry out unit tests for the application components as well as for the services.
Testing has been carried out on the gateway-service microservice and the Game webapp component.
67 changes: 45 additions & 22 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,59 @@ app.post('/adduser', async (req, res) => {

app.get('/getQuestion', async (req, res) => {
try {
const idioma = req.query.idioma;
// llamamos al servicio de preguntas
const questionResponse = await axios.get(questionServiceUrl+'/getQuestion', req.body);
const questionResponse = await axios.get(`${questionServiceUrl}/getQuestion?idioma=${idioma}`, req.body);

res.json(questionResponse.data);
} catch (error) {
//Modifico el error
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de preguntas' });
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de preguntas para obtener una pregunta -> ' + error.message});
}
});


app.get('/getQuestionModoBasico', async (req, res) => {
app.get('/getQuestionDiaria', async (req, res) => {
try {
const idioma = req.query.idioma;
const fecha = req.query.fecha;

// llamamos al servicio de preguntas
const questionResponse = await axios.get(questionServiceUrl+'/getQuestionModoBasico', req.body);
const questionResponse = await axios.get(`${questionServiceUrl}/getQuestionDiaria?idioma=${idioma}?fecha=${fecha}`, req.body);

res.json(questionResponse.data);
} catch (error) {
//Modifico el error
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de preguntas' });
}
});


app.get('/getQuestionModoBasico', async (req, res) => {
try {
// Obtener el idioma en el que esta la app
const idioma = req.query.idioma;
console.log("entro en getQuestionModoBasico " + idioma);
// llamamos al servicio de preguntas
const questionResponse = await axios.get(`${questionServiceUrl}/getQuestionModoBasico?idioma=${idioma}`, req.body);

console.log("getQuestionModoBasico response: ", questionResponse.data);
res.json(questionResponse.data);
} catch (error) {
//Modifico el error

res.status(500).json({ error: 'Error al realizar la solicitud al servicio de preguntas modo basico' });

}
});

app.get('/generateQuestion', async (req, res) => {
try {
// llamamos al servicio de preguntas
await axios.get(questionServiceUrl+'/generateQuestion', req.body);

await axios.get(questionServiceUrl+'/generateQuestion', req.body);
res.status(200).send("Pregunta generada y guardada correctamente.");
} catch (error) {
//Modifico el error
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de generacion de preguntas' });

res.status(500).json({ error: 'Error al realizar la solicitud al servicio de generacion de preguntas -> ' + error.response.data.error});
}
});

Expand All @@ -101,7 +123,7 @@ app.get('/getHistoryDetallado', async (req, res) => {
res.json(historyResponse.data);
} catch (error) {
//Modifico el error
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de historial' });
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de historial detallado' });
}
});

Expand All @@ -112,12 +134,25 @@ app.get('/getHistoryTotal', async (req, res) => {
// llamamos al servicio de preguntas
const historyResponse = await axios.get(`${historyServiceUrl}/getHistoryTotal?usuario=${usuario}`);

res.json(historyResponse.data);
} catch (error) {
//Modifico el error
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de historial total' });
}
});

app.post('/updateHistory', async (req, res) => {
try {
// llamamos al servicio de preguntas
const historyResponse = await axios.post(historyServiceUrl+'/updateHistory', req.body);

res.json(historyResponse.data);
} catch (error) {
//Modifico el error
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de historial' });
}
});

//***************************************************endpoints de las salas */
app.get('/joinroom/:id/:username',async(req,res)=> {
try {
Expand Down Expand Up @@ -156,18 +191,6 @@ app.get('/startgame/:id/:username',async(req,res)=> {
}
});

app.post('/updateHistory', async (req, res) => {
try {
// llamamos al servicio de preguntas
const historyResponse = await axios.post(historyServiceUrl+'/updateHistory', req.body);

res.json(historyResponse.data);
} catch (error) {
//Modifico el error
res.status(500).json({ error: 'Error al realizar la solicitud al servicio de historial' });
}
});

// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
Expand Down
Loading

0 comments on commit ed6ddd7

Please sign in to comment.