https://github.com/alashutosh/blog_assignment
This is a blog management application built with Spring Boot and MySQL. It allows users to create, update, delete, and fetch blogs, as well as generate reports based on the most frequently used words in blogs created by the user.
https://github.com/alashutosh/blog_assignment
hibernet rest-api springboot
Last synced: about 2 months ago
JSON representation
This is a blog management application built with Spring Boot and MySQL. It allows users to create, update, delete, and fetch blogs, as well as generate reports based on the most frequently used words in blogs created by the user.
- Host: GitHub
- URL: https://github.com/alashutosh/blog_assignment
- Owner: AlAshutosh
- Created: 2025-01-23T10:27:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-23T11:17:10.000Z (over 1 year ago)
- Last Synced: 2025-01-23T11:32:38.528Z (over 1 year ago)
- Topics: hibernet, rest-api, springboot
- Language: Java
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Blog Application
This is a blog management application built with Spring Boot and MySQL. It allows users to create, update, delete, and fetch blogs, as well as generate reports based on the most frequently used words in blogs created by the user.
Features
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.
Technologies Used
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
Prerequisites
Java 11 or higher
MySQL Database
Maven or Gradle
1. Clone the Repository
bash
Copy
Edit
git clone https://github.com/AlAshutosh/blog_assignment.git
2. Configure MySQL Database
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.
3.Setup Application Properties
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
4. Build and Run the Application
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.
API Endpoints
1. 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" }
2. 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" }
3. Fetch a Blog by User URL: /blogs/user/{userId}
Method: GET
Description: Retrieves all blogs for a specific user by userId.
4. 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" }
5. Delete a Blog URL: /blogs/delete/{blogId}
Method: DELETE
Description: Deletes a blog by blogId.
6. 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.
UI
The front-end for interacting with the API can be built using HTML, Thymeleaf, and JavaScript.
The following pages are available for user interactions:
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.