Skip to content

sanchezcodes/java-pet-registry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Pet Registry System

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.

Technology Stack

  • 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

Getting Started

Prerequisites

  • Java 17 or higher
  • Maven

Running the Application

  1. Clone the repository
  2. Navigate to the project directory
  3. Run the application using Maven:
mvn spring-boot:run

The application will start on port 8080 by default.

API Documentation

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.

API Endpoints

Pet 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

Owner Endpoints

  • 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

Database

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

Sample Data

The application is pre-loaded with sample data for testing purposes. This includes:

  • 3 owners
  • 7 pets (5 with owners, 2 available for adoption)

Production Deployment

For production deployment, you should:

  1. Configure a persistent database (MySQL, PostgreSQL) in application.properties
  2. Uncomment the appropriate database driver dependency in pom.xml
  3. Set the Spring profile to "prod" to disable sample data loading

About

java-pet-registry

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages