Build a RESTful API for a simple social media application using Spring Boot, Hibernate, and PostgreSQL. The application should allow users to create and view posts, follow other users, and like posts. Each post should have a title, body, and author. Use Hibernate to persist the post and user data in the database.
- JDK 8 or later installed (JDK 11 or later recommended)
- Maven 3.6.0 or later installed (3.9.1 or later recommended)
-
Clone this repository:
git clone https://github.com/Seniuk-Vi/SocialMedia-AI-task cd SocialMedia-AI-task
-
Create empty PostgreSQL database and add credentials to hibernate.cfg.xml
<!--DB_NAME--> <!--USERNAME--> <!--PASSWORD-->
-
Build and run the project:
mvn clean clean install
The application should now be up and running at http://localhost:8080
.
SonarQube is an open-source platform for continuous code quality analysis. It helps developers identify potential issues like code smell, vulnerabilities, and bugs. In this project, we have integrated SonarQube for code quality control.
-
Run Docker and run sonarqube
sudo docker run -d --name sonarqube -p 9000:9000 -v /sonar/data:/opt/sonarqube/data -v /sonar/extensions:/opt/sonarqube/extensions sonarqube:9.3.0-community
-
You can access the SonarQube web portal at
http://localhost:9000
. The default login credentials areadmin
for both the username and password. -
Create settings.xml in your
User/.m2
folder. Pass your credentials to SonarQube. -
Run the analysis: In the terminal, navigate to your project's root directory and execute the following command:
mvn clean install sonar:sonar
-
View the report: After the analysis is complete, you can view the report by going to
http://localhost:9000/projects
and clicking on your project.
- Was it easy to complete the task using AI?
- Quite easy, but there were some problems with
hibernate
, AI just insisted on using JPA, and it was hard to get proper configuration for plain hibernate.
- Quite easy, but there were some problems with
- How long did task take you to complete? (Please be honest, we need it to gather anonymized statistics)
- Around 7 hours.
- Was the code ready to run after generation? What did you have to change to make it usable?
- For plain java it was perfect. But when using hibernate, chat provided deprecated arguments for configuration. Also with when working with SonarQube + Spring Boot, it was hard to configure, on the internet there no a lot of helpful articles about it, I need to combine Chat and Internet to get that working.
- Which challenges did you face during completion of the task?
- Hibernate and SonarQube (with JaCoCo) configuration.
- Which specific prompts you learned as a good practice to complete the task?
- I used Chat to generate phases of building such project, and asked to add questions to each phase, that I can ask Chat to help me.