Login: Allows users to authenticate.
Create Blog: Allows users to create a new blog.
Fetch Blog: Retrieves blogs associated with a user by userId.
Update Blog: Updates an existing blog.
Delete Blog: Deletes an existing blog by blogId.
Generate Report: Generates a report with the top 5 most frequently used words from all blogs created by the user.
Spring Boot: A Java-based framework to build and run the application.
MySQL: Used to store user and blog data.
Thymeleaf: Used to render HTML templates for the UI.
Setup and Installation
Java 11 or higher
MySQL Database
Maven or Gradle
bash
Copy
Edit
git clone https://github.com/AlAshutosh/blog_assignment.git
Create a new database in MySQL named blogdb.
Create the necessary tables for User and Blog.
You can refer to the application.properties file for connection details.
In the src/main/resources/application.properties file, configure your database connection:
spring.datasource.url=jdbc:mysql://localhost:3306/blog_app
spring.datasource.username=root
spring.datasource.password=yourpassword
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
To build and run the Spring Boot application, execute the following commands:
bash mvn clean install mvn spring-boot:run The application will start on localhost:8080.
-
Login URL: /auth/login
Method: POST
Description: Authenticates a user by username and password.
Request Body: json Copy Edit { "username": "your-username", "password": "your-password" } -
Create a Blog URL: /blogs/create
Method: POST
Description: Creates a new blog.
Request Body: json Copy Edit { "title": "Your Blog Title", "body": "Your Blog Content" } -
Fetch a Blog by User URL: /blogs/user/{userId}
Method: GET
Description: Retrieves all blogs for a specific user by userId. -
Update a Blog URL: /blogs/update/{blogId}
Method: PUT
Description: Updates an existing blog.
Request Body: json Copy Edit { "title": "Updated Blog Title", "body": "Updated Blog Content" } -
Delete a Blog URL: /blogs/delete/{blogId}
Method: DELETE
Description: Deletes a blog by blogId. -
Generate Report URL: /report/{userId}
Method: GET
Description: Generates a report showing the top 5 most frequently used words in blogs for a specific user.
Login Page: Allows users to log in and authenticate.
Create Blog Page: Allows users to create new blogs.
View Blog Page: Displays all blogs for the logged-in user.
Update Blog Page: Allows users to update existing blogs.
Delete Blog Page: Allows users to delete existing blogs.
Report Page: Displays the report with the most frequent words used in the blogs.