{"id":27883080,"url":"https://github.com/mrnicolass/v2com-library-training-backend","last_synced_at":"2026-04-09T11:03:49.789Z","repository":{"id":275970729,"uuid":"927133445","full_name":"MrNicolass/V2com-Library-Training-backend","owner":"MrNicolass","description":"It's a simple API project of a library concept made to learn some of Quarkus, PostgreSQL and Docker.","archived":false,"fork":false,"pushed_at":"2025-02-25T12:34:34.000Z","size":641,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T06:12:33.649Z","etag":null,"topics":["docker","flyway-migrations","java","openapi","postgresql","quarkus"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrNicolass.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-04T13:12:24.000Z","updated_at":"2025-04-04T14:46:03.000Z","dependencies_parsed_at":"2025-02-25T13:48:48.057Z","dependency_job_id":null,"html_url":"https://github.com/MrNicolass/V2com-Library-Training-backend","commit_stats":null,"previous_names":["mrnicolass/v2com-library-training","mrnicolass/v2com-library-training-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MrNicolass/V2com-Library-Training-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNicolass%2FV2com-Library-Training-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNicolass%2FV2com-Library-Training-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNicolass%2FV2com-Library-Training-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNicolass%2FV2com-Library-Training-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrNicolass","download_url":"https://codeload.github.com/MrNicolass/V2com-Library-Training-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrNicolass%2FV2com-Library-Training-backend/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264343805,"owners_count":23593792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","flyway-migrations","java","openapi","postgresql","quarkus"],"created_at":"2025-05-05T06:11:51.197Z","updated_at":"2025-12-30T22:14:30.086Z","avatar_url":"https://github.com/MrNicolass.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# V2com Library Training\n\nThis project was proposed by \u003ca href=\"https://v2com.com/\"\u003eV2com\u003c/a\u003e to teach college scholarship students how to use Quarkus, Docker, and the MVC pattern. Through this training, it's possible to develop practical skills in building Java Quarkus mainly.\n\n## Project Structure\n\n\u003cdetails\u003e\n\u003csummary\u003eHow it was created?\u003c/summary\u003e\nIt was created using the MVC model, that is a pattern that separates an application's logic into three parts: model, the view and the controller. We can see the base structure below:\n\n```\nV2com-Library-Training-api/\n│── src/\n│   ├── main/\n│   │   ├── java/com/example/V2com-Library-Training/\n│   │   │   ├── entity/\n│   │   │   │   ├── Book.java\n│   │   │   │   ├── User.java\n│   │   │   │   ├── Loan.java\n│   │   │   │   ├── Reservation.java\n│   │   │   │   ├── enums/\n│   │   │   │   │   ├── LoanStatus.java\n│   │   │   │   │   ├── ReservationStatus.java\n│   │   │   │   │   ├── UserRole.java\n│   │   │   ├── repository/\n│   │   │   │   ├── BookRepository.java\n│   │   │   │   ├── UserRepository.java\n│   │   │   │   ├── LoanRepository.java\n│   │   │   │   ├── ReservationRepository.java\n│   │   │   ├── service/\n│   │   │   │   ├── BookService.java\n│   │   │   │   ├── UserService.java\n│   │   │   │   ├── LoanService.java\n│   │   │   │   ├── ReservationService.java\n│   │   │   ├── controller/\n│   │   │   │   ├── BookController.java\n│   │   │   │   ├── UserController.java\n│   │   │   │   ├── LoanController.java\n│   │   │   │   ├── ReservationController.java\n│   │   │   ├── dto/\n│   │   │   │   ├── BookDTO.java\n│   │   │   │   ├── UserDTO.java\n│   │   │   │   ├── LoanDTO.java\n│   │   │   │   ├── ReservationDTO.java\n│   ├── resources/\n│   │   ├── application.properties\n│── pom.xml\n```\n\n\u003c/details\u003e\n\n### Entities Description\n\n\u003e 💡 Below, some entities receive other entities in there structure, like `Loan`, tha receive `User` and `book`. In the database they were recorded as UUID's, but in code/ORM on moust routes is sent a DTO with UUID's and recorded by using entities/objects.\n\nBelow it's possible to find the written and image description:\n\n\u003cdetails\u003e\n\u003csummary\u003eDiagram\u003c/summary\u003e\n\n#### Book\n- **Attributes:**\n    - `id` (UUID): Unique identifier for the book.\n    - `title` (String): Title of the book.\n    - `author` (String): Author of the book.\n    - `isbn` (String): ISBN number of the book.\n    - `publishedDate` (LocalDate): Date when the book was published.\n    - `status` (String): Current status of the book (e.g., available, borrowed).\n\n- **Relationships:**\n    - One-to-Many with `Loan`: A book can have multiple loans.\n    - One-to-Many with `Reservation`: A book can have multiple reservations.\n\n#### User\n- **Attributes:**\n    - `id` (UUID): Unique identifier for the user.\n    - `name` (String): Name of the user.\n    - `email` (String): Email address of the user.\n    - `password` (String): Password for the user's account.\n    - `role` (UserRole): Role of the user (e.g., admin, member).\n\n- **Relationships:**\n    - One-to-Many with `Loan`: A user can have multiple loans.\n    - One-to-Many with `Reservation`: A user can have multiple reservations.\n\n#### Loan\n- **Attributes:**\n    - `id` (UUID): Unique identifier for the loan.\n    - `bookId` (UUID): Identifier of the borrowed book.\n    - `userId` (UUID): Identifier of the user who borrowed the book.\n    - `loanDate` (LocalDate): Date when the loan was made.\n    - `returnDate` (LocalDate): Date when the book is expected to be returned.\n    - `status` (LoanStatus): Current status of the loan (e.g., active, returned).\n\n- **Relationships:**\n    - Many-to-One with `Book`: A loan is associated with one book.\n    - Many-to-One with `User`: A loan is associated with one user.\n\n#### Reservation\n- **Attributes:**\n    - `id` (UUID): Unique identifier for the reservation.\n    - `bookId` (UUID): Identifier of the reserved book.\n    - `userId` (UUID): Identifier of the user who reserved the book.\n    - `reservationDate` (LocalDate): Date when the reservation was made.\n    - `status` (ReservationStatus): Current status of the reservation (e.g., active, fulfilled).\n\n- **Relationships:**\n    - Many-to-One with `Book`: A reservation is associated with one book.\n    - Many-to-One with `User`: A reservation is associated with one user.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eExample image of the Diagram\u003c/summary\u003e\n\n![Project Diagram](diagram.png)\n\n\u003c/details\u003e\n\n## How Routes works\n\n\u003e 💡 You can see all the routes and test how they work by accessing http://localhost:8080/q/swagger-ui/ for a better view!\n\nSee the routes in the dropdown below:\n\u003cdetails\u003e\n\u003csummary\u003eRoutes\u003c/summary\u003e\n\n### Users\nUsers can register, update their information, and delete their accounts. They can also borrow and reserve books.\n\n- **Routes:**\n    - `POST /users` - Register a new user;\n    - `GET /users/{id}` - Get user details by searching by filter;\n    - `GET /users` - Get users by filter on UriInfo (`endpoint?filterName=filterValue`);\n    - `PATCH /users/{id}` - Update user information;\n    - `DELETE /users/{id}` - Delete a user.\n\n### Books\nBooks can be added, updated, and deleted by the library staff. Users can view book details.\n\n- **Routes:**\n    - `POST /books` - Add a new book;\n    - `GET /books/{id}` - Get book details;\n    - `GET /books` - Get books by filter on UriInfo (`endpoint?filterName=filterValue`);\n    - `PATCH /books/{id}` - Update book information;\n    - `DELETE /books/{id}` - Delete a book.\n\n### Loans\nUsers can borrow books, and the system tracks the loan status.\n\n- **Routes:**\n    - `POST /loans` - Create a new loan;\n        - If the book is already borrowed, automatically creates a new reservation;\n    - `GET /loans/{id}` - Get loan details;\n    - `GET /loans` - Get loan by filter on UriInfo (`endpoint?filterName=filterValue`);\n    - `PATCH /loans/{id}` - Update loan information;\n    - `DELETE /loans/{id}` - Delete a loan.\n\n### Reservations\nUsers can reserve books, and the system tracks the reservation status.\n\n- **Routes:**\n    - `POST /reservations` - Create a new reservation;\n        - If there are no Loans for the select book, it's created automatically a new Loan;\n    - `GET /reservations/{id}` - Get reservation details;\n    - `GET /reservations` - Get reservation by filters on UriInfo (`endpoint?filterName=filterValue`);\n    - `PATCH /reservations/{id}` - Update reservation information;\n    - `DELETE /reservations/{id}` - Delete a reservation.\n\n\u003c/details\u003e\n\n## Libraries Used\n\n- [Quarkus](https://quarkus.io/);\n- [JUnit](https://junit.org/junit5/);\n- [RESTEasy](https://resteasy.github.io/);\n- [Hibernate ORM](https://hibernate.org/orm/);\n- [Docker](https://www.docker.com/);\n- [JDBC PostgreSQL](https://jdbc.postgresql.org/);\n- [Flyway](https://flywaydb.org/);\n- [SmallRye OpenAPI](https://smallrye.io/smallrye-open-api/);\n- [SmallRye JWT](https://smallrye.io/smallrye-jwt/);\n- [SmallRye JWT Build](https://smallrye.io/smallrye-jwt-build/).\n\n## `.env` Configuration\n\nCreate a `.env` file in the root of the project with the following variables:\n\n```\nPOSTGRES_DB=library\nPOSTGRES_USER=your_own_db_user\nPOSTGRES_PASSWORD=your_own_db_password\nQUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://localhost:5432/library\nQUARKUS_DATASOURCE_JDBC_URL_DOCKER=jdbc:postgresql://db:5432/library\nQUARKUS_DATASOURCE_USERNAME=your_own_db_user\nQUARKUS_DATASOURCE_PASSWORD=your_own_db_user\n```\n\n## Running the Program\n\nOn both ways to start the program, execute commands in root folder:\n\n### With Docker\n\n1. Create the project .jar:\n    ```sh\n    ./mvnw package -DskipTests\n    ```\n\n2. Build the Docker image:\n    ```sh\n    docker build -f src/main/docker/Dockerfile.jvm -t quarkus/library-jvm .\n    ```\n\n3. Change the tag of container:\n    ```sh\n    docker tag quarkus/library-jvm:latest quarkus/library-jvm:1.0.0-SNAPSHOT\n    ```\n\n4. Remove old container:\n    ```sh\n    docker rmi quarkus/library-jvm:latest\n    ```\n\n5. Run docker compose:\n    ```sh\n    docker-compose up\n    ```\n\n### With Maven/Quarkus from the Terminal\n\n1. Create the project .jar:\n    ```sh\n    ./mvnw package -DskipTests\n    ```\n\n2. Run the project:\n    ```sh\n    ./mvnw quarkus:dev\n    ```\n\nDone! The project will be running at `http://localhost:8080`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrnicolass%2Fv2com-library-training-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrnicolass%2Fv2com-library-training-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrnicolass%2Fv2com-library-training-backend/lists"}