A REST API-based pet registry system for animal shelters and adoption agencies. The system manages information about pets available for adoption and their owners, allowing shelters to track pets throughout the adoption process.
- Backend: Java with Spring Boot framework
- Data Persistence: JPA (Java Persistence API) with Hibernate
- Database: H2 (in-memory for development)
- API Style: RESTful API with JSON data format
- Build Tool: Maven
- Documentation: OpenAPI/Swagger
- Java 17 or higher
- Maven
- Clone the repository
- Navigate to the project directory
- Run the application using Maven:
mvn spring-boot:runThe application will start on port 8080 by default.
Once the application is running, you can access the Swagger UI at:
http://localhost:8080/swagger-ui.html
This provides an interactive interface for exploring and testing all available API endpoints.
- GET /pets: Get all pets
- GET /pets/{id}: Get pet by ID
- POST /pets: Create a new pet
- PUT /pets/{id}: Update an existing pet
- DELETE /pets/{id}: Delete a pet
- GET /pets/breed/{breed}: Get pets by breed
- GET /pets/youngest: Get 20 youngest pets
- GET /pets/page?page={pageNumber}&size=5: Get paginated list of pets
- GET /pets/{petId}/owner: Get pet's owner
- PUT /pets/{petId}/owner/{ownerId}: Assign owner to pet
- GET /owners: Get all owners
- GET /owners/{id}: Get owner by ID
- POST /owners: Create a new owner
- PUT /owners/{id}: Update an existing owner
- DELETE /owners/{id}: Delete an owner
- GET /owners/{ownerId}/pets: Get all pets belonging to an owner
The application uses an H2 in-memory database for development. You can access the H2 console at:
http://localhost:8080/h2-console
Connection details:
- JDBC URL:
jdbc:h2:mem:petregistrydb - Username:
sa - Password:
password
The application is pre-loaded with sample data for testing purposes. This includes:
- 3 owners
- 7 pets (5 with owners, 2 available for adoption)
For production deployment, you should:
- Configure a persistent database (MySQL, PostgreSQL) in
application.properties - Uncomment the appropriate database driver dependency in
pom.xml - Set the Spring profile to "prod" to disable sample data loading