A secure, RESTful API for a pet adoption platform, built with Java and the Spring ecosystem. This project demonstrates a clean, layered architecture and robust security implementation for managing pet listings, user authentication, and adoption workflows from end-to-end.
- Stateless JWT Authentication: Secure user registration and login using Spring Security and JSON Web Tokens.
- Role-Based Access Control (RBAC): Distinct permissions for regular users (Adopters) and Admins.
- Users/Adopters: Can view available pets and submit/view their own adoption requests.
- Admins: Can perform full CRUD operations on pet listings and approve/reject any adoption request.
- Complete Adoption Workflow: Manages the lifecycle of adoption requests from
PENDINGtoAPPROVEDorREJECTED. - Professional Architecture: Follows a professional Controller-Service-Repository pattern to ensure separation of concerns, high maintainability, and testability.
- Backend: Java 17, Spring Boot 3
- Security: Spring Security, JWT
- Database: Spring Data JPA / Hibernate, H2 (In-Memory for development), easily configurable for MySQL/PostgreSQL
- Build Tool: Maven
- API Testing: VS Code REST Client (
api-tests.http)
The API is currently deployed and live on Render. All endpoints can be accessed at the following base URL:
https://pawpal-api.onrender.com
The API is fully testable using the api-tests.http file in this repository with the VS Code REST Client extension.
| Method | Endpoint | Description |
|---|---|---|
POST |
/signup |
Register a new user account. |
POST |
/login |
Log in to get a JWT. |
| Method | Endpoint | Description |
|---|---|---|
GET |
/pets |
Get a list of all available pets. |
GET |
/search/{name} |
Search for available pets by name. |
POST |
/request-adoption |
Submit an adoption request for a pet. |
GET |
/my-requests/{userId} |
View all requests made by the user. |
| Method | Endpoint | Description |
|---|---|---|
POST |
/pet |
Add a new pet (requires form-data). |
GET |
/pets |
Get a list of all pets (any status). |
GET |
/pet/{petId} |
Get a single pet by its ID. |
PUT |
/pet/{petId} |
Update a pet's details. |
DELETE |
/pet/{petId} |
Delete a pet listing. |
GET |
/adoption-requests |
Get all adoption requests in the system. |
GET |
/adoption-request/{reqId}/{status} |
Approve or reject an adoption request. |
- Clone the repository:
git clone https://github.com/tanvikreddy123/pawpal-api.git - Navigate into the project directory:
cd pawpal-api - Run the application using Maven:
mvn spring-boot:run - The server will start on
http://localhost:8081.
Your API uses JWT for authentication. To access protected routes, you must first log in to receive a token.
Example Authentication Flow (using Postman or cURL):
- Sign Up:
POST https://pawpal-api.onrender.com/api/auth/signupBody: { "email": "[email protected]", "password": "password123", "name": "Test User" }
- Login:
POST https://pawpal-api.onrender.com/api/auth/loginBody: { "username": "[email protected]", "password": "password123" }- The response will contain a
jwtToken.
- Access Protected Route:
GET https://pawpal-api.onrender.com/api/user/pets- Header:
Authorization: Bearer <your_jwt_token_here>
- Header:
For any questions or feedback, feel free to reach out to the author:
- Author: Tanvik Reddy Kotha
- Email: [email protected]