# r1qk/cp05-poo-petfiap-bughunt architecture

> Architecture diagram of the GitHub repository r1qk/cp05-poo-petfiap-bughunt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/r1qk/cp05-poo-petfiap-bughunt
- Repository: https://github.com/r1qk/cp05-poo-petfiap-bughunt

## Overview

PetFiap is a Spring REST API for scheduling pet bathing, grooming, and veterinary appointments. The main workflow accepts appointment details, assigns a protocol, builds and type-selects a domain appointment, checks scheduling rules, and persists it; clients can then look up appointments, view price/points/duration, or complete and cancel them. The README also documents Oracle/H2 runtime configuration. Edges follow the controller, service, builder, factory, model, and repository calls visible in the excerpts; storage wiring is represented by the repository abstraction, not an asserted database connection.

Main entry points: [`src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java`](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java) (Appointment API), [`src/main/java/br/com/fiap/petfiap/service/AgendaService.java`](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/service/AgendaService.java) (Agenda rules), [`src/main/java/br/com/fiap/petfiap/factory/AtendimentoFactory.java`](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/factory/AtendimentoFactory.java) (Appointment factory), [`src/main/java/br/com/fiap/petfiap/model/Atendimento.java`](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/Atendimento.java) (Appointment state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_controller["Appointment API"]
  node_agenda["Agenda rules<br/>[AgendaService.java]"]
  node_service["Appointment not found"]
  node_occupied["Occupied slot"]
end

subgraph group_creation["Appointment creation"]
  node_builder["Appointment builder"]
  node_factory["Appointment factory"]
  node_protocol["Protocol generator"]
end

subgraph group_domain["Appointment domain"]
  node_appointment["Appointment state<br/>[Atendimento.java]"]
  node_bath["Bath pricing<br/>[Banho.java]"]
  node_grooming["Grooming pricing<br/>[Tosa.java]"]
  node_vet["Veterinary consultation"]
  node_invalid["Invalid status"]
end

subgraph group_persistence["Persistence"]
  node_repository[("Appointment repository")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_controller
node_controller -->|"gets protocol"| node_protocol
node_controller -->|"builds appointment"| node_builder
node_builder -->|"creates type"| node_factory
node_factory -->|"instantiates"| node_bath
node_factory -->|"instantiates"| node_grooming
node_factory -->|"instantiates"| node_vet
node_controller -->|"routes operations"| node_agenda
node_agenda -->|"queries and saves"| node_repository
node_repository -->|"stores entities"| node_appointment
node_controller -->|"reads summary"| node_appointment
node_agenda -->|"changes status"| node_appointment
node_appointment -->|"rejects transitions"| node_invalid
node_agenda -->|"rejects slot"| node_occupied
node_agenda -->|"throws on missing"| node_service
node_controller -->|"maps not found"| node_service

click node_controller "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java"
click node_agenda "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/service/AgendaService.java"
click node_builder "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/builder/AtendimentoBuilder.java"
click node_factory "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/factory/AtendimentoFactory.java"
click node_protocol "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/GeradorProtocolo.java"
click node_appointment "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/Atendimento.java"
click node_bath "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/Banho.java"
click node_grooming "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/Tosa.java"
click node_vet "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/ConsultaVeterinaria.java"
click node_repository "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/repository/AtendimentoRepository.java"
click node_service "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/exception/AtendimentoNaoEncontradoException.java"
click node_occupied "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/exception/HorarioOcupadoException.java"
click node_invalid "https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/exception/StatusInvalidoException.java"

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_controller,node_agenda,node_service,node_occupied,node_client toneBlue
class node_builder,node_factory,node_protocol toneAmber
class node_appointment,node_bath,node_grooming,node_vet,node_invalid toneMint
class node_repository toneRose
```

## Components

### REST API

- [Appointment API](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java): `src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java`
- [Agenda rules](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/service/AgendaService.java): `src/main/java/br/com/fiap/petfiap/service/AgendaService.java`
- [Appointment not found](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/exception/AtendimentoNaoEncontradoException.java): `src/main/java/br/com/fiap/petfiap/exception/AtendimentoNaoEncontradoException.java`
- [Occupied slot](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/exception/HorarioOcupadoException.java): `src/main/java/br/com/fiap/petfiap/exception/HorarioOcupadoException.java`

### Appointment creation

- [Appointment builder](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/builder/AtendimentoBuilder.java): `src/main/java/br/com/fiap/petfiap/builder/AtendimentoBuilder.java`
- [Appointment factory](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/factory/AtendimentoFactory.java): `src/main/java/br/com/fiap/petfiap/factory/AtendimentoFactory.java`
- [Protocol generator](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/GeradorProtocolo.java): `src/main/java/br/com/fiap/petfiap/model/GeradorProtocolo.java`

### Appointment domain

- [Appointment state](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/Atendimento.java): `src/main/java/br/com/fiap/petfiap/model/Atendimento.java`
- [Bath pricing](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/Banho.java): `src/main/java/br/com/fiap/petfiap/model/Banho.java`
- [Grooming pricing](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/Tosa.java): `src/main/java/br/com/fiap/petfiap/model/Tosa.java`
- [Veterinary consultation](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/model/ConsultaVeterinaria.java): `src/main/java/br/com/fiap/petfiap/model/ConsultaVeterinaria.java`
- [Invalid status](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/exception/StatusInvalidoException.java): `src/main/java/br/com/fiap/petfiap/exception/StatusInvalidoException.java`

### Persistence

- [Appointment repository](https://github.com/r1qk/cp05-poo-petfiap-bughunt/blob/main/src/main/java/br/com/fiap/petfiap/repository/AtendimentoRepository.java): `src/main/java/br/com/fiap/petfiap/repository/AtendimentoRepository.java`

### Other components

- **API client**

## Connections

- API client → Appointment API: sends requests (evidence: `src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java`)
- Appointment API → Protocol generator: gets protocol (evidence: `src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java`)
- Appointment API → Appointment builder: builds appointment (evidence: `src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java`)
- Appointment builder → Appointment factory: creates type (evidence: `src/main/java/br/com/fiap/petfiap/builder/AtendimentoBuilder.java`)
- Appointment factory → Bath pricing: instantiates (evidence: `src/main/java/br/com/fiap/petfiap/factory/AtendimentoFactory.java`)
- Appointment factory → Grooming pricing: instantiates (evidence: `src/main/java/br/com/fiap/petfiap/factory/AtendimentoFactory.java`)
- Appointment factory → Veterinary consultation: instantiates (evidence: `src/main/java/br/com/fiap/petfiap/factory/AtendimentoFactory.java`)
- Appointment API → Agenda rules: routes operations (evidence: `src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java`)
- Agenda rules → Appointment repository: queries and saves (evidence: `src/main/java/br/com/fiap/petfiap/service/AgendaService.java`)
- Appointment repository → Appointment state: stores entities (evidence: `src/main/java/br/com/fiap/petfiap/repository/AtendimentoRepository.java`)
- Appointment API → Appointment state: reads summary (evidence: `src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java`)
- Agenda rules → Appointment state: changes status (evidence: `src/main/java/br/com/fiap/petfiap/service/AgendaService.java`)
- Appointment state → Invalid status: rejects transitions (evidence: `src/main/java/br/com/fiap/petfiap/model/Atendimento.java`)
- Agenda rules → Occupied slot: rejects slot (evidence: `src/main/java/br/com/fiap/petfiap/service/AgendaService.java`)
- Agenda rules → Appointment not found: throws on missing (evidence: `src/main/java/br/com/fiap/petfiap/service/AgendaService.java`)
- Appointment API → Appointment not found: maps not found (evidence: `src/main/java/br/com/fiap/petfiap/controller/AtendimentoController.java`)
