- Route
/
: welcome page, it has 2 buttons to the main functionalities - Route
/play
: route used to play the game, it renders the game instructions, the different rounds and the recap - Route
/profile
: shows the logged user info and the history of the played games, if the user is not logged in it navigates to/
- Route
/login
: shows the login form, if the user is logged in it navigates to/
- Route
/logout
: application navigates to this route when a logout request is sent, when the server response arrives it navigates to/
- Route
/*
: default route, it signals that it doesn't match any route
- POST
/api/sessions
- Login request
- Response:
201 Created
(success) or401 Unauthorized
(wrong login). - Request body:
{ username: 'nzino', password: 'password' }
- GET
/api/sessions/current
- Current session request
- Response:
200 OK
(success) or401 Unauthorized
(Not authenticated).
- DELETE
/api/sessions/current
- Logout request
- Response:
200 OK
(success)
- GET
/api/memes/random
- If the user is logged in retrive 3 random meme images, each with 7 captions (2 are correct).
- If the user is not logged in retrive 1 random meme image with 7 captions (2 are correct).
- Response:
200 OK
(success) or500 Internal Server Error
(generic error). - Response body:
[ { "captions": [ {"id": 2, "text": "Esami a fine luglio"}, {"id": 16, "text": "Lezione a metà giugno senza aria condizionata"}, {"id": 1, "text": "Lezione alle 8:30"}, {"id": 15, "text": "Io che mi preparo a dare 4 esami in 10 giorni"}, {"id": 14, "text": "C'è un AI che fa i meme per te"}, {"id": 6,"text": "Io a Torino a Luglio // I miei amici al mare in Puglia"}, {"id": 19, "text": "Average python fan // Average C enjoyer"} ], "id": 1, "image_path": "meme1.jpg" }, ... ]
- GET
/api/memes/:id/captions
- Retrieve the correct captions of a meme given its image
id
- Response:
200 OK
(success) or500 Internal Server Error
(generic error). - Response body:
[ {"id": 5, "text": "Io durante la sessione"}, {"id": 1, "text": "Lezione alle 8:30"}, ... ]
- Retrieve the correct captions of a meme given its image
- POST
/api/games
- Save a new game
- Response:
201 Created
(success),401 Unauthorized
(user is not logged in),422 Unprocessable Content
(wrong parameters) or500 Internal Server Error
(generic error). - Request body:
{ scores: [0,0,5], images: [ 'meme9.jpg', 'meme10.jpg', 'meme2.jpg' ] }
- GET
/api/games
- Get all games of the requesting user
- Response:
200 OK
(success),401 Unauthorized
(user is not logged in) or500 Internal Server Error
(generic error). - Response body:
[ { "id": 1, "user_id": 1, "scores": [0,0,0], "images": [ "meme3.jpg", "meme10.jpg", "meme8.jpg" ] }, ... ]
- Table
captions
- contains:
id
(INTEGER)text
(TEXT)
- primary key:
id
- contains:
- Table
images
- contains:
id
(INTEGER)image_path
(TEXT)
- primary key:
id
- contains:
- Table
image_caption
- contains:
image_id
(INTEGER)caption_id
(INTEGER)
- primary key:
image_id
+caption_id
- foreign keys:
image_id
→images.id
caption_id
→captions.id
- contains:
- Table
users
- contains:
id
(INTEGER)username
(TEXT)password
(TEXT)salt
(TEXT)
- primary key:
id
- contains:
- Table
games
- contains:
id
(INTEGER)user_id
(INTEGER)score_round1
(INTEGER)score_round2
(INTEGER)score_round3
(INTEGER)image_round1
(TEXT)image_round2
(TEXT)image_round3
(TEXT)
- primary key:
id
- foreign key:
user_id
→users.id
- contains:
Header
(inHeader.jsx
): navigation bar, it shows the brand name with a link to/
, a login button for the unauthenticated or a dropdown menu for the logged userLoginForm
(inLoginForm.jsx
): form to manage loginNotFound
(inNotFound.jsx
): it shows the not found messageWelcomePage
(inWelcomePage.jsx
): it shows a welcome message if the user is not logged in, with a button to play and a button to login; if the user is logged in it shows a button to play and a button to see the user's profileGamePage
(inGameComponents.jsx
): wraps and managesInstructions
,Round
andRecap
Instructions
(inGameComponents.jsx
): it shows the game istructionsRound
(inGameComponents.jsx
): it shows meme image and captions to guessRecap
(inGameComponents.jsx
): sums up the results of the gameTimer
(inGameComponents.jsx
): timer countdownProfilePage
(inProfileComponents.jsx
): wrapsProfile
andPreviousGames
Profile
(inProfileComponents.jsx
): it shows the user info pus some statisticsPreviousGames
(inProfileComponents.jsx
): shows user's previous gamesDetails
(inProfileComponents.jsx
): shows game details on a OffCanvas
- username:
nzino
, password:password
- username:
luigi
, password:password