Lab#SB07-1: monitor Book

Spring Boot

Spring-Boot
lab
Spring Boot
Author

albertprofe

Published

Tuesday, June 1, 2021

Modified

Thursday, December 21, 2023

1 monitor Book overview

The project involves creating a Spring Boot application with a primary domain focused on “books” and the implementation of a user activity monitoring system through RESTful APIs. The core objective is to develop a platform for managing and tracking user interactions with book-related content.

The “book” domain will encompass features for storing, retrieving, and managing book-related data (all basic CRUD operations), including attributes such as title, author, publication date, and genre. This domain will serve as the backbone of the application, facilitating CRUD operations on book records.

To monitor user activity, the project will include an activity tracking system that logs and analyzes user interactions with the book domain. This will involve creating RESTful APIs for actions like book views, ratings, reviews, and other user-related activities. These API endpoints will collect and store user activity data, enabling administrators to gain insights into user engagement and behavior.

2 monitor Book (java-EE spring boot) core documentation

2.1 github repo

AlbertProfe/monitorBook

2.2 Project Tree

monitorBook tree

monitorBook tree

2.3 API Rest Postman

2.4 Model

2.4.1 book

    private String id; 
    private String title; 
    private int pages; 
    private String language; 
    private String author; 

book java class

2.4.2 activityLog

    private String id;
    private String ip;
    private String operationMethod;
    private String user;
    private Timestamp time; // Assuming time is represented as a Unix timestamp (long)
    private String status;
    private String endpoint;
    private String domain;
    private String version;

activityLog java class

3 Domains

  • RestController: In a Spring Boot application, the RestController acts as the presentation layer responsible for handling incoming HTTP requests.
    • It receives requests from clients, processes them, and returns responses as RESTful web services. This component typically maps HTTP methods (GET, POST, PUT, DELETE) to specific methods and serves as a bridge between the client and the application’s core logic.
  • Controller: The Controller in Spring Boot serves as the intermediary between the user interface (e.g., a web page) and the application’s backend.
    • It processes user input, triggers corresponding actions, and orchestrates the flow of data. Controllers often contain business logic and route requests to the appropriate services for further processing.
  • Service:The Service layer encapsulates the application’s core business logic and domain-specific operations.
    • It serves as the intermediary between controllers and repositories, handling the application’s high-level functionality. Services are responsible for implementing and managing the business rules and application-specific operations, ensuring separation of concerns within the application.
  • Repository: The Repository layer in Spring Boot is responsible for data access and database interactions. It abstracts the underlying data source (e.g., a database) and provides methods for CRUD operations.
    • It typically uses technologies like JPA, Hibernate, or Spring Data to simplify data access and management, promoting database abstraction and data integrity.
  • Model: The Model represents the data structure of the application, defining the object’s attributes and relationships. It often corresponds to database entities and is used for data storage and retrieval.
    • In Spring Boot, Models are often annotated with JPA or Hibernate annotations to facilitate database mapping and object-relational mapping (ORM).

4 Versions management by iteration

Version What How Much When Project
Version0 sandbox Just a project to play with the new tools and really understand the project’s goal Spring Boot, TH, API rest, postman, wiki, github, idea 27/10/2023 25/10/2023
Version1 book/activity implement book and activity domains with List(Book, Activity) TH and API rest 31/11/2023 26/10/2023 Project structure, POM
CRUD: read, implement log 27/10/2023 monitorBook v1.1 code
CRUD: create, implement log & Utilities domain 30/10/2023 monitorBook v1.2 code
CRUD: delete and update, implement log 31/10/2023 monitorBook v1.3 code / monitorBook v1.31 code
Version2 database, JPA-H2 implement repository and JPA, install H2, create service and queries JPA, H2 just get all books 02/11/2023 monitorBook v2.0 code
JPA, H2 all CRUD 03/11/2023 monitorBook v2.1 code
JPA, H2 all CRUD minor error checked UPDATE 03/11/2023 monitorBook v2.11 code
JPA, H2 all CRUD lombok book 03/11/2023 monitorBook v2.12 code
Version3 author, composition domain author composition, author-book @oneToMany, @manyToOne (without @Controller and @Service ) 06/11/2023 monitorBook v3.0 code -just created, build and structure-
JPA, H2 07/11/2023 monitorBook 3.1 code -temptative-
JPA, H2 author-book @oneToMany JPA unable to find AUTHOR 08/11/2023 monitorBook 3.2
JPA, H2 author-book @oneToMany JPA, authorService 09/11/2023 monitorBook 3.3
JPA, H2 author-book-comment @oneToMany JPA 10/11/2023 monitorBook 3.4 / @ManyToOne decommented