# chiraggupta0/home4paws- architecture

> Architecture diagram of the GitHub repository chiraggupta0/home4paws-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chiraggupta0/home4paws-
- Repository: https://github.com/chiraggupta0/home4paws-

## Overview

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 `AdoptionRequest`s for `Pet`s, 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: [`src/main/java/com/home4paws/home4paws/controller`](https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/controller) (Controllers), [`home4paws-frontend/src/main.jsx`](https://github.com/chiraggupta0/home4paws-/blob/main/home4paws-frontend/src/main.jsx) (React App), [`nginx/conf.d/app.conf`](https://github.com/chiraggupta0/home4paws-/blob/main/nginx/conf.d/app.conf) (Nginx), [`src/main/java/com/home4paws/home4paws/service`](https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/service) (Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_browser(("Browser<br/>client"))
  node_spa["React App<br/>SPA<br/>[main.jsx]"]
  node_pages["Pages<br/>routes"]
  node_components["UI Components<br/>shared UI"]
  node_api_client["API Client<br/>axios<br/>[axiosConfig.js]"]
  node_auth_callback["Auth Callback<br/>auth bridge<br/>[AuthCallback.jsx]"]
end

subgraph group_backend["Backend"]
  node_app_boot["Spring Boot<br/>API host"]
  node_security["Security<br/>jwt filter chain"]
  node_controllers["Controllers<br/>REST layer"]
  node_services["Services<br/>business layer"]
  node_models[("Domain Model<br/>JPA entities")]
  node_repositories["Repositories<br/>data access"]
  node_chat_realtime{{"Chat Realtime<br/>SSE/Redis"}}
  node_payment["Payment"]
  node_admin["Admin Ops<br/>oversight"]
end

subgraph group_runtime["Runtime"]
  node_nginx["Nginx<br/>reverse proxy<br/>[app.conf]"]
  node_db[("PostgreSQL<br/>relational DB")]
  node_deploy["Deploy<br/>ci/cd<br/>[deploy.yml]"]
  node_config["Env Config<br/>settings"]
end

node_browser -->|"HTTP"| node_nginx
node_nginx -->|"serves"| node_spa
node_browser -->|"loads"| node_spa
node_spa -->|"calls"| node_api_client
node_spa -->|"auth flow"| node_auth_callback
node_api_client -->|"API traffic"| node_nginx
node_nginx -->|"forwards"| node_controllers
node_controllers -->|"delegates"| node_services
node_services -->|"queries"| node_repositories
node_repositories -->|"reads/writes"| node_db
node_services -->|"uses"| node_models
node_security -->|"guards"| node_controllers
node_services -->|"publishes"| node_chat_realtime
node_chat_realtime -->|"stream updates"| node_browser
node_controllers -->|"admin api"| node_admin
node_controllers -->|"billing api"| node_payment
node_controllers -->|"configures"| node_config
node_spa -->|"reads env"| node_config
node_deploy -->|"ships"| node_nginx
node_deploy -->|"deploys"| node_app_boot
node_app_boot -->|"starts"| node_security

click node_nginx "https://github.com/chiraggupta0/home4paws-/blob/main/nginx/conf.d/app.conf"
click node_spa "https://github.com/chiraggupta0/home4paws-/blob/main/home4paws-frontend/src/main.jsx"
click node_pages "https://github.com/chiraggupta0/home4paws-/tree/main/home4paws-frontend/src/pages"
click node_components "https://github.com/chiraggupta0/home4paws-/tree/main/home4paws-frontend/src/components"
click node_api_client "https://github.com/chiraggupta0/home4paws-/blob/main/home4paws-frontend/src/api/axiosConfig.js"
click node_auth_callback "https://github.com/chiraggupta0/home4paws-/blob/main/home4paws-frontend/src/pages/AuthCallback.jsx"
click node_app_boot "https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/Home4pawsApplication.java"
click node_security "https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/config/SecurityConfig.java"
click node_controllers "https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/controller"
click node_services "https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/service"
click node_models "https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/model"
click node_repositories "https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/repository"
click node_chat_realtime "https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/config/ChatSseManager.java"
click node_payment "https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/controller/PaymentController.java"
click node_admin "https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/controller/AdminController.java"
click node_deploy "https://github.com/chiraggupta0/home4paws-/blob/main/.github/workflows/deploy.yml"
click node_config "https://github.com/chiraggupta0/home4paws-/blob/main/src/main/resources/application.properties"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_spa,node_pages,node_components,node_api_client,node_auth_callback toneBlue
class node_app_boot,node_security,node_controllers,node_services,node_models,node_repositories,node_chat_realtime,node_payment,node_admin toneAmber
class node_nginx,node_db,node_deploy,node_config toneMint
```

## Components

### Frontend

React/Vite single-page app and UI routes

- **Browser**: client · End-user web client
- [React App](https://github.com/chiraggupta0/home4paws-/blob/main/home4paws-frontend/src/main.jsx): SPA · Vite frontend entry and route-driven UI · `home4paws-frontend/src/main.jsx`
- [Pages](https://github.com/chiraggupta0/home4paws-/tree/main/home4paws-frontend/src/pages): routes · Main screens for pets, auth, admin, chat, and requests · `home4paws-frontend/src/pages`
- [UI Components](https://github.com/chiraggupta0/home4paws-/tree/main/home4paws-frontend/src/components): shared UI · Reusable interface pieces and route guards · `home4paws-frontend/src/components`
- [API Client](https://github.com/chiraggupta0/home4paws-/blob/main/home4paws-frontend/src/api/axiosConfig.js): axios · Centralized backend request configuration · `home4paws-frontend/src/api/axiosConfig.js`
- [Auth Callback](https://github.com/chiraggupta0/home4paws-/blob/main/home4paws-frontend/src/pages/AuthCallback.jsx): auth bridge · External login callback path for browser auth · `home4paws-frontend/src/pages/AuthCallback.jsx`

### Backend

Spring Boot API, domain logic, persistence, and security

- [Spring Boot](https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/Home4pawsApplication.java): API host · Backend application entrypoint · `src/main/java/com/home4paws/home4paws/Home4pawsApplication.java`
- [Security](https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/config/SecurityConfig.java): jwt filter chain · JWT authentication, CORS, and user details integration · `src/main/java/com/home4paws/home4paws/config/SecurityConfig.java`
- [Controllers](https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/controller): REST layer · HTTP entrypoints for auth, pets, requests, chat, admin, and payments · `src/main/java/com/home4paws/home4paws/controller`
- [Services](https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/service): business layer · Orchestrates adoption, auth, admin, chat, pets, and subscriptions · `src/main/java/com/home4paws/home4paws/service`
- [Domain Model](https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/model): JPA entities · Users, pets, requests, chat messages, and subscriptions · `src/main/java/com/home4paws/home4paws/model`
- [Repositories](https://github.com/chiraggupta0/home4paws-/tree/main/src/main/java/com/home4paws/home4paws/repository): data access · Spring Data JPA repositories · `src/main/java/com/home4paws/home4paws/repository`
- [Chat Realtime](https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/config/ChatSseManager.java): SSE/Redis · SSE delivery plus Redis pub/sub coordination · `src/main/java/com/home4paws/home4paws/config/ChatSseManager.java`
- [Payment](https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/controller/PaymentController.java): payment flow · Subscription or billing-related API surface · `src/main/java/com/home4paws/home4paws/controller/PaymentController.java`
- [Admin Ops](https://github.com/chiraggupta0/home4paws-/blob/main/src/main/java/com/home4paws/home4paws/controller/AdminController.java): oversight · Administrative review and dashboard operations · `src/main/java/com/home4paws/home4paws/controller/AdminController.java`

### Runtime

Nginx, Docker, deployment, and environment boundaries

- [Nginx](https://github.com/chiraggupta0/home4paws-/blob/main/nginx/conf.d/app.conf): reverse proxy · Serves the SPA and routes API traffic · `nginx/conf.d/app.conf`
- **PostgreSQL**: relational DB · Primary persistent store
- [Deploy](https://github.com/chiraggupta0/home4paws-/blob/main/.github/workflows/deploy.yml): ci/cd · Container and release automation · `.github/workflows/deploy.yml`
- [Env Config](https://github.com/chiraggupta0/home4paws-/blob/main/src/main/resources/application.properties): settings · Backend properties and frontend environment variables · `src/main/resources/application.properties`

## Connections

- 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
