This project has been developed by Andrea Deluca for the course of "Applicazioni Web I", attended during the academic year 2021/22 at Politecnico di Torino, Master's Degree in Computer Engineering.
- React Client Application Routes
- API Server
- Database Tables
- Main React Components
- Screenshot
- Users Credentials
This is the index route
Homepage for guest users (not logged in users).
This route is unprotected from the user authentication. Moreover, it is unreachable when the user is logged in.
Page that contains the login form to perform authentication.
This route is unprotected from the user authentication. Moreover, it is unreachable when the user is logged in.
Page that contains the list of all courses offered
This route is unprotected from the user authentication.
Homepage for authenticated and logged in users.
This route is protected. The user must be authenticated to navigate here.
Page that contains info about the study plan associated with the logged in user and its correlated list of courses, if they exist.
This route is protected. The user must be authenticated to navigate here.
Page where the logged in user can edit the list of courses associated with its study-plan, if they exist.
This route is protected. The user must be authenticated to navigate here.
Any other route is matched by this one where the application shows a page not found error.
Performs user authentication and create a new session for the user.
Request header:
Content-Type: application/json
Request body:
A JSON object containing username and password.
{
"username": "[email protected]",
"password": "Password123*"
}
Response body
HTTP status code 200 OK
{
"id": 1,
"firstname": "Testuser",
"lastname": "User1",
"email": "[email protected]"
}
Error responses
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 401 Unauthorized
(credentials error)
Performs user logout and delete the current user session.
Request header:
Session: req.user to retrieve the logged in user id
Response body
HTTP status code 200 OK
Error responses
HTTP status code 500 Internal Server Error
(generic server error)
Gets information about the user, if he is logged in.
Request header:
Session: req.user to retrieve the logged in user id
Response body
HTTP status code 200 OK
{
"id": 1,
"firstname": "Testuser",
"lastname": "User1",
"email": "[email protected]"
}
Error responses
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(user not found error)HTTP status code 401 Unauthorized
(authentication error)
Gets information about courses offered, including incompatibilities info, ordered by name.
Response body
HTTP status code 200 OK
Here some examples of course objects returned as response body, with and not preparatory course, incompatible courses and maximum number of enrolled students.
[
{
"code": "01UDFOV",
"name": "Applicazioni Web I",
"credits": 6,
"maxStudents": null,
"enrolledStudents": 0,
"preparatoryCourse": null,
"incompatibleCourses": [
{
"code": "01TXYOV",
"name": "Web Applications I"
}
]
},
{
"code": "02GOLOV",
"name": "Architetture dei sistemi di elaborazione",
"credits": 12,
"maxStudents": null,
"enrolledStudents": 0,
"preparatoryCourse": null,
"incompatibleCourses": [
{
"code": "02LSEOV",
"name": "Computer architectures"
}
]
},
{
"code": "03UEWOV",
"name": "Challenge",
"credits": 5,
"maxStudents": null,
"enrolledStudents": 0,
"preparatoryCourse": null
},
...
{
"code": "05BIDOV",
"name": "Ingegneria del software",
"credits": 6,
"maxStudents": null,
"enrolledStudents": 0,
"preparatoryCourse": {
"code": "02GOLOV",
"name": "Architetture dei sistemi di elaborazione"
},
"incompatibleCourses": [
{
"code": "04GSPOV",
"name": "Software engineering"
}
]
},
{
"code": "01URSPD",
"name": "Internet Video Streaming",
"credits": 6,
"maxStudents": 2,
"enrolledStudents": 0,
"preparatoryCourse": null
},
...
]
Error responses
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(courses not found error)
Gets information about types that a study plan can take.
Request header:
Session: req.user to retrieve the logged in user id
Response body
HTTP status code 200 OK
[
{
"id": 1,
"name": "Full-time",
"min_credits": 60,
"max_credits": 80
},
{
"id": 2,
"name": "Part-time",
"min_credits": 20,
"max_credits": 40
}
]
Error responses
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(study plan types not found error)HTTP status code 401 Unauthorized
(authentication error)
Gets information about the study plan associated with the logged in user, including info about the list of courses correlated to it and info about the study plan type.
Request header:
Session: req.user to retrieve the logged in user id
Response body
HTTP status code 200 OK
{
"id": 2,
"totCredits": 23,
"type": {
"id": 2,
"name": "Part-time",
"min": 20,
"max": 40
},
"createDate": "2022-06-21T18:44:00.837Z",
"updateDate": "2022-06-21T18:44:07.302Z",
"courses": ["01UDFOV", "02GOLOV", "03UEWOV"]
}
Error responses
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(study plan not found error)HTTP status code 401 Unauthorized
(authentication error)
Creates a new study plan entry, that has to be associated with the logged in user, and fills its correlated list of courses. It also updates the number of enrolled students for the courses inserted into the study plan.
Request header:
Content-Type: application/json
Session: req.user to retrieve the logged in user id
Request body:
A JSON object containing info about the study plan and a list of courses to insert into the correlated list.
{
"updates": {
"inserts": ["01UDFOV", "02GOLOV", "03UEWOV"],
"deletes": []
},
"plan": {
"type": 2,
"credits": 23,
"createDate": "2022-06-21T09:19:11.091Z",
"updateDate": "2022-06-21T09:25:03.091Z"
}
}
Response body
HTTP status code 200 OK
Error responses
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 422 Unprocessable Entity
(validation error)HTTP status code 401 Unauthorized
(authentication error)
Updates info about the study plan associated with the logged in user and the list of courses correlated to it, given the study plan id. It also updates the number of enrolled students for the courses inserted and removed from the study plan.
Request header:
Content-Type: application/json
Session: req.user to retrieve the logged in user id
Params: req.params.id to retrieve study plan id
Request body:
A JSON object containing info about the updates for the study plan.
{
"updates": {
"inserts": ["01SQMOV", "01UDUOV"],
"deletes": ["03UEWOV"]
},
"plan": {
"type": 2,
"credits": 38,
"updateDate": "2022-06-23T11:28:03.091Z"
}
}
Response body
HTTP status code 200 OK
Error responses
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 422 Unprocessable Entity
(validation error)HTTP status code 404 Not Found
(study plan not found error)HTTP status code 401 Unauthorized
(authentication error)
Deletes the study plan associated with the logged in user and the list of courses correlated to it, given the study plan id. It also updates the number of enrolled students for the courses removed from the study plan.
Request header:
Session: req.user to retrieve the logged in user id
Params: req.params.id to retrieve study plan id
Response body
HTTP status code 200 OK
Error responses
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 422 Unprocessable Entity
(validation error)HTTP status code 404 Not Found
(study plan not found error)HTTP status code 401 Unauthorized
(authentication error)
It contains info about users, including authentication info.
id (PRIMARY KEY)
firstname
lastname
email (UNIQUE NOT NULL) - used as username during authentication
password
salt
It contains info about courses offered, including propedeuticity info.
id (PRIMARY KEY)
code (UNIQUE NOT NULL)
name
credits
max_students - it can be null
enrolled_students
preparatory_course (FOREIGN KEY REFERENCES courses(code)) - it can be null
It contains info about incompatible courses.
id (PRIMARY KEY)
course_code (FOREIGN KEY REFERENCES courses(code))
incompatible_course (FOREIGN KEY REFERENCES courses(code))
It contains info about types that a study plan can take, i.e. Full-time or Part-time.
id (PRIMARY KEY)
name
min_credits
max_credits
It contains info about the list of courses associated with a study plan.
id (PRIMARY KEY)
course_code (FOREIGN KEY REFERENCES courses(code))
It contains info about study plans.
id (PRIMARY KEY)
user_id (FOREIGN KEY REFERENCES users(id))
list_id (FOREIGN KEY REFERENCES courses_lists(id))
type_id (FOREIGN KEY REFERENCES study_plan_types(id))
tot_credits
create_timestamp
last_update_timestamp
components/forms/LoginForm.jsx
This component contains the login form that calls the correlated API on submit.
components/ui-core/Course.jsx
This component shows the main info about a course. In particular, it shows the course code, its name, its number of credits, its maximum number of enrolled students, if exists, and the number of enrolled students at the moment.
components/ui-core/Course.jsx
This component shows the propedeuticity and incompatibility info about a course.
components/ui-core/CoursesList.jsx
This component is a wrapper for the visualization of all course info in an expandable way. In particulr, if it's closed, the component shows just the CourseHeader component, else if it'open, also CourseBody component is shown.
components/ui-core/CoursesList.jsx
This component shows a list of ExpandableCourse components, given the array of courses to show.
components/ui-core/OptionModal.jsx
When this modal is triggered, it shows info about the study plan types and it allows the user to choose one option to create its study plan locally, without any saving in db.
components/ui-core/SelectableCoursesList.jsx
This component shows all info about a course, i.e. CourseHeader and CourseBody components, and draws a green border when a course results selected. Moreover, it also can show a course as disabled.
components/ui-core/SelectableCoursesList.jsx
It contains the logic on client-side of the update of a study plan and its correlated list of courses.
This component shows two lists of SelectableCourse components to show the list of courses already inserted into the study plan associated with a user and the list of courses not selected, possibly disabled. Moreover, it checks for study plan courses constraints when a course is selected or deselected.
pages/Plan.jsx
This component shows info about the study plan associated with the logged in user and the list of courses correlated, if they exist. Morover, it contains client-side logic to delete the stuy plan.
pages/EditPlan.jsx
This component allows the logged in user to edit his study plan and its correlated list of courses, if they exist. Morover, it contains the client-side logic to perform the creation or the update of the study plan on submit.
id | firstname | lastname | password | study plan | |
---|---|---|---|---|---|
1 | Testuser | User1 | [email protected] | Password123* | Full-time |
2 | Testuser | User2 | [email protected] | Password123* | Part-time |
3 | Testuser | User3 | [email protected] | Password123* | Part-time |
4 | Testuser | User4 | [email protected] | Password123* | |
5 | Testuser | User5 | [email protected] | Password123* |