BFF Pattern
Seu melhor amigo backend
Engenharia de Software - FIB
Desenvolvedor - Finch Soluções
Helder Traci
O que é
BFF?
O que é BFF?
- Backend For Frontend
- Pattern
- Phil Calçado
O que é BFF?
- Motivação
- Uso de API genérica
- Responsabilidades nas UIs
- Desorganização entre times
O que é BFF?

API backend genérica
API backend genérica

API backend genérica
- Diferentes necessidades e limitações


API backend genérica
- Separação entre times

Time A
Time B
Time C
API backend genérica
- Alterações centralizadas


X
API backend genérica
- Novas UIs





O pattern BFF
O pattern BFF
- Foco específico

O pattern BFF
- Conversões
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML
{
"note": {
"to": "Tove",
"from": "Jani",
"heading": "Reminder",
"body": "Don't forget me this weekend!"
}
}
JSON
O pattern BFF
- Response limpo
{
"contentDetails": {
"duration": "PT4M39S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": true,
"projection": "rectangular"
}
}
{
"contentDetails": {
"duration": "PT4M39S"
}
}
O pattern BFF
- Response limpo
{
"thumbnails": {
"default": {
"url": "https://i.com/ok9spOX0iaE/default.jpg",
"width": 120,
"height": 90
},
"medium": { ... },
"high": { ... },
"standard": { ... },
"maxres": { ... }
}
}
{
"thumbnail": {
"url": "https://i.com/ok9spOX0iaE/sddefault.jpg",
"width": 640,
"height": 480
}
}
O pattern BFF
- Padrões
{
"url": "maxResults=12&q=bff&pageToken=CAwQAA"
}
{
"url": "size=10&search=bff&page=0"
}
O pattern BFF
- Responsabilidade
- Construção de objetos
- Unificação de requests
O pattern BFF

Quantos BFFs?
Quantos BFFs?
- One UI, one BFF

Quantos BFFs?
- Times completos

Time A
Time B
Time C
Time D
Quantos BFFs?
- Reutilização de um BFF

Quantos BFFs?
- Estrutura dos BFFs

Múltiplos serviços
Múltiplos serviços
- Padrão essencial

Reuso e BFF
Reuso e BFF
- Duplicidade de código
- Abordagens
- biblioteca compartilhada
- novo serviço
- unificação de serviço
- Evite generalização prematura

Reuso e BFF
- Evolução do BFF

Sobre autonomia
Sobre autonomia
- Velocidade no desenvolvimento
- Auto-gerenciável
- Toma as próprias decisões
Quando utilizar
Quando utilizar
- Interfaces distintas (muitos dispositivos)
- Muitos serviços
- Agregação no lado do servidor
- Chamadas a serviços distintos
- API genérica complexa
Quando não utilizar
Quando não utilizar
- Times pequenos e especialistas
- Suporte para poucos dispositivos (foco específico)
- Quando não quer
E mais...
E mais...
- Trial no RADAR da ThoughtWorks (2015/2016)
- Cases
- SoundCloud
- SporTV
- Microservices.io
- Bluemix Developer Console – BFF (Backend for Frontend) Pattern
Dúvidas?












Obrigado!






https://helderdiin.github.io/
https://github.com/helderdiin
@Helderdiin