| 1 | # Petify Backend
|
|---|
| 2 |
|
|---|
| 3 | Petify Backend is a Spring Boot–based REST API that powers the Petify platform — a pet care and service marketplace connecting pet owners, caregivers, and administrators.
|
|---|
| 4 | The backend is responsible for authentication, business logic, data persistence, and API exposure for the frontend and external services.
|
|---|
| 5 |
|
|---|
| 6 | ---
|
|---|
| 7 |
|
|---|
| 8 | ## Overview
|
|---|
| 9 |
|
|---|
| 10 | The backend provides:
|
|---|
| 11 |
|
|---|
| 12 | - Secure user authentication and authorization
|
|---|
| 13 | - Role-based access control (Admin, Client, Owner)
|
|---|
| 14 | - Management of pets, listings, reviews, and bookings
|
|---|
| 15 | - Vet clinic onboarding and approval workflows
|
|---|
| 16 | - Centralized business rules and validations
|
|---|
| 17 | - RESTful APIs for frontend consumption
|
|---|
| 18 |
|
|---|
| 19 | The system is designed with scalability, clarity, and real-world domain modeling in mind.
|
|---|
| 20 |
|
|---|
| 21 | ---
|
|---|
| 22 |
|
|---|
| 23 | ## Tech Stack
|
|---|
| 24 |
|
|---|
| 25 | - **Java 17**
|
|---|
| 26 | - **Spring Boot**
|
|---|
| 27 | - **Spring Security**
|
|---|
| 28 | - **Spring Data JPA (Hibernate)**
|
|---|
| 29 | - **PostgreSQL**
|
|---|
| 30 | - **Maven**
|
|---|
| 31 | - **JWT-based authentication**
|
|---|
| 32 | - **Docker-ready architecture**
|
|---|
| 33 |
|
|---|
| 34 | ---
|
|---|
| 35 |
|
|---|
| 36 | ## Architecture
|
|---|
| 37 |
|
|---|
| 38 | The project follows a layered architecture:
|
|---|
| 39 |
|
|---|
| 40 | - **API Layer**
|
|---|
| 41 | REST controllers exposing endpoints and handling HTTP requests/responses
|
|---|
| 42 |
|
|---|
| 43 | - **Service Layer**
|
|---|
| 44 | Business logic, validations, and transactional operations
|
|---|
| 45 |
|
|---|
| 46 | - **Persistence Layer**
|
|---|
| 47 | JPA entities and repositories mapped to PostgreSQL
|
|---|
| 48 |
|
|---|
| 49 | - **Security Layer**
|
|---|
| 50 | Authentication, authorization, JWT handling, and request filtering
|
|---|
| 51 |
|
|---|
| 52 | - **Domain Model**
|
|---|
| 53 | Clear separation of Users, Roles, Pets, Listings, Reviews, and Clinics
|
|---|
| 54 |
|
|---|
| 55 | ---
|
|---|
| 56 |
|
|---|
| 57 | ## Core Features
|
|---|
| 58 |
|
|---|
| 59 | ### Authentication & Authorization
|
|---|
| 60 | - Username/password authentication
|
|---|
| 61 | - JWT token issuance and validation
|
|---|
| 62 | - Role-based endpoint protection
|
|---|
| 63 |
|
|---|
| 64 | ### Users & Roles
|
|---|
| 65 | - Unified `User` model with role specialization
|
|---|
| 66 | - Support for Admins and Clients
|
|---|
| 67 | - Account status handling (active, blocked)
|
|---|
| 68 |
|
|---|
| 69 | ### Pets & Owners
|
|---|
| 70 | - Clients can add pets and become owners
|
|---|
| 71 | - Pet profiles with documents and metadata
|
|---|
| 72 | - Owner–pet relationships enforced at database level
|
|---|
| 73 |
|
|---|
| 74 | ### Listings
|
|---|
| 75 | - Pet-related service listings
|
|---|
| 76 | - Pricing, location, and availability tracking
|
|---|
| 77 | - Public and private listing visibility
|
|---|
| 78 |
|
|---|
| 79 | ### Reviews
|
|---|
| 80 | - Authenticated user reviews
|
|---|
| 81 | - One-to-many user-to-review relationship
|
|---|
| 82 | - Review authorship enforcement
|
|---|
| 83 |
|
|---|
| 84 | ### Vet Clinics
|
|---|
| 85 | - Vet clinic application workflow
|
|---|
| 86 | - Admin approval or rejection process
|
|---|
| 87 | - Separation between application and active clinic records
|
|---|
| 88 |
|
|---|
| 89 | ---
|
|---|
| 90 |
|
|---|
| 91 | ## Data Persistence
|
|---|
| 92 |
|
|---|
| 93 | - PostgreSQL as the primary datastore
|
|---|
| 94 | - Strong referential integrity using foreign keys
|
|---|
| 95 | - Lazy and eager loading configured per use case
|
|---|
| 96 | - Transactional service methods for consistency
|
|---|
| 97 |
|
|---|
| 98 | ---
|
|---|
| 99 |
|
|---|
| 100 | ## Security
|
|---|
| 101 |
|
|---|
| 102 | - Stateless authentication using JWT
|
|---|
| 103 | - Password hashing with BCrypt
|
|---|
| 104 | - Protected endpoints based on roles
|
|---|
| 105 | - CORS configuration for frontend integration
|
|---|
| 106 |
|
|---|
| 107 | ---
|
|---|
| 108 |
|
|---|
| 109 | ## Configuration
|
|---|
| 110 |
|
|---|
| 111 | The application is configured via environment variables and Spring profiles.
|
|---|
| 112 | Sensitive data such as database credentials and secrets are externalized and not committed to version control.
|
|---|
| 113 |
|
|---|
| 114 | ---
|
|---|
| 115 |
|
|---|
| 116 | ## Running the Application
|
|---|
| 117 |
|
|---|
| 118 | The backend is designed to run:
|
|---|
| 119 |
|
|---|
| 120 | - Locally (for development and testing)
|
|---|
| 121 | - In Docker containers
|
|---|
| 122 | - As part of a multi-service deployment with frontend and database
|
|---|
| 123 |
|
|---|
| 124 | Spring profiles allow flexible environment switching.
|
|---|
| 125 |
|
|---|
| 126 | ---
|
|---|
| 127 |
|
|---|
| 128 | ## API Design
|
|---|
| 129 |
|
|---|
| 130 | - RESTful endpoints
|
|---|
| 131 | - JSON request/response payloads
|
|---|
| 132 | - Clear separation of public and protected routes
|
|---|
| 133 | - Predictable HTTP status codes
|
|---|
| 134 |
|
|---|
| 135 | ---
|
|---|
| 136 |
|
|---|
| 137 | ## Project Goals
|
|---|
| 138 |
|
|---|
| 139 | - Real-world domain modeling for academic and production use
|
|---|
| 140 | - Clean, maintainable backend structure
|
|---|
| 141 | - Ready for extension with AI-driven services
|
|---|
| 142 | - Suitable for cloud deployment and CI/CD pipelines
|
|---|
| 143 |
|
|---|
| 144 | ---
|
|---|
| 145 |
|
|---|
| 146 | ## License
|
|---|
| 147 |
|
|---|
| 148 | This project is developed for educational and research purposes.
|
|---|
| 149 | All rights reserved.
|
|---|