API REST Survey IT is an IT survey application built using Spring Boot that allows users to participate in and view results of structured IT surveys. The application, ITLens, enables survey creation and management, organized into chapters and subchapters containing various types of questions, with RESTful APIs facilitating interaction.
- Survey Participation: Allows users to respond to open surveys.
- Results Consultation: Provides aggregated results as statistics and percentages for analysis.
- Survey: Comprises multiple chapters.
- Chapters: Contains subchapters with grouped questions.
- Subchapters: Each holds one or more questions.
- Question Types:
- Single Choice: E.g., "What is your age?"
- Multiple Choice: E.g., "What languages can you read/write?"
-
Survey Management
POST /surveys
- Create a new survey.POST /surveys/{surveyId}/chapters
- Add a chapter to a survey.POST /chapters/{chapterId}/subchapters
- Add a subchapter to a chapter.POST /subchapters/{subChapterId}/questions
- Add a question to a subchapter.
-
Survey Participation
POST /surveys/{surveyId}/participate
- Submit a user's survey responses.- Example Payload:
{ "responses": [ { "questionId": 1, "answerId": "11" }, { "questionId": 2, "answers": [{"answerId": "25"}, {"answerId": "34"}] } ] }
-
Results Consultation
GET /surveys/{surveyId}/results
- Retrieve survey results.- Example Response:
{ "surveyTitle": "IT Survey 2024", "chapters": [ { "title": "Profile", "subChapters": [ { "title": "Age", "question": "What is your age?", "answers": { "18-24": 45, "25-34": 35, "35-44": 15, "Younger than 18": 5 }, "totalAnswers": 100 } ] } ] }
- Backend: Spring Boot
- Spring Web: For exposing the REST API.
- Spring Data JPA: Manages persistence with a relational database (PostgreSQL or MySQL).
- Lombok: Reduces boilerplate code (auto-generates getters, setters, constructors).
- MapStruct: Maps between DTO and entities.
- JUnit 5 & Mockito: For unit and service testing.
- @RestControllerAdvice: Centralized exception handling.
- Swagger: Auto-generates API documentation.
- Database: PostgreSQL
-
Survey
id
: Unique identifiertitle
: Survey titledescription
: Brief descriptionowner
: Reference to the survey owner
-
SurveyEdition
id
: Unique identifiercreationDate
: Creation datestartDate
: Launch dateyear
: Launch yearsurvey
: Reference to associated survey
-
Chapter
id
: Unique identifiertitle
: Chapter titlesurvey
: Reference to associated survey
-
SubChapter
id
: Unique identifiertitle
: Subchapter titlechapter
: Reference to associated chapter
-
Question
id
: Unique identifiersubChapter
: Reference to associated subchaptertext
: Question texttype
: Question type (SINGLE_CHOICE, MULTIPLE_CHOICE)answerCount
: Number of responses to the question
-
Answer
id
: Unique identifierquestion
: Reference to associated questiontext
: Answer textselectionCount
: Count of selections for this answerpercentage
: Calculated based onanswerCount
andselectionCount
-
Owner
id
: Unique identifiername
: Owner's name