To run this application locally, you will need to have Java and MySQL installed on your machine.
- Clone the repository to your local machine.
- Create a new MySQL database called
blogapp
- Make sure you have Java JDK above 8 on ur local machine.
- Update the
application.properties
file in thesrc/main/resources
directory to include your MySQL username and password - Run the application using your IDE or by running the command
mvn spring-boot:run
in the project directory - Access the APIs using any HTTP client such as Postman or Swagger open AI.
The application is built using the SpringBoot framework and consists of seven layers: DTO, model, controller, service, security, repository and jwt
- DTO -The DTO layer consists of classes that are used to transfer data between different layers of the application
- Controller - The controller layer handles the HTTP requests, translates the JSON parameter to object, and authenticates the request and transfer it to the business (service) layer.
- Service -The business layer handles all the business logic. It consists of service classes and uses services provided by data access layers.
- Security -We configure Spring security in this layer by creating security beans such as UserDetailsService,PasswordEncoder,SecurityFilterChain
- JWT - In this layer we configure JWT Authentication filter and create Jwt entry point.
- Repository - This layer maintains the data by accessing Mysql Database on which CRUD operations are performed.. for that we extend our interface with another interface called JpaRepository.
- Model - This layer consists basically the class level things-and this classes are stored in form of tables in given Mysql database as we annotate this class by @Entity.
-
UserService
- SignUp Blog User
- SignIn Blog User
- Create Blog Post
- Remove Blog Post
- Add Comment
- Authorize Comment Remover
- Remove Blog Comment
- Get All Users
- Follow User
- Update Blog Post
- SignOut Blog User
- Unfollow User
- Authorize Unfollow
- PostService
- Create Blog Post
- Remove Blog Post
- Validate Post
- Get Post By Id
- Get All Posts
- FollowService
- Start Following
- Is Follow Allowed
- Find Follow
- Unfollow
- CommentService
- Add Comment
- Find Comment
- Remove Comment
- AuthenticationService
- Authenticate
- Save AuthToken
- remove token
-
POST /userfollower/follow :- follow user
-
GET /userfollower/followed/{id} :- get all followed user of particular user
- Repository
JpaRepository
- Arraylist
- MYSQL Database
- This is "Blogging-Platform-Api" Application which follows MVC-architecture.I have created this project by using spring initilizer by taking 7 dependency i.e., lombok, spring web,Mysql,JPA,Email,swagger,and Validation. In my model package I have User,Authentication,Follow,Post,Comment class which has all its related data.
- A user can SignUp and SignIn on Blogging Platform.
- A User can create a Post on Blogging Platform.
- A User can follow another User on Blogging Platform.
- A user can post a comment on another's post on this Blogging Platform.
- A PostOwner can delete his post and comments.
- Any user can delete his comment.
This is a brief summary of my project where we can perform all these task smoothly and efficiently.
- Pratik Sharma
- Mail to: [email protected]