Skip to content

Java Spring Boot

Finn Lippok edited this page Jul 7, 2023 · 9 revisions

We have chosen to use Java Spring as our framework due to its numerous strengths and advantages. It is a proven and robust framework that has been continuously developed for many years. As a result, extensive resources, documentation, and an active community are available, making the development and maintenance of the application easier.

Structure

Another advantage of Java Spring is its support for the Controller-Service-Repository pattern. This design pattern allows for a clear separation of responsibilities and promotes a modular and well-structured codebase.

image

  • Controller: The controller is part of the presentation layer and is responsible for handling HTTP requests and returning HTTP responses. It manages the communication between the front-end and the back-end and forwards the requests to the corresponding service.

  • Service: The service contains the actual business logic of the application. It processes the received requests, performs the necessary actions, and interacts with repositories to access data. The service implements the business rules and ensures the proper handling of requests.

  • Repository: The repository is responsible for data access. It provides methods for reading, creating, updating, and deleting data in the database. The repository acts as an interface through which the service can access the database.

Example Sequence Diagram for Adding new Post (simplified):

sequenceDiagram
    Frontend->>PostController: Add new post API request
    PostController->>PostService: Add new post
    PostService->>PostRepository: Save post
    PostRepository-->>PostService: 
    PostService-->>PostController: 
    PostController-->>Frontend: Return Postresponse as Responseentity
Loading

Example Sequence Diagram for Adding new Post:

sequenceDiagram
    Frontend->>+JwtAuthenticationFilter: Add new post request
    JwtAuthenticationFilter->>+jwtService: Check Token 
    jwtService-->>-JwtAuthenticationFilter: Token is Valid 
    JwtAuthenticationFilter->>+PostController: forward new post Request
    PostController->>+UserService: get User
    UserService->>+UserRepository: findbyUsername
    UserRepository-->>-UserService: User DAO
    UserService-->>-PostController: User DAO
    PostController->>+PostService: Add new Post
    PostService->>+PostRepository: Save post
    PostRepository-->>-PostService: ‎
    PostService-->>-PostController: 
    PostController-->>-Frontend: Post DAO as ResponseEntity
Loading

API

Posts User Comment FileData Admin Authentication

To facilitate data exchange between the client and server, the server provides an API. The Schoolforum operates using a RESTful API, which enables the client to retrieve, create, update, or delete information through specific endpoints.

The communication between the client and server occurs over the HTTP protocol. The API utilizes various HTTP methods such as GET, POST, PUT, and DELETE to perform the desired operations. These methods correspond to retrieving data, creating new data, updating existing data, and deleting data, respectively.

When making requests to the API, data can be passed either through the URL as path variables or in the form of JSON. Path variables allow for including specific identifiers or parameters in the URL to specify the requested resource or operation. JSON, on the other hand, is a lightweight data format that is commonly used for transmitting structured data between the client and server.

image

Clone this wiki locally