# outro-lucas/pet-valley-api architecture

> Architecture diagram of the GitHub repository outro-lucas/pet-valley-api, 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/outro-lucas/pet-valley-api
- Repository: https://github.com/outro-lucas/pet-valley-api

## Overview

Adopet is an animal-adoption API: adopters browse animal listings and submit an adoption request; organizations and adopters then progress it through interview, home visit, contract, and travel, or cancel it. Express routes dispatch to controllers, which delegate to services; services use TypeORM with SQLite. The README documents the broader adoption stages and listing/organization capabilities. Notification and dashboard services described in the README are not present in the supplied tree; relationships are limited to those evidenced by excerpts, the source index, or README.

Main entry points: [`src/app.ts`](https://github.com/outro-lucas/pet-valley-api/blob/main/src/app.ts) (Express API), [`src/middleware/auth.middleware.ts`](https://github.com/outro-lucas/pet-valley-api/blob/main/src/middleware/auth.middleware.ts) (Token authentication), [`src/utils/database.ts`](https://github.com/outro-lucas/pet-valley-api/blob/main/src/utils/database.ts) (TypeORM data source), [`src/services/animal.service.ts`](https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/animal.service.ts) (Animal catalog service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry and access"]
  node_server["Express API<br/>[app.ts]"]
  node_auth_routes["Auth routes<br/>[auth.routes.ts]"]
  node_user_routes["User routes<br/>[users.routes.ts]"]
  node_org_routes["Organization routes"]
  node_animal_routes["Animal routes<br/>[animal.routes.ts]"]
  node_adoption_routes["Adoption routes<br/>[adoption.routes.ts]"]
  node_auth_middleware["Token authentication<br/>[auth.middleware.ts]"]
  node_role_middleware["Role authorization<br/>[role.middleware.ts]"]
end

subgraph group_accounts["Accounts and organizations"]
  node_auth_controller["Auth controller<br/>[auth.controller.ts]"]
  node_user_controller["User controller"]
  node_org_controller["Organization controller"]
  node_auth_service["Authentication service<br/>[auth.service.ts]"]
  node_user_service["User service<br/>[user.service.ts]"]
  node_org_service["Organization service"]
end

subgraph group_animals["Animal listings"]
  node_animal_controller["Animal controller"]
  node_animal_service["Animal catalog service<br/>[animal.service.ts]"]
end

subgraph group_adoption["Adoption process"]
  node_adoption_controller["Adoption controller"]
  node_adoption_service["Adoption workflow service"]
end

subgraph group_persistence["Persistence and media"]
  node_domain_entities["Domain entities"]
  node_database_config["TypeORM data source<br/>[database.ts]"]
  node_sqlite[("SQLite database<br/>[adopet.sqlite]")]
  node_github_media["GitHub Pages media"]
end

node_user(("Adopter or organization"))
node_github_external{{"GitHub Pages"}}

node_user -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_user_routes
node_server -->|"mounts routes"| node_org_routes
node_server -->|"mounts routes"| node_animal_routes
node_server -->|"mounts routes"| node_adoption_routes
node_auth_routes -->|"dispatches to"| node_auth_controller
node_user_routes -->|"dispatches to"| node_user_controller
node_org_routes -->|"dispatches to"| node_org_controller
node_animal_routes -->|"dispatches to"| node_animal_controller
node_adoption_routes -->|"dispatches to"| node_adoption_controller
node_auth_routes -->|"authenticates with"| node_auth_middleware
node_user_routes -->|"authenticates with"| node_auth_middleware
node_org_routes -->|"authenticates with"| node_auth_middleware
node_org_routes -->|"checks roles"| node_role_middleware
node_animal_routes -->|"authenticates with"| node_auth_middleware
node_animal_routes -->|"checks roles"| node_role_middleware
node_adoption_routes -->|"authenticates with"| node_auth_middleware
node_auth_controller -->|"calls"| node_auth_service
node_user_controller -->|"calls"| node_user_service
node_org_controller -->|"calls"| node_org_service
node_animal_controller -->|"calls"| node_animal_service
node_adoption_controller -->|"calls"| node_adoption_service
node_auth_middleware -->|"validates token"| node_auth_service
node_auth_service -->|"uses repositories"| node_database_config
node_user_service -->|"uses repositories"| node_database_config
node_org_service -->|"uses repositories"| node_database_config
node_animal_service -->|"uses repository"| node_database_config
node_adoption_service -->|"uses repository"| node_database_config
node_database_config -->|"configures store"| node_sqlite
node_auth_service -->|"persists accounts"| node_domain_entities
node_user_service -->|"persists users"| node_domain_entities
node_org_service -->|"persists organizations"| node_domain_entities
node_animal_service -->|"persists animals"| node_domain_entities
node_adoption_service -->|"persists adoptions"| node_domain_entities
node_adoption_service -->|"updates animal status"| node_animal_service
node_animal_service -->|"uploads images"| node_github_media
node_github_media -.->|"stores images"| node_github_external

click node_server "https://github.com/outro-lucas/pet-valley-api/blob/main/src/app.ts"
click node_auth_routes "https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/auth.routes.ts"
click node_user_routes "https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/users.routes.ts"
click node_org_routes "https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/organization.routes.ts"
click node_animal_routes "https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/animal.routes.ts"
click node_adoption_routes "https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/adoption.routes.ts"
click node_auth_middleware "https://github.com/outro-lucas/pet-valley-api/blob/main/src/middleware/auth.middleware.ts"
click node_role_middleware "https://github.com/outro-lucas/pet-valley-api/blob/main/src/middleware/role.middleware.ts"
click node_auth_controller "https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/auth.controller.ts"
click node_user_controller "https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/users.controller.ts"
click node_org_controller "https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/organizations.controller.ts"
click node_auth_service "https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/auth.service.ts"
click node_user_service "https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/user.service.ts"
click node_org_service "https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/organization.service.ts"
click node_animal_controller "https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/animal.controller.ts"
click node_animal_service "https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/animal.service.ts"
click node_adoption_controller "https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/adoption.controller.ts"
click node_adoption_service "https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/adoption.service.ts"
click node_domain_entities "https://github.com/outro-lucas/pet-valley-api/tree/main/src/entities"
click node_database_config "https://github.com/outro-lucas/pet-valley-api/blob/main/src/utils/database.ts"
click node_sqlite "https://github.com/outro-lucas/pet-valley-api/blob/main/database/adopet.sqlite"
click node_github_media "https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/github-pages.service.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_server,node_auth_routes,node_user_routes,node_org_routes,node_animal_routes,node_adoption_routes,node_auth_middleware,node_role_middleware toneBlue
class node_auth_controller,node_user_controller,node_org_controller,node_auth_service,node_user_service,node_org_service toneAmber
class node_animal_controller,node_animal_service toneMint
class node_adoption_controller,node_adoption_service toneRose
class node_domain_entities,node_database_config,node_sqlite,node_github_media,node_user,node_github_external toneIndigo
```

## Components

### API entry and access

- [Express API](https://github.com/outro-lucas/pet-valley-api/blob/main/src/app.ts): `src/app.ts`
- [Auth routes](https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/auth.routes.ts): `src/routes/auth.routes.ts`
- [User routes](https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/users.routes.ts): `src/routes/users.routes.ts`
- [Organization routes](https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/organization.routes.ts): `src/routes/organization.routes.ts`
- [Animal routes](https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/animal.routes.ts): `src/routes/animal.routes.ts`
- [Adoption routes](https://github.com/outro-lucas/pet-valley-api/blob/main/src/routes/adoption.routes.ts): `src/routes/adoption.routes.ts`
- [Token authentication](https://github.com/outro-lucas/pet-valley-api/blob/main/src/middleware/auth.middleware.ts): `src/middleware/auth.middleware.ts`
- [Role authorization](https://github.com/outro-lucas/pet-valley-api/blob/main/src/middleware/role.middleware.ts): `src/middleware/role.middleware.ts`

### Accounts and organizations

- [Auth controller](https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/auth.controller.ts): `src/controllers/auth.controller.ts`
- [User controller](https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/users.controller.ts): `src/controllers/users.controller.ts`
- [Organization controller](https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/organizations.controller.ts): `src/controllers/organizations.controller.ts`
- [Authentication service](https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/auth.service.ts): `src/services/auth.service.ts`
- [User service](https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/user.service.ts): `src/services/user.service.ts`
- [Organization service](https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/organization.service.ts): `src/services/organization.service.ts`

### Animal listings

- [Animal controller](https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/animal.controller.ts): `src/controllers/animal.controller.ts`
- [Animal catalog service](https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/animal.service.ts): `src/services/animal.service.ts`

### Adoption process

- [Adoption controller](https://github.com/outro-lucas/pet-valley-api/blob/main/src/controllers/adoption.controller.ts): `src/controllers/adoption.controller.ts`
- [Adoption workflow service](https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/adoption.service.ts): `src/services/adoption.service.ts`

### Persistence and media

- [Domain entities](https://github.com/outro-lucas/pet-valley-api/tree/main/src/entities): `src/entities`
- [TypeORM data source](https://github.com/outro-lucas/pet-valley-api/blob/main/src/utils/database.ts): `src/utils/database.ts`
- [SQLite database](https://github.com/outro-lucas/pet-valley-api/blob/main/database/adopet.sqlite): `database/adopet.sqlite`
- [GitHub Pages media](https://github.com/outro-lucas/pet-valley-api/blob/main/src/services/github-pages.service.ts): `src/services/github-pages.service.ts`

### Other components

- **Adopter or organization**
- **GitHub Pages**

## Connections

- Adopter or organization → Express API: sends requests (evidence: `src/app.ts`)
- Express API → Auth routes: mounts routes (evidence: `src/app.ts`)
- Express API → User routes: mounts routes (evidence: `src/app.ts`)
- Express API → Organization routes: mounts routes (evidence: `src/app.ts`)
- Express API → Animal routes: mounts routes (evidence: `src/app.ts`)
- Express API → Adoption routes: mounts routes (evidence: `src/app.ts`)
- Auth routes → Auth controller: dispatches to (evidence: `src/routes/auth.routes.ts`)
- User routes → User controller: dispatches to (evidence: `src/routes/users.routes.ts`)
- Organization routes → Organization controller: dispatches to (evidence: `src/routes/organization.routes.ts`)
- Animal routes → Animal controller: dispatches to (evidence: `src/routes/animal.routes.ts`)
- Adoption routes → Adoption controller: dispatches to (evidence: `src/routes/adoption.routes.ts`)
- Auth routes → Token authentication: authenticates with (evidence: `src/routes/auth.routes.ts`)
- User routes → Token authentication: authenticates with (evidence: `src/routes/users.routes.ts`)
- Organization routes → Token authentication: authenticates with (evidence: `src/routes/organization.routes.ts`)
- Organization routes → Role authorization: checks roles (evidence: `src/routes/organization.routes.ts`)
- Animal routes → Token authentication: authenticates with (evidence: `src/routes/animal.routes.ts`)
- Animal routes → Role authorization: checks roles (evidence: `src/routes/animal.routes.ts`)
- Adoption routes → Token authentication: authenticates with (evidence: `src/routes/adoption.routes.ts`)
- Auth controller → Authentication service: calls (evidence: `src/controllers/auth.controller.ts`)
- User controller → User service: calls (evidence: `src/controllers/users.controller.ts`)
- Organization controller → Organization service: calls (evidence: `src/controllers/organizations.controller.ts`)
- Animal controller → Animal catalog service: calls (evidence: `src/controllers/animal.controller.ts`)
- Adoption controller → Adoption workflow service: calls (evidence: `src/controllers/adoption.controller.ts`)
- Token authentication → Authentication service: validates token (evidence: `src/middleware/auth.middleware.ts`)
- Authentication service → TypeORM data source: uses repositories (evidence: `src/services/auth.service.ts`)
- User service → TypeORM data source: uses repositories (evidence: `src/services/user.service.ts`)
- Organization service → TypeORM data source: uses repositories (evidence: `src/services/organization.service.ts`)
- Animal catalog service → TypeORM data source: uses repository (evidence: `src/services/animal.service.ts`)
- Adoption workflow service → TypeORM data source: uses repository (evidence: `src/services/adoption.service.ts`)
- TypeORM data source → SQLite database: configures store (evidence: `src/utils/database.ts`)
- Authentication service → Domain entities: persists accounts (evidence: `src/services/auth.service.ts`)
- User service → Domain entities: persists users (evidence: `src/services/user.service.ts`)
- Organization service → Domain entities: persists organizations (evidence: `src/services/organization.service.ts`)
- Animal catalog service → Domain entities: persists animals (evidence: `src/services/animal.service.ts`)
- Adoption workflow service → Domain entities: persists adoptions (evidence: `src/services/adoption.service.ts`)
- Adoption workflow service → Animal catalog service: updates animal status (evidence: `src/services/adoption.service.ts`)
- Animal catalog service → GitHub Pages media: uploads images (evidence: `src/services/animal.service.ts`)
- GitHub Pages media → GitHub Pages: stores images
