Skip to content

stevegaunt/blog

Repository files navigation

Example App

Java 21 + Spring Boot 3 (CRUD, auth, advanced patterns, etc) spec and API.

[Demo]


Table of Contents


How it works

The example project aims to represent a simple blog

  1. Authenticate users via JWT
  2. sign up/login users
  3. create/update/detete articles
  4. add feedback to articles
  5. Favorite articles
  6. Follow other users

Project structures

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.

Modules

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.

Classes

  • ~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.

Database architecture

Note: I paid attention to data types, but did not pay much attention to size.


Getting started

Note: You just need to have JDK 21 installed.

Run application

./gradlew :bootstrap:bootRun

Apply code style

Note: When you run the build task, this task runs automatically. If the code style doesn't match, the build will fail.

./gradlew spotlessApply

Example GraphQl request

POST using graphql client

http://localhost:8080/graphql

query
UserByName {
  userByName(username: "u1714138542") { 
      username
      email
      username
      bio
      article {
           title
      }
  }
}

Run test

./gradlew test

Run build

./gradlew build

Run E2E test

  1. Run application (important)
  2. Run E2E test

About

java 21 using spring boot 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages