{"id":19162264,"url":"https://github.com/andre-carbajal/libraryapi","last_synced_at":"2026-04-19T14:34:53.130Z","repository":{"id":239465322,"uuid":"799391224","full_name":"andre-carbajal/LibraryApi","owner":"andre-carbajal","description":"LibraryApi is a Java-based web application that provides a REST ful API for managing a library system. It is built with Spring Boot and uses MySQL for data persistence.","archived":false,"fork":false,"pushed_at":"2024-05-24T19:27:43.000Z","size":127,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T22:29:16.707Z","etag":null,"topics":["flyway","flyway-migrations","flyway-spring","flywaydb","java-21","lombok","lombok-maven","mysql","rest","rest-api","restful","spring-boot","spring-data-jpa","spring-security","springboot","sql"],"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/andre-carbajal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-05-12T02:00:59.000Z","updated_at":"2024-05-24T19:27:47.000Z","dependencies_parsed_at":"2024-11-09T09:19:40.463Z","dependency_job_id":null,"html_url":"https://github.com/andre-carbajal/LibraryApi","commit_stats":null,"previous_names":["andre-carbajal/libraryapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andre-carbajal/LibraryApi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andre-carbajal%2FLibraryApi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andre-carbajal%2FLibraryApi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andre-carbajal%2FLibraryApi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andre-carbajal%2FLibraryApi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andre-carbajal","download_url":"https://codeload.github.com/andre-carbajal/LibraryApi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andre-carbajal%2FLibraryApi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018707,"owners_count":26086609,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["flyway","flyway-migrations","flyway-spring","flywaydb","java-21","lombok","lombok-maven","mysql","rest","rest-api","restful","spring-boot","spring-data-jpa","spring-security","springboot","sql"],"created_at":"2024-11-09T09:09:34.894Z","updated_at":"2025-10-14T13:35:51.841Z","avatar_url":"https://github.com/andre-carbajal.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LibraryApi\n\n## Description\nLibraryApi is a Java-based web application that provides a REST fulL API for managing a library system. It is built with Spring Boot and uses MySQL for data persistence.\n\n\u003cdetails\u003e\n\u003csummary\u003eIndex\u003c/summary\u003e\n\n- [Technologies](#technologies)\n- [Spring Security](#spring-security)\n   - [Roles](#roles)\n- [Setup](#setup)\n- [Docker Execution](#docker-execution)\n   - [Prerequisites](#prerequisites)\n   - [Steps](#steps)\n- [API Documentation](#api-documentation)\n- [License](#license)\n\n\u003c/details\u003e\n\n## Technologies\n- Java 21\n- Spring Boot 3.2.5\n- MySQL\n- Maven\n- Flyway for database migrations\n- Spring Security for authentication and authorization\n\n## Spring Security\nIn this project, Spring Security is used to handle user authentication and authorization. It has been configured to authenticate users through a custom user details service that loads user details by their username. User roles are used to authorize requests to different API endpoints.\n\n### Roles\nRoles in Spring Security are used to authorize users to access different parts of the application(POST, PUT, DELETE). In this project, two roles are used: `ROLE_USER` and `ROLE_ADMIN`. These roles must be added to the database with the prefix `ROLE_` for Spring Security to recognize them.\n\n## Setup\nTo run this project, you need to have Java and Maven installed on your machine.\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/andre-carbajal/LibraryApi.git\n   ```\n\n2. Navigate to the project directory:\n   ```bash\n   cd LibraryApi\n   ```\n\n3. Create a MySQL database:\n   ```sql\n   CREATE DATABASE libraryApi;\n   ```\n\n4. Download the dependencies:\n   ```bash\n   mvn dependency:resolve\n   ```\n\n5. Build the project:\n   ```bash\n   mvn clean install\n   ```\n6. Run the Flyway migrations to set up the database schema:\n   ```bash\n   mvn flyway:migrate\n   ```\n\n7. Run the project:\n   ```bash\n   mvn spring-boot:run\n   ```\n\n## Docker Execution\n\nThis application can be run using Docker and Docker Compose. Docker allows you to create a container for your application, ensuring it has all the dependencies it needs to run, and Docker Compose allows you to manage applications that require multiple containers, like this one which requires a separate container for the MySQL database.\n\n### Prerequisites\n\nEnsure you have Docker and Docker Compose installed on your machine. If not, you can download them from the official Docker website.\n\n### Steps\n\n1. **Build the Docker images:**\n\n   Docker can build images automatically by reading the instructions from a Dockerfile. In the root directory of the project, you can find a `Dockerfile` which contains instructions on how to build the image for the application.\n\n   Run the following command in the terminal to build the Docker image:\n\n    ```bash\n    docker build -t library-api .\n    ```\n\n   This command tells Docker to build an image using the Dockerfile in the current directory and tag the image as `library-api`.\n\n2. **Run the Docker container:**\n\n   After building the Docker image, you can run the Docker container with the following command:\n\n    ```bash\n    docker run -e 'DB_HOST=\u003cyour_database_host\u003e' -e 'DB_PORT=\u003cyour_database_port\u003e' -e 'DB_USERNAME=\u003cyour_database_username\u003e' -e 'DB_PASSWORD=\u003cyour_database_password\u003e' -p 8080:8080 library-api\n    ```\n\n   Replace `\u003cyour_database_host\u003e`, `\u003cyour_database_port\u003e`, `\u003cyour_database_username\u003e`, and `\u003cyour_database_password\u003e` with your actual database credentials. If you are using a local database, you can use `host.docker.internal` as the `DB_HOST`.\n\n   This command tells Docker to run the `library-api` image as a container, with the specified environment variables and port mapping. The application will be accessible at `http://localhost:8080`.\n\n3. **Run the Docker Compose:**\n\n   Docker Compose uses a file named `docker-compose.yml` for defining and running multi-container Docker applications.\n\n   Run the following command in the terminal to start the application and the database using Docker Compose:\n\n    ```bash\n    docker compose up\n    ```\n\n   This command tells Docker Compose to start the services defined in the `docker-compose.yml` file.\n\n   The application will be accessible at `http://localhost:8080`.\n\n4. **Stop the Docker Compose:**\n\n   You can stop the services started by Docker Compose by running the following command in the terminal:\n\n    ```bash\n    docker compose down\n    ```\n\n   This command tells Docker Compose to stop the services defined in the `docker-compose.yml` file.\n\n## API Documentation\nThe API documentation is generated using `Springdoc OpenAPI`. This allows for interactive exploration of the API via a web interface. The documentation is available at http://localhost:8080/doc after starting the application.\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandre-carbajal%2Flibraryapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandre-carbajal%2Flibraryapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandre-carbajal%2Flibraryapi/lists"}