IPW_IP 2425 1 A2 - isel-leic-ipw/2425i-IPW-LEIC33D GitHub Wiki

Instituto Superior de Engenharia de Lisboa
Bachelor in Computer Science and Computer Engineering
Bachelor in Informatics, Networks and Telecommunications Engineering
Internet Programming/Introduction to Web Programming
Winter Semester of 2024/2025 – 2nd practical assignment - FOCCACIA - Part1

Delivery

Due date for this assignment: 02/12/2024-23h59

Delivery method

The delivery method is done through Github Classroom, using the invitation links below. Following the corresponding link, login with your github user and select your student id to make the correspondence between them and create a new group or join an existing one. If you create a new repository, the repository name should be: <LEIC|LEIRT>2425i-<COURSE><CLASS>-<GROUP_NUMBER>. For example:

  • Group 2 for class LEIC31D from IPW course, should name the repository: LEIC2425i-IPW31D-G02
  • Group 1 for class LEIRT51D from PI course LEIRT2425i-PI51D-G01.

The registration in the assignment should be done through the following Github Classroom

The assignment should be delivered in this repository, by creating a tag called FOCCACIA-P1. If you need to make some changes to the delivery, just create another tag named FOCCACIA-P1.1, FOCCACIA-P1.1, etc.

Introduction

The practical component evaluation for this course will be carried out based on the FOCCACIA (FOotball Complete Clubs Api and Chelas Internet Application), to be developed throughout the semester. This application provides access, through a web interface (hypermedia), using the information provided by the API Football. To access this API, each student must request the API key that identifies the student application's requests. That key must be included in the header x-apisports-key of each HTTP request. The description of the necessary steps to create the token are described here. Note that this is a free API, and therefore it has rate limits for your requests. Be sure you understand and comply to these limits.

The development will be carried out incrementally, necessarily involving several code refactoring cycles and, therefore, it is essential that you make use of good programming practices in general, in order to reduce the effort associated with each cycle.

The development of the FOCCACIA application has 3 development cycles, phased in three parts (Part 1, Part 2 and Part 3). For each one, the deadline for delivering the solution will be defined, and it will be a non-negotiable requirement.

For each FOCCACIA functionality, the corresponding HTTP *endpoint- must be defined. The description of the application API (i.e. all application endpoints) must appear on the repository in an OpenAPI file, named docs/foccacia-api-spec.json (or .yaml). The repository must also contain REST client compatible files (with .http extension), with the requests that validate the API, in a file named docs/foccacia-api-test.http.

Summary of the artifacts to be submitted upon delivery:

  • OpenAPI/Swagger file with API documentation - docs/foccacia-api-spec.[yaml|json]
  • Http files compatible with REST Client Visual Studio Code Plugin - docs/foccacia-api-requests.http
  • Node.js FOCCACIA application files

Functional Requirements

Develop a web application that provides a web API that follows current principals of current Web the REST principles, with responses in JSON format and that supports the following features:

  • Search clubs by name (using URI https://v3.football.api-sports.io/teams?name=)

  • Get all leagues for a given team (using URI https://v3.football.api-sports.io/leagues?team=)

  • Manage favorite teams groups

    • Create group providing its name and description
    • Edit group by changing its name and description
    • List all groups
    • Delete a group
    • Get the details of a group, with its name and description and the list of its teams with Team and Stadium names, league name and Season.
    • Add a team, in a given league and season for a group (with this operation, the teamId, leagueId and season must be stored in the local data)
    • Remove a team from a group
  • Create new user, given its username For all group operations, a user token must be sent in the Authorization header using a Bearer Token. This token is generated at user creation, and consists of a UUID string, obtained from the crypto.randomUUID() method.

Non-Functional Requirements

The application must be developed with Node.js technology. To handle/receive HTTP requests, the express module must be used. To make HTTP requests, the fetch global function used.

The API Football must be used to obtain data (query) about the teams.

The data that is specific to the application, which can be created, altered and deleted, namely the entire group management, in this phase must be stored in memory.

Any of the base modules of Node.js can be used. In addition to these, in this 1st part of the work, only the following modules can be used:

  • express - Handling HTTP requests
  • debug – Debug messages
  • mocha and optionally chai - Unit tests

Any other module you intend to use must be previously discussed and authorized by the corresponding teacher.

All PUT and POST requests must send their data (except unique resource identifiers) in the request body (body) and not in the query string. The body should be handled by builtin Express JSON middleware.

The server application must consist of at least 5 Node modules:

  • foccacia-server.mjs - file that constitutes the entry point to the server application
  • foccacia-web-api.mjs - implementation of the HTTP routes that make up the REST API of the web application
  • foccacia-services.mjs - implementation of the logic of each of the application's functionalities
  • fapi-teams-data.mjs - access to the Football API.
  • foccacia-data-mem.mjs - access to foccacia data (groups and users), in this version stored in memory .

The dependencies between these modules are as follows:

foccacia-server.mjs -> foccacia-web-api.mjs -> foccacia-services.mjs -> fapi-teams-data.mjs
                                                                     -> foccacia-data-mem.mjs

The server application development methodology must be as follows and in this order:

  1. Design and document API routes (HTTP request type + URL+example response content) using OpenAPI/Swagger format.
  2. Create HTTP requests in REST Client file (ex. FOCCACIA) to test API routes
  3. Implement the server application input module: foccacia-server.mjs. For this module it is not necessary to create unit tests, since it must not implement any logic other than receiving some arguments from the command line (configuration), registering routes and starting the web server. This module can be built as each route in foccacia-web-api.mjs is implemented.
  4. In the foccacia-web-api.mjs module, implement the API routes one by one.
  • For each route implemented, use REST Client to verify the correct functioning of that route.
  • Only move on to implementing the next route when the previous one is fully implemented and tested.
  • For each route, create a request in the REST Client file that validates it.
  • In this phase of the implementation of the module foccacia-web-api.mjs use local data (*mock- of foccacia-services.mjs), that is, testing must be performed without access to the API Football or memory storage.
  1. Implement application services in foccacia-services.mjs module.
  • Follow an approach similar to the one used in foccacia-web-api.mjs in the development of the features of this module and respective unit tests.
  • foccacia-services.mjs module unit tests must be run without access to the API Football (fapi-teams-data.mjs). That is, create a mock for that access.
  1. Implement data access modules:
  • fapi-teams-data.mjs - access to the API Football.
  • foccacia-data-mem.mjs - access groups data.
⚠️ **GitHub.com Fallback** ⚠️