# hirashakeel00/purr-fect-homes architecture

> Architecture diagram of the GitHub repository hirashakeel00/purr-fect-homes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hirashakeel00/purr-fect-homes
- Repository: https://github.com/hirashakeel00/purr-fect-homes

## Overview

This repository is the backend for a pet-adoption service. The main workflow is that a user registers or logs in, lists a pet, and an authenticated user can submit adopter details to mark that pet adopted; public routes expose available pets and adoption records. Admin statistics are a separate capability. The route and model excerpts support these connections, but the client is not represented in the supplied tree, and the database is configured through an environment variable.

Main entry points: [`backend/server.js`](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/server.js) (Express server), [`backend/routes/admin.js`](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/admin.js) (Admin stats), [`backend/routes/adoptions.js`](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/adoptions.js) (Adoption routes), [`backend/middleware/auth.js`](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/middleware/auth.js) (Auth middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Express server<br/>[server.js]"]
  node_admin_routes["Admin stats<br/>[admin.js]"]
end

subgraph group_identity["Identity"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_auth_middleware["Auth middleware<br/>[auth.js]"]
end

subgraph group_petflow["Pet Adoption"]
  node_pet_routes["Pet routes<br/>[pets.js]"]
  node_adoption_routes["Adoption routes<br/>[adoptions.js]"]
end

subgraph group_data["Persistence"]
  node_user_model["User model<br/>[User.js]"]
  node_pet_model["Pet model<br/>[pet.js]"]
  node_adopter_model["Adopter model<br/>[Adopter.js]"]
end

node_client(("API client"))
node_mongodb[("MongoDB")]

node_client -->|"sends HTTP requests"| node_server
node_server -->|"returns responses"| node_client
node_server -->|"mounts /api/auth"| node_auth_routes
node_server -->|"mounts /api/pets"| node_pet_routes
node_server -->|"mounts /api/adoptions"| node_adoption_routes
node_server -->|"mounts /api/admin"| node_admin_routes
node_auth_routes -->|"finds and saves"| node_user_model
node_pet_routes -->|"invokes protection"| node_auth_middleware
node_adoption_routes -->|"invokes protection"| node_auth_middleware
node_admin_routes -->|"invokes protection"| node_auth_middleware
node_auth_middleware -->|"loads user"| node_user_model
node_pet_routes -->|"queries and saves"| node_pet_model
node_adoption_routes -->|"finds and updates"| node_pet_model
node_adoption_routes -->|"creates and queries"| node_adopter_model
node_admin_routes -->|"counts pets"| node_pet_model
node_admin_routes -->|"counts adopters"| node_adopter_model
node_user_model -->|"persists user data"| node_mongodb
node_pet_model -->|"persists pet data"| node_mongodb
node_adopter_model -->|"persists adopter data"| node_mongodb

click node_server "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/server.js"
click node_auth_routes "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/auth.js"
click node_auth_middleware "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/middleware/auth.js"
click node_pet_routes "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/pets.js"
click node_adoption_routes "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/adoptions.js"
click node_admin_routes "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/admin.js"
click node_user_model "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/models/User.js"
click node_pet_model "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/models/pet.js"
click node_adopter_model "https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/models/Adopter.js"

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_server,node_admin_routes,node_client toneBlue
class node_auth_routes,node_auth_middleware,node_mongodb toneAmber
class node_pet_routes,node_adoption_routes toneMint
class node_user_model,node_pet_model,node_adopter_model toneRose
```

## Components

### HTTP API

- [Express server](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/server.js): `backend/server.js`
- [Admin stats](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/admin.js): `backend/routes/admin.js`

### Identity

- [Auth routes](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Auth middleware](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`

### Pet Adoption

- [Pet routes](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/pets.js): `backend/routes/pets.js`
- [Adoption routes](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/routes/adoptions.js): `backend/routes/adoptions.js`

### Persistence

- [User model](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/models/User.js): `backend/models/User.js`
- [Pet model](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/models/pet.js): `backend/models/pet.js`
- [Adopter model](https://github.com/hirashakeel00/purr-fect-homes/blob/main/backend/models/Adopter.js): `backend/models/Adopter.js`

### Other components

- **API client**
- **MongoDB**

## Connections

- API client → Express server: sends HTTP requests
- Express server → API client: returns responses
- Express server → Auth routes: mounts /api/auth
- Express server → Pet routes: mounts /api/pets
- Express server → Adoption routes: mounts /api/adoptions
- Express server → Admin stats: mounts /api/admin
- Auth routes → User model: finds and saves
- Pet routes → Auth middleware: invokes protection
- Adoption routes → Auth middleware: invokes protection
- Admin stats → Auth middleware: invokes protection
- Auth middleware → User model: loads user
- Pet routes → Pet model: queries and saves
- Adoption routes → Pet model: finds and updates
- Adoption routes → Adopter model: creates and queries
- Admin stats → Pet model: counts pets
- Admin stats → Adopter model: counts adopters
- User model → MongoDB: persists user data
- Pet model → MongoDB: persists pet data
- Adopter model → MongoDB: persists adopter data
