# theusinhoiost/pettracker-backend architecture

> Architecture diagram of the GitHub repository theusinhoiost/pettracker-backend, 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/theusinhoiost/pettracker-backend
- Repository: https://github.com/theusinhoiost/pettracker-backend

## Overview

PetTracker is a NestJS REST backend for account access and pet-care records. The main workflow is a client authenticating, then managing owned pets and their images; weight and vaccine records and notification state are separate user-facing branches. Authentication also supports Google sign-in and refresh-token exchange. The tree and README establish PostgreSQL and S3 capabilities, but service implementations and module wiring for several branches were not sampled, so those connections are shown only where documented or directly supported.

Main entry points: [`src/main.ts`](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/main.ts) (NestJS API bootstrap), [`src/auth/auth.service.ts`](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/auth.service.ts) (Auth workflows), [`src/auth/auth.controller.ts`](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/auth.controller.ts) (Auth endpoints), [`src/pet/pet.service.ts`](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/pet.service.ts) (Pet workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Identity and access"]
  node_authctl["Auth endpoints<br/>[auth.controller.ts]"]
  node_authsvc["Auth workflows<br/>[auth.service.ts]"]
  node_jwt["JWT strategies<br/>[jwt.strategy.ts]"]
  node_googleflow["Google strategy<br/>[google.strategy.ts]"]
end

subgraph group_accounts["Account management"]
  node_userctl["User endpoints<br/>[user.controller.ts]"]
  node_usersvc["User workflows<br/>[user.service.ts]"]
  node_userdata["User records<br/>[user.entity.ts]"]
end

subgraph group_petcare["Pet care records"]
  node_petctl["Pet endpoints<br/>[pet.controller.ts]"]
  node_petsvc["Pet workflows<br/>[pet.service.ts]"]
  node_petdata["Pet records<br/>[pet.entity.ts]"]
  node_vaccinectl["Vaccine endpoints"]
  node_vaccinesvc["Vaccine workflows<br/>[vaccine.service.ts]"]
  node_vaccinedata["Vaccine records<br/>[vaccine.entity.ts]"]
  node_weightctl["Weight endpoints"]
  node_weightsvc["Weight workflows<br/>[weight.service.ts]"]
  node_weightdata["Weight records<br/>[weight.entity.ts]"]
end

subgraph group_platform["Storage and uploads"]
  node_s3svc["Image storage<br/>[s3.service.ts]"]
end

subgraph group_alerts["Notifications"]
  node_notifyctl["Notification endpoints"]
  node_notifysvc["Notification workflows"]
  node_notifydata["Notification records"]
end

node_client(("Frontend client"))
node_google(("Google OAuth"))
node_api["NestJS API bootstrap<br/>[main.ts]"]
node_s3[("AWS S3")]
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_api
node_api -->|"serves routes"| node_authctl
node_api -->|"serves routes"| node_userctl
node_api -->|"serves routes"| node_petctl
node_api -->|"serves routes"| node_vaccinectl
node_api -->|"serves routes"| node_weightctl
node_api -->|"serves routes"| node_notifyctl
node_authctl -->|"calls"| node_authsvc
node_authsvc -->|"looks up user"| node_usersvc
node_authsvc -->|"signs tokens"| node_jwt
node_authctl -->|"guards callback"| node_googleflow
node_google -->|"authenticates"| node_googleflow
node_googleflow -->|"provides identity"| node_authctl
node_authsvc -->|"reads and writes"| node_postgres
node_userctl -->|"calls"| node_usersvc
node_usersvc -->|"persists accounts"| node_postgres
node_petctl -->|"calls"| node_petsvc
node_petsvc -->|"uploads images"| node_s3svc
node_s3svc -->|"stores objects"| node_s3
node_petsvc -->|"persists pets"| node_postgres
node_vaccinectl -->|"calls"| node_vaccinesvc
node_vaccinesvc -->|"persists records"| node_postgres
node_weightctl -->|"calls"| node_weightsvc
node_weightsvc -->|"persists records"| node_postgres
node_notifyctl -->|"calls"| node_notifysvc
node_notifysvc -->|"reads and writes"| node_postgres

click node_api "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/main.ts"
click node_authctl "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/auth.controller.ts"
click node_authsvc "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/auth.service.ts"
click node_jwt "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/jwt.strategy.ts"
click node_googleflow "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/google.strategy.ts"
click node_userctl "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/user/user.controller.ts"
click node_usersvc "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/user/user.service.ts"
click node_userdata "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/user/entities/user.entity.ts"
click node_petctl "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/pet.controller.ts"
click node_petsvc "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/pet.service.ts"
click node_petdata "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/entities/pet.entity.ts"
click node_vaccinectl "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/vaccine/vaccine.controller.ts"
click node_vaccinesvc "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/vaccine/vaccine.service.ts"
click node_vaccinedata "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/vaccine/entities/vaccine.entity.ts"
click node_weightctl "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/weight/weight.controller.ts"
click node_weightsvc "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/weight/weight.service.ts"
click node_weightdata "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/weight/entities/weight.entity.ts"
click node_s3svc "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/common/s3/s3.service.ts"
click node_notifyctl "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/notifications/notifications.controller.ts"
click node_notifysvc "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/notifications/notifications.service.ts"
click node_notifydata "https://github.com/theusinhoiost/pettracker-backend/blob/master/src/notifications/entities/notification.entity.ts"

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_authctl,node_authsvc,node_jwt,node_googleflow,node_client toneBlue
class node_userctl,node_usersvc,node_userdata,node_s3,node_postgres toneAmber
class node_petctl,node_petsvc,node_petdata,node_vaccinectl,node_vaccinesvc,node_vaccinedata,node_weightctl,node_weightsvc,node_weightdata,node_api toneMint
class node_s3svc toneRose
class node_notifyctl,node_notifysvc,node_notifydata,node_google toneIndigo
```

## Components

### Identity and access

- [Auth endpoints](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Auth workflows](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [JWT strategies](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/jwt.strategy.ts): `src/auth/jwt.strategy.ts`
- [Google strategy](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/auth/google.strategy.ts): `src/auth/google.strategy.ts`

### Account management

- [User endpoints](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/user/user.controller.ts): `src/user/user.controller.ts`
- [User workflows](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/user/user.service.ts): `src/user/user.service.ts`
- [User records](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/user/entities/user.entity.ts): `src/user/entities/user.entity.ts`

### Pet care records

- [Pet endpoints](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/pet.controller.ts): `src/pet/pet.controller.ts`
- [Pet workflows](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/pet.service.ts): `src/pet/pet.service.ts`
- [Pet records](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/entities/pet.entity.ts): `src/pet/entities/pet.entity.ts`
- [Vaccine endpoints](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/vaccine/vaccine.controller.ts): `src/pet/vaccine/vaccine.controller.ts`
- [Vaccine workflows](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/vaccine/vaccine.service.ts): `src/pet/vaccine/vaccine.service.ts`
- [Vaccine records](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/vaccine/entities/vaccine.entity.ts): `src/pet/vaccine/entities/vaccine.entity.ts`
- [Weight endpoints](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/weight/weight.controller.ts): `src/pet/weight/weight.controller.ts`
- [Weight workflows](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/weight/weight.service.ts): `src/pet/weight/weight.service.ts`
- [Weight records](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/pet/weight/entities/weight.entity.ts): `src/pet/weight/entities/weight.entity.ts`

### Storage and uploads

- [Image storage](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/common/s3/s3.service.ts): `src/common/s3/s3.service.ts`

### Notifications

- [Notification endpoints](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/notifications/notifications.controller.ts): `src/notifications/notifications.controller.ts`
- [Notification workflows](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/notifications/notifications.service.ts): `src/notifications/notifications.service.ts`
- [Notification records](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/notifications/entities/notification.entity.ts): `src/notifications/entities/notification.entity.ts`

### Other components

- **Frontend client**
- **Google OAuth**
- [NestJS API bootstrap](https://github.com/theusinhoiost/pettracker-backend/blob/master/src/main.ts): `src/main.ts`
- **AWS S3**
- **PostgreSQL**

## Connections

- Frontend client → NestJS API bootstrap: sends requests
- NestJS API bootstrap → Auth endpoints: serves routes
- NestJS API bootstrap → User endpoints: serves routes
- NestJS API bootstrap → Pet endpoints: serves routes
- NestJS API bootstrap → Vaccine endpoints: serves routes
- NestJS API bootstrap → Weight endpoints: serves routes
- NestJS API bootstrap → Notification endpoints: serves routes
- Auth endpoints → Auth workflows: calls
- Auth workflows → User workflows: looks up user
- Auth workflows → JWT strategies: signs tokens
- Auth endpoints → Google strategy: guards callback
- Google OAuth → Google strategy: authenticates
- Google strategy → Auth endpoints: provides identity
- Auth workflows → PostgreSQL: reads and writes
- User endpoints → User workflows: calls
- User workflows → PostgreSQL: persists accounts
- Pet endpoints → Pet workflows: calls
- Pet workflows → Image storage: uploads images
- Image storage → AWS S3: stores objects
- Pet workflows → PostgreSQL: persists pets
- Vaccine endpoints → Vaccine workflows: calls
- Vaccine workflows → PostgreSQL: persists records
- Weight endpoints → Weight workflows: calls
- Weight workflows → PostgreSQL: persists records
- Notification endpoints → Notification workflows: calls
- Notification workflows → PostgreSQL: reads and writes
