Skip to content

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.

Notifications You must be signed in to change notification settings

AlAshutosh/blog_assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published