The example project aims to represent a simple blog
- Authenticate users via JWT
- sign up/login users
- create/update/detete articles
- add feedback to articles
- Favorite articles
- Follow other users
The project is implemented based on Java 21 and Spring Boot 3, utilizing various Spring technologies such as Spring MVC, Spring Data JPA, and Spring Security. It uses H2 DB (in-memory, MySQL mode) as the database. and JUnit5 for writing test codes.
core
, persistence
, api
and bootstrap
modules exist, and each module performs the following roles.
- bootstrap: All existing modules are put together to form an executable application.
- core: Contains the core logic of the application, including the domain model, service, and exception handling.
- persistence: Contains the persistence layer logic of the application, including the repository and entity.
- api: Contains the API layer logic of the application, including the controller and DTO and Graphql.
- ~Controller: Processes HTTP requests, Graphql Requests, calls business logic, and generates responses.
- ~Service: Implements business logic and interacts with the database through Repositories.
- ~Repository: An interface for interacting with the database, implemented using Spring Data JPA.
Note: I paid attention to data types, but did not pay much attention to size.
Note: You just need to have JDK 21 installed.
./gradlew :bootstrap:bootRun
Note: When you run the
build
task, this task runs automatically. If the code style doesn't match, the build will fail.
./gradlew spotlessApply
POST using graphql client
http://localhost:8080/graphql
query
UserByName {
userByName(username: "u1714138542") {
username
email
username
bio
article {
title
}
}
}
./gradlew test
./gradlew build
- Run application (important)
- Run E2E test