# petoapp-org/peto-backend-application architecture

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

- Interactive diagram: https://gitdiagram.com/petoapp-org/peto-backend-application
- Repository: https://github.com/petoapp-org/peto-backend-application

## Overview

Peto is a FastAPI backend exposing REST endpoints and merged GraphQL schemas for authentication, users, pets, items, and pet data. A request enters through the application routers or GraphQL schema, then domain resolvers/services validate and process it; results are returned as typed responses. MongoDB stores application records, while item images use an S3 utility and user flows invoke OTP delivery. The graph reflects documented and indexed relationships; some implementation details, including OTP delivery internals and pet-data resolver behavior, were not excerpted.

Main entry points: [`app/main.py`](https://github.com/petoapp-org/peto-backend-application/blob/main/app/main.py) (FastAPI application), [`app/data/items/item_resolver.py`](https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/items/item_resolver.py) (Item resolvers), [`app/mutations.py`](https://github.com/petoapp-org/peto-backend-application/blob/main/app/mutations.py) (Mutation registry), [`app/user/user_resolvers.py`](https://github.com/petoapp-org/peto-backend-application/blob/main/app/user/user_resolvers.py) (User resolvers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry points"]
  node_application["FastAPI application<br/>[main.py]"]
  node_graphql["GraphQL router<br/>[graphql_router.py]"]
  node_queries["Query registry<br/>[queries.py]"]
  node_mutations["Mutation registry<br/>[mutations.py]"]
end

subgraph group_identity["Identity and users"]
  node_authrouter["Auth routes<br/>[router.py]"]
  node_authservice["Auth service<br/>[service.py]"]
  node_authmodels["Auth models<br/>[models.py]"]
  node_authdeps["Auth dependencies<br/>[dependencies.py]"]
  node_userdomain["User resolvers<br/>[user_resolvers.py]"]
  node_usermodels["User models<br/>[user_models.py]"]
  node_userutils["User validation<br/>[user_utils.py]"]
  node_otp["OTP delivery<br/>[otp_utils.py]"]
  node_otpresolvers["OTP resolvers<br/>[otp_resolvers.py]"]
end

subgraph group_domain["Pet and item domains"]
  node_petdomain["Pet resolvers<br/>[pet_resolvers.py]"]
  node_petmodels["Pet models<br/>[pet_models.py]"]
  node_petutils["Pet response cleanup<br/>[pets_utils.py]"]
  node_itemdomain["Item resolvers<br/>[item_resolver.py]"]
  node_itemmodels["Item models<br/>[item_model.py]"]
  node_itemsroutes["Item routes<br/>[items_router.py]"]
  node_petdata["Pet-data API"]
  node_petdatamodel["Pet-data models<br/>[pets_data_model.py]"]
end

subgraph group_infra["Storage and shared services"]
  node_mongodb[("MongoDB")]
  node_database["Database manager<br/>[database.py]"]
  node_aws[("AWS S3")]
  node_awsutil["Image upload<br/>[aws_util.py]"]
  node_validation["Shared validation<br/>[validations.py]"]
  node_responses["Response types<br/>[response.py]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_application
node_application -->|"mounts routes"| node_authrouter
node_application -->|"mounts schemas"| node_graphql
node_application -->|"mounts routes"| node_itemsroutes
node_application -->|"mounts routes"| node_petdata
node_application -->|"merges queries"| node_queries
node_application -->|"merges mutations"| node_mutations
node_queries -->|"registers queries"| node_userdomain
node_queries -->|"registers queries"| node_petdomain
node_queries -->|"registers queries"| node_itemdomain
node_mutations -->|"registers mutations"| node_userdomain
node_mutations -->|"registers mutations"| node_otpresolvers
node_mutations -->|"registers mutations"| node_petdomain
node_mutations -->|"registers mutations"| node_itemdomain
node_mutations -->|"registers mutations"| node_petdata
node_authrouter -->|"calls service"| node_authservice
node_authservice -->|"uses models"| node_authmodels
node_authservice -->|"reads users"| node_database
node_authdeps -->|"uses service"| node_authservice
node_userdomain -->|"builds responses"| node_usermodels
node_userdomain -->|"validates input"| node_userutils
node_userdomain -->|"requests OTP"| node_otp
node_otpresolvers -->|"uses utilities"| node_otp
node_petdomain -->|"builds responses"| node_petmodels
node_petdomain -->|"cleans records"| node_petutils
node_itemdomain -->|"uses models"| node_itemmodels
node_itemdomain -->|"uploads images"| node_awsutil
node_itemsroutes -->|"routes requests"| node_itemdomain
node_petdata -->|"uses models"| node_petdatamodel
node_petdomain -->|"reads and writes"| node_database
node_userdomain -->|"reads and writes"| node_database
node_itemdomain -->|"reads and writes"| node_database
node_petdata -.->|"uses database"| node_database
node_database -->|"connects to"| node_mongodb
node_awsutil -.->|"uploads objects"| node_aws
node_itemmodels -->|"checks image data"| node_validation
node_userutils -->|"uses validators"| node_validation
node_itemdomain -->|"returns typed results"| node_responses
node_petdata -->|"returns typed results"| node_responses

click node_application "https://github.com/petoapp-org/peto-backend-application/blob/main/app/main.py"
click node_graphql "https://github.com/petoapp-org/peto-backend-application/blob/main/app/graphql_router.py"
click node_queries "https://github.com/petoapp-org/peto-backend-application/blob/main/app/queries.py"
click node_mutations "https://github.com/petoapp-org/peto-backend-application/blob/main/app/mutations.py"
click node_authrouter "https://github.com/petoapp-org/peto-backend-application/blob/main/app/auth/router.py"
click node_authservice "https://github.com/petoapp-org/peto-backend-application/blob/main/app/auth/service.py"
click node_authmodels "https://github.com/petoapp-org/peto-backend-application/blob/main/app/auth/models.py"
click node_authdeps "https://github.com/petoapp-org/peto-backend-application/blob/main/app/auth/dependencies.py"
click node_userdomain "https://github.com/petoapp-org/peto-backend-application/blob/main/app/user/user_resolvers.py"
click node_usermodels "https://github.com/petoapp-org/peto-backend-application/blob/main/app/user/user_models.py"
click node_userutils "https://github.com/petoapp-org/peto-backend-application/blob/main/app/user/user_utils.py"
click node_otp "https://github.com/petoapp-org/peto-backend-application/blob/main/app/otp/otp_utils.py"
click node_otpresolvers "https://github.com/petoapp-org/peto-backend-application/blob/main/app/otp/otp_resolvers.py"
click node_petdomain "https://github.com/petoapp-org/peto-backend-application/blob/main/app/pets/pet_resolvers.py"
click node_petmodels "https://github.com/petoapp-org/peto-backend-application/blob/main/app/pets/pet_models.py"
click node_petutils "https://github.com/petoapp-org/peto-backend-application/blob/main/app/pets/pets_utils.py"
click node_itemdomain "https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/items/item_resolver.py"
click node_itemmodels "https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/items/item_model.py"
click node_itemsroutes "https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/items/items_router.py"
click node_petdata "https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/pets_data/pets_data_resolver.py"
click node_petdatamodel "https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/pets_data/pets_data_model.py"
click node_database "https://github.com/petoapp-org/peto-backend-application/blob/main/app/database.py"
click node_awsutil "https://github.com/petoapp-org/peto-backend-application/blob/main/app/utils/aws_util.py"
click node_validation "https://github.com/petoapp-org/peto-backend-application/blob/main/app/utils/validations.py"
click node_responses "https://github.com/petoapp-org/peto-backend-application/blob/main/app/utils/response.py"

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_application,node_graphql,node_queries,node_mutations,node_client toneBlue
class node_authrouter,node_authservice,node_authmodels,node_authdeps,node_userdomain,node_usermodels,node_userutils,node_otp,node_otpresolvers toneAmber
class node_petdomain,node_petmodels,node_petutils,node_itemdomain,node_itemmodels,node_itemsroutes,node_petdata,node_petdatamodel toneMint
class node_mongodb,node_database,node_aws,node_awsutil,node_validation,node_responses toneRose
```

## Components

### API entry points

- [FastAPI application](https://github.com/petoapp-org/peto-backend-application/blob/main/app/main.py): `app/main.py`
- [GraphQL router](https://github.com/petoapp-org/peto-backend-application/blob/main/app/graphql_router.py): `app/graphql_router.py`
- [Query registry](https://github.com/petoapp-org/peto-backend-application/blob/main/app/queries.py): `app/queries.py`
- [Mutation registry](https://github.com/petoapp-org/peto-backend-application/blob/main/app/mutations.py): `app/mutations.py`

### Identity and users

- [Auth routes](https://github.com/petoapp-org/peto-backend-application/blob/main/app/auth/router.py): `app/auth/router.py`
- [Auth service](https://github.com/petoapp-org/peto-backend-application/blob/main/app/auth/service.py): `app/auth/service.py`
- [Auth models](https://github.com/petoapp-org/peto-backend-application/blob/main/app/auth/models.py): `app/auth/models.py`
- [Auth dependencies](https://github.com/petoapp-org/peto-backend-application/blob/main/app/auth/dependencies.py): `app/auth/dependencies.py`
- [User resolvers](https://github.com/petoapp-org/peto-backend-application/blob/main/app/user/user_resolvers.py): `app/user/user_resolvers.py`
- [User models](https://github.com/petoapp-org/peto-backend-application/blob/main/app/user/user_models.py): `app/user/user_models.py`
- [User validation](https://github.com/petoapp-org/peto-backend-application/blob/main/app/user/user_utils.py): `app/user/user_utils.py`
- [OTP delivery](https://github.com/petoapp-org/peto-backend-application/blob/main/app/otp/otp_utils.py): `app/otp/otp_utils.py`
- [OTP resolvers](https://github.com/petoapp-org/peto-backend-application/blob/main/app/otp/otp_resolvers.py): `app/otp/otp_resolvers.py`

### Pet and item domains

- [Pet resolvers](https://github.com/petoapp-org/peto-backend-application/blob/main/app/pets/pet_resolvers.py): `app/pets/pet_resolvers.py`
- [Pet models](https://github.com/petoapp-org/peto-backend-application/blob/main/app/pets/pet_models.py): `app/pets/pet_models.py`
- [Pet response cleanup](https://github.com/petoapp-org/peto-backend-application/blob/main/app/pets/pets_utils.py): `app/pets/pets_utils.py`
- [Item resolvers](https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/items/item_resolver.py): `app/data/items/item_resolver.py`
- [Item models](https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/items/item_model.py): `app/data/items/item_model.py`
- [Item routes](https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/items/items_router.py): `app/data/items/items_router.py`
- [Pet-data API](https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/pets_data/pets_data_resolver.py): `app/data/pets_data/pets_data_resolver.py`
- [Pet-data models](https://github.com/petoapp-org/peto-backend-application/blob/main/app/data/pets_data/pets_data_model.py): `app/data/pets_data/pets_data_model.py`

### Storage and shared services

- **MongoDB**
- [Database manager](https://github.com/petoapp-org/peto-backend-application/blob/main/app/database.py): `app/database.py`
- **AWS S3**
- [Image upload](https://github.com/petoapp-org/peto-backend-application/blob/main/app/utils/aws_util.py): `app/utils/aws_util.py`
- [Shared validation](https://github.com/petoapp-org/peto-backend-application/blob/main/app/utils/validations.py): `app/utils/validations.py`
- [Response types](https://github.com/petoapp-org/peto-backend-application/blob/main/app/utils/response.py): `app/utils/response.py`

### Other components

- **API client**

## Connections

- API client → FastAPI application: sends requests (evidence: `app/main.py`)
- FastAPI application → Auth routes: mounts routes (evidence: `app/main.py`)
- FastAPI application → GraphQL router: mounts schemas (evidence: `app/main.py`)
- FastAPI application → Item routes: mounts routes (evidence: `app/main.py`)
- FastAPI application → Pet-data API: mounts routes (evidence: `app/main.py`)
- FastAPI application → Query registry: merges queries (evidence: `app/main.py`)
- FastAPI application → Mutation registry: merges mutations (evidence: `app/main.py`)
- Query registry → User resolvers: registers queries (evidence: `app/queries.py`)
- Query registry → Pet resolvers: registers queries (evidence: `app/queries.py`)
- Query registry → Item resolvers: registers queries (evidence: `app/queries.py`)
- Mutation registry → User resolvers: registers mutations (evidence: `app/mutations.py`)
- Mutation registry → OTP resolvers: registers mutations (evidence: `app/mutations.py`)
- Mutation registry → Pet resolvers: registers mutations (evidence: `app/mutations.py`)
- Mutation registry → Item resolvers: registers mutations (evidence: `app/mutations.py`)
- Mutation registry → Pet-data API: registers mutations (evidence: `app/mutations.py`)
- Auth routes → Auth service: calls service (evidence: `app/auth/router.py`)
- Auth service → Auth models: uses models (evidence: `app/auth/service.py`)
- Auth service → Database manager: reads users (evidence: `app/auth/service.py`)
- Auth dependencies → Auth service: uses service (evidence: `app/auth/dependencies.py`)
- User resolvers → User models: builds responses (evidence: `app/user/user_resolvers.py`)
- User resolvers → User validation: validates input (evidence: `app/user/user_resolvers.py`)
- User resolvers → OTP delivery: requests OTP (evidence: `app/user/user_resolvers.py`)
- OTP resolvers → OTP delivery: uses utilities (evidence: `app/otp/otp_resolvers.py`)
- Pet resolvers → Pet models: builds responses (evidence: `app/pets/pet_resolvers.py`)
- Pet resolvers → Pet response cleanup: cleans records (evidence: `app/pets/pet_resolvers.py`)
- Item resolvers → Item models: uses models (evidence: `app/data/items/item_resolver.py`)
- Item resolvers → Image upload: uploads images (evidence: `app/data/items/item_resolver.py`)
- Item routes → Item resolvers: routes requests (evidence: `app/data/items/items_router.py`)
- Pet-data API → Pet-data models: uses models (evidence: `app/data/pets_data/pets_data_resolver.py`)
- Pet resolvers → Database manager: reads and writes (evidence: `app/pets/pet_resolvers.py`)
- User resolvers → Database manager: reads and writes (evidence: `app/user/user_resolvers.py`)
- Item resolvers → Database manager: reads and writes (evidence: `app/data/items/item_resolver.py`)
- Pet-data API → Database manager: uses database
- Database manager → MongoDB: connects to (evidence: `app/database.py`)
- Image upload → AWS S3: uploads objects
- Item models → Shared validation: checks image data (evidence: `app/data/items/item_model.py`)
- User validation → Shared validation: uses validators (evidence: `app/user/user_utils.py`)
- Item resolvers → Response types: returns typed results (evidence: `app/data/items/item_resolver.py`)
- Pet-data API → Response types: returns typed results (evidence: `app/data/pets_data/pets_data_resolver.py`)
