How chiraggupta0/home4paws- works
1. Overall shape
Home4Paws is a two-tier pet adoption platform: a Spring Boot backend at the repo root and a React/Vite frontend in home4paws-frontend/. The backend exposes REST APIs and handles persistence, security, and real-time chat; the frontend is a single-page app that consumes those APIs.
2. Core domain boundaries
The backend is organized around a small domain model: users, pets, adoption requests, chat messages, and subscriptions. Role and status enums (Role, PetStatus, RequestStatus, DogType) define the business states that flow through the system.
3. Backend layered architecture
The Spring code follows a standard controller → service → repository split:
- controller/ contains HTTP entry points such as AuthController, PetController, AdoptionRequestController, ChatController, AdminController, and PaymentController.
- service/ contains business rules and orchestration.
- repository/ contains Spring Data JPA interfaces for database access.
- model/ contains JPA entities mapped to relational tables.
This separation is the main backend boundary for the architecture diagram.
4. Persistence layer
PostgreSQL is the primary data store, accessed through Spring Data JPA / Hibernate. The existing schema centers on:
- users
- pets
- adoption_requests
with additional tables/entities for chat and subscriptions in the codebase. Relationships are mostly foreign-key driven around User and Pet.
5. Security and request filtering
Security is explicitly implemented in config/ with SecurityConfig, JwtFilter, JwtUtil, CorsConfig, and CustomUserDetailsService. This indicates a request pipeline where inbound API calls are authenticated/authorized before reaching controllers, with JWT-based access control and cross-origin rules for the frontend.
6. Real-time chat subsystem
Chat is its own subsystem, not just another CRUD feature. ChatController, ChatService, ChatMessage plus ChatPubSubConfig, ChatSseManager, and RedisConfig show a design that uses SSE for browser delivery and Redis pub/sub for fan-out or coordination between instances. That makes chat a distinct real-time path alongside the normal REST APIs.
7. Adoption workflow
The adoption flow is a business process spanning multiple entities: adopters submit AdoptionRequests for Pets, shelters review them, and request status transitions drive pet availability. This is the main transactional workflow that links the pet catalog to user actions and admin/shelter decisions.
8. Admin and operational features
AdminController, AdminService, and the frontend admin pages suggest a separate operational view for moderation/analytics/oversight. The frontend also includes Charts.jsx, which points to reporting or dashboard metrics as part of that admin surface.
9. Frontend application structure
The React app is routed by pages in src/pages/: Home, Pets, PetDetails, Login, Register, MyDogs, MyRequests, ShelterRequests, AdminDashboard, AdminDetail, Chat, Subscribe, and AuthCallback. Reusable UI is isolated in src/components/ (Navbar, PetCard, ProtectedRoute, Charts, HeroCanvas). This makes the frontend a route-driven SPA with role-based protected views.
10. Frontend integration points
API calls are centralized through src/api/axiosConfig.js, while src/lib/supabaseClient.js and AuthCallback.jsx indicate an external auth integration path in addition to the backend’s JWT/security code. In architectural terms, the browser app is the primary consumer of both the Spring REST API and any auth provider callback flow.
11. Deployment and runtime boundary
The repo is containerized with Dockerfiles for backend/frontend, a top-level docker-compose.yml, and an nginx/ config. That suggests production deployment through a reverse proxy that serves the frontend and forwards API traffic to the backend. The init-letsencrypt.sh script and GitHub Actions workflow (.github/workflows/deploy.yml) show that TLS and deployment automation are part of the runtime story.
12. Configuration and environment separation
Backend config lives in src/main/resources/application.properties; the frontend uses .env. This separation matters because the system spans multiple runtimes and needs distinct environment-specific settings for database access, API base URLs, auth, and deployment targets.
13. Repo signal for evolution
The repository contains both a minimal README-described backend and a much larger implemented codebase, so the diagram should reflect the current system state: a feature-complete platform foundation with authentication, pets, adoption requests, chat, admin, payment, and deployment scaffolding—not just the initial /api/hello demo.
14. Practical diagram boundaries
A good architecture diagram for this repo should show: browser → nginx → React SPA → Spring Boot API → PostgreSQL, with a side channel for chat via SSE/Redis, and external nodes for auth/payment/deployment tooling where relevant.
Main entry points: controller Controllers · main.jsx React App · app.conf Nginx · service Services
Components 19
Frontend
React/Vite single-page app and UI routes
- Browser · End-user web client
- React App · Vite frontend entry and route-driven UI
home4paws-frontend/src/main.jsx - Pages · Main screens for pets, auth, admin, chat, and requests
home4paws-frontend/src/pages - UI Components · Reusable interface pieces and route guards
home4paws-frontend/src/components - API Client · Centralized backend request configuration
home4paws-frontend/src/api/axiosConfig.js - Auth Callback · External login callback path for browser auth
home4paws-frontend/src/pages/AuthCallback.jsx
Backend
Spring Boot API, domain logic, persistence, and security
- Spring Boot · Backend application entrypoint
src/main/java/com/home4paws/home4paws/Home4pawsApplication.java - Security · JWT authentication, CORS, and user details integration
src/main/java/com/home4paws/home4paws/config/SecurityConfig.java - Controllers · HTTP entrypoints for auth, pets, requests, chat, admin, and payments
src/main/java/com/home4paws/home4paws/controller - Services · Orchestrates adoption, auth, admin, chat, pets, and subscriptions
src/main/java/com/home4paws/home4paws/service - Domain Model · Users, pets, requests, chat messages, and subscriptions
src/main/java/com/home4paws/home4paws/model - Repositories · Spring Data JPA repositories
src/main/java/com/home4paws/home4paws/repository - Chat Realtime · SSE delivery plus Redis pub/sub coordination
src/main/java/com/home4paws/home4paws/config/ChatSseManager.java - Payment · Subscription or billing-related API surface
src/main/java/com/home4paws/home4paws/controller/PaymentController.java - Admin Ops · Administrative review and dashboard operations
src/main/java/com/home4paws/home4paws/controller/AdminController.java
Runtime
Nginx, Docker, deployment, and environment boundaries
- Nginx · Serves the SPA and routes API traffic
nginx/conf.d/app.conf - PostgreSQL · Primary persistent store
- Deploy · Container and release automation
.github/workflows/deploy.yml - Env Config · Backend properties and frontend environment variables
src/main/resources/application.properties
Connections 21
- Browser → Nginx: HTTP · User traffic enters the deployment edge
- Nginx → React App: serves · Delivers the frontend application assets
- Browser → React App: loads · The SPA runs in the browser
- React App → API Client: calls · Frontend uses centralized API configuration
- React App → Auth Callback: auth flow · Browser auth redirects return here
- API Client → Nginx: API traffic · Frontend requests pass through the reverse proxy
- Nginx → Controllers: forwards · Reverse proxy routes backend API requests
- Controllers → Services: delegates · Controllers hand off business work
- Services → Repositories: queries · Services persist and load domain state
- Repositories → PostgreSQL: reads/writes · JPA-backed access to PostgreSQL
- Services → Domain Model: uses · Domain entities define business state
- Security → Controllers: guards · JWT and CORS filter inbound requests
- Services → Chat Realtime: publishes · Chat service fans out messages via SSE/Redis
- Chat Realtime → Browser: stream updates · Chat messages are delivered live to clients
- Controllers → Admin Ops: admin api · Administrative endpoints expose oversight actions
- Controllers → Payment: billing api · Payment-related operations are exposed here
- Controllers → Env Config: configures · Runtime settings shape API behavior
- React App → Env Config: reads env · Frontend uses environment-based API and auth settings
- Deploy → Nginx: ships · Deployment pipeline builds and publishes runtime assets
- Deploy → Spring Boot: deploys · Backend container/runtime is released through automation
- Spring Boot → Security: starts · Application boot wires security and request handling