specifica-br 1.2.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -44
- package/dist/boilerplate/commands/executar-task.md +133 -0
- package/dist/boilerplate/commands/gerar-contexto.md +1462 -0
- package/dist/boilerplate/commands/gerar-prd.md +289 -0
- package/dist/boilerplate/commands/gerar-tasks.md +168 -0
- package/dist/boilerplate/commands/gerar-techspec.md +1467 -0
- package/dist/boilerplate/commands/gerar-visao.md +731 -0
- package/dist/boilerplate/commands/realizar-codereview.md +288 -0
- package/dist/boilerplate/opencode-commands/executar-task.md +55 -48
- package/dist/boilerplate/opencode-commands/gerar-contexto.md +1462 -0
- package/dist/boilerplate/opencode-commands/gerar-prd.md +232 -40
- package/dist/boilerplate/opencode-commands/gerar-tasks.md +112 -31
- package/dist/boilerplate/opencode-commands/gerar-techspec.md +1464 -80
- package/dist/boilerplate/opencode-commands/gerar-visao.md +731 -0
- package/dist/boilerplate/opencode-commands/realizar-codereview.md +288 -0
- package/dist/boilerplate/skills/product-manager/SKILL.md +32 -0
- package/dist/boilerplate/skills/techspec-generator/SKILL.md +489 -0
- package/dist/boilerplate/skills/techspec-generator/references/api-contracts.md +421 -0
- package/dist/boilerplate/skills/techspec-generator/references/architecture-patterns.md +316 -0
- package/dist/boilerplate/skills/techspec-generator/references/database-modeling.md +436 -0
- package/dist/boilerplate/skills/techspec-generator/references/observability-testing.md +436 -0
- package/dist/boilerplate/skills/techspec-generator/references/security-hardening.md +238 -0
- package/dist/boilerplate/skills/techspec-generator/references/ux-ui-accessibility.md +511 -0
- package/dist/boilerplate/specs-templates/architecture-template.md +736 -0
- package/dist/boilerplate/specs-templates/codereview-template.md +95 -0
- package/dist/boilerplate/specs-templates/prd-template.md +101 -19
- package/dist/boilerplate/specs-templates/product_vision-template.md +284 -0
- package/dist/boilerplate/specs-templates/task-template.md +64 -18
- package/dist/boilerplate/specs-templates/tasks-template.md +12 -4
- package/dist/boilerplate/specs-templates/techspec-template.md +1227 -89
- package/dist/boilerplate/templates/architecture-template.md +736 -0
- package/dist/boilerplate/templates/codereview-template.md +95 -0
- package/dist/boilerplate/templates/prd-template.md +167 -0
- package/dist/boilerplate/templates/product_vision-template.md +284 -0
- package/dist/boilerplate/templates/task-template.md +169 -0
- package/dist/boilerplate/templates/tasks-template.md +15 -0
- package/dist/boilerplate/templates/techspec-template.md +1306 -0
- package/dist/commands/help.js +33 -11
- package/dist/commands/init.js +39 -43
- package/dist/tools-mapping.json +32 -0
- package/dist/types/init.d.ts +14 -17
- package/dist/utils/file-service.d.ts +5 -3
- package/dist/utils/file-service.js +168 -56
- package/dist/utils/message-formatter.d.ts +2 -1
- package/dist/utils/message-formatter.js +39 -22
- package/package.json +1 -1
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
# ARCHITECTURE DEFINITION
|
|
2
|
+
|
|
3
|
+
**Scope:** Esta definição estabelece os invariantes técnicos do projeto.
|
|
4
|
+
Todas as features futuras devem respeitar estas decisões arquiteturais.
|
|
5
|
+
|
|
6
|
+
| Metadata | Details |
|
|
7
|
+
|:---|:---|
|
|
8
|
+
| **Status** | DRAFT |
|
|
9
|
+
| **Data** | {{DATA_ATUAL}} |
|
|
10
|
+
| **Nível de Profundidade** | {{HIGH_LEVEL|MEDIUM_DETAIL|COMPREHENSIVE}} |
|
|
11
|
+
<!-- Status: DRAFT to IN_PROGRESS to APPROVED -->
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Paradigma Arquitetural
|
|
16
|
+
|
|
17
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
18
|
+
OBJETIVO: Definir o estilo arquitetural fundamental do projeto
|
|
19
|
+
REGRA CRÍTICA: ZERO menções a regras de negócio ou funcionalidades específicas
|
|
20
|
+
-->
|
|
21
|
+
|
|
22
|
+
**Padrão Arquitetural Principal:**
|
|
23
|
+
* [Ex: Clean Architecture, Hexagonal Architecture, Onion Architecture, DDD, Microservices, Monolith]
|
|
24
|
+
|
|
25
|
+
**Justificativa da Escolha:**
|
|
26
|
+
* [Por que este padrão é adequado para o projeto?]
|
|
27
|
+
|
|
28
|
+
**Camadas Arquiteturais (se aplicável):**
|
|
29
|
+
|
|
30
|
+
| Camada | Responsabilidade | Regras de Dependência |
|
|
31
|
+
|:---|:---|:---|
|
|
32
|
+
| **[Nome da Camada 1]** | [O que essa camada faz?] | [Depende de quais camadas?] |
|
|
33
|
+
| **[Nome da Camada 2]** | [O que essa camada faz?] | [Depende de quais camadas?] |
|
|
34
|
+
| **[Nome da Camada 3]** | [O que essa camada faz?] | [Depende de quais camadas?] |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 2. Stack Tecnológico
|
|
39
|
+
|
|
40
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
41
|
+
OBJETIVO: Definir versões específicas de todas as tecnologias
|
|
42
|
+
REGRA: Seja extremamente específico (ex: ".NET 8" não ".NET")
|
|
43
|
+
-->
|
|
44
|
+
|
|
45
|
+
### 2.1. Backend
|
|
46
|
+
|
|
47
|
+
| Categoria | Tecnologia | Versão Específica | Justificativa |
|
|
48
|
+
|:---|:---|:---|:---|
|
|
49
|
+
| **Linguagem** | [Ex: C#, TypeScript, Python] | [Ex: C# 12, Python 3.11] | [Por quê?] |
|
|
50
|
+
| **Framework** | [Ex: ASP.NET Core, Express, FastAPI] | [Ex: 8.0, 4.18] | [Por quê?] |
|
|
51
|
+
| **ORM/Query Builder** | [Ex: Entity Framework, Prisma, Dapper] | [Ex: EF Core 8.0, Prisma 5.0] | [Por quê?] |
|
|
52
|
+
| **Validação** | [Ex: FluentValidation, Zod] | [Versão] | [Por quê?] |
|
|
53
|
+
| **Logging** | [Ex: Serilog, Winston, Pino] | [Versão] | [Por quê?] |
|
|
54
|
+
|
|
55
|
+
### 2.2. Frontend
|
|
56
|
+
|
|
57
|
+
| Categoria | Tecnologia | Versão Específica | Justificativa |
|
|
58
|
+
|:---|:---|:---|:---|
|
|
59
|
+
| **Framework** | [Ex: Vue.js, React, Angular] | [Ex: 3.4, 18.2, 16] | [Por quê?] |
|
|
60
|
+
| **Biblioteca de UI** | [Ex: shadcn-vue, MUI, Chakra] | [Versão] | [Por quê?] |
|
|
61
|
+
| **State Management** | [Ex: Pinia, Redux, Zustand] | [Versão] | [Por quê?] |
|
|
62
|
+
| **Formulários** | [Ex: VeeValidate, React Hook Form] | [Versão] | [Por quê?] |
|
|
63
|
+
| **Build Tool** | [Ex: Vite, Webpack, Turbopack] | [Versão] | [Por quê?] |
|
|
64
|
+
| **CSS Framework** | [Ex: TailwindCSS, Bootstrap] | [Versão] | [Por quê?] |
|
|
65
|
+
|
|
66
|
+
### 2.3. Banco de Dados
|
|
67
|
+
|
|
68
|
+
| Categoria | Tecnologia | Versão Específica | Justificativa |
|
|
69
|
+
|:---|:---|:---|:---|
|
|
70
|
+
| **Tipo** | [Ex: PostgreSQL, MySQL, MongoDB] | [Ex: 15.x, 8.0] | [Por quê?] |
|
|
71
|
+
| **ORM/Driver** | [Ex: Prisma, EF Core, Mongoose] | [Versão] | [Por quê?] |
|
|
72
|
+
| **Migrações** | [Ex: Prisma Migrate, EF Migrations] | [Versão] | [Por quê?] |
|
|
73
|
+
| **Pool de Conexões** | [Ex: PgBouncer, nativo] | [Config] | [Por quê?] |
|
|
74
|
+
|
|
75
|
+
### 2.4. Infraestrutura
|
|
76
|
+
|
|
77
|
+
| Categoria | Tecnologia | Versão Específica | Justificativa |
|
|
78
|
+
|:---|:---|:---|:---|
|
|
79
|
+
| **Cloud Provider** | [Ex: AWS, Azure, GCP, On-premise] | [Região] | [Por quê?] |
|
|
80
|
+
| **Containerização** | [Ex: Docker, Podman] | [Versão] | [Por quê?] |
|
|
81
|
+
| **Orquestração** | [Ex: Kubernetes, Docker Compose] | [Versão] | [Por quê?] |
|
|
82
|
+
| **Mensageria** | [Ex: RabbitMQ, Kafka, SQS] | [Versão] | [Por quê?] |
|
|
83
|
+
| **Cache** | [Ex: Redis, Memcached] | [Versão] | [Por quê?] |
|
|
84
|
+
| **Storage** | [Ex: S3, Azure Blob, MinIO] | [Config] | [Por quê?] |
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 3. Padrões de Design e Convenções
|
|
89
|
+
|
|
90
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
91
|
+
OBJETIVO: Definir como o código deve ser escrito
|
|
92
|
+
REGRA: Seja específico e forneça exemplos quando possível
|
|
93
|
+
-->
|
|
94
|
+
|
|
95
|
+
### 3.1. Convenções de Nomenclatura
|
|
96
|
+
|
|
97
|
+
| Tipo | Convenção | Exemplo |
|
|
98
|
+
|:---|:---|:---|
|
|
99
|
+
| **Classes/Entities** | [Ex: PascalCase] | `UserRepository`, `OrderService` |
|
|
100
|
+
| **Métodos/Funções** | [Ex: PascalCase ou camelCase] | `CreateUser()`, `getUser()` |
|
|
101
|
+
| **Variáveis Locais** | [Ex: camelCase] | `userId`, `orderTotal` |
|
|
102
|
+
| **Constantes** | [Ex: UPPER_SNAKE_CASE] | `MAX_RETRY_COUNT` |
|
|
103
|
+
| **Interfaces** | [Ex: I prefix ou sem sufixo] | `IUserRepository` ou `UserRepository` |
|
|
104
|
+
| **Tabelas (BD)** | [Ex: snake_case plural] | `users`, `order_items` |
|
|
105
|
+
| **Colunas (BD)** | [Ex: snake_case] | `created_at`, `user_id` |
|
|
106
|
+
|
|
107
|
+
### 3.2. Padrões Arquiteturais Específicos
|
|
108
|
+
|
|
109
|
+
**Injeção de Dependência:**
|
|
110
|
+
* [Ex: Constructor injection, Method injection, Property injection]
|
|
111
|
+
* **Exemplo:**
|
|
112
|
+
```csharp
|
|
113
|
+
// Constructor injection (recomendado)
|
|
114
|
+
public class UserService {
|
|
115
|
+
private readonly IUserRepository _repository;
|
|
116
|
+
public UserService(IUserRepository repository) {
|
|
117
|
+
_repository = repository;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Tratamento de Erros:**
|
|
123
|
+
* [Ex: Exceptions, Result types, Either monad]
|
|
124
|
+
* **Convenção:**
|
|
125
|
+
* [Ex: "Lançar domain exception para erros de negócio"]
|
|
126
|
+
* [Ex: "Retornar Result<T> para erros recuperáveis"]
|
|
127
|
+
|
|
128
|
+
**Validação:**
|
|
129
|
+
* [Ex: FluentValidation, Zod, manual decorators]
|
|
130
|
+
* **Onde validar:**
|
|
131
|
+
* [Ex: "Validação de input em controllers/handlers"]
|
|
132
|
+
* [Ex: "Validação de domínio em entities/value objects"]
|
|
133
|
+
|
|
134
|
+
**Logging:**
|
|
135
|
+
* [Ex: Structured logging com Serilog]
|
|
136
|
+
* **Níveis:**
|
|
137
|
+
* [Ex: "DEBUG: detalhes de implementação"]
|
|
138
|
+
* [Ex: "INFO: eventos de negócio importantes"]
|
|
139
|
+
* [Ex: "ERROR: falhas que requerem atenção"]
|
|
140
|
+
* **Campos obrigatórios:**
|
|
141
|
+
* [Ex: "CorrelationId, UserId, Action, ErrorCode"]
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
{{IF MEDIUM_DETAIL OR COMPREHENSIVE}}
|
|
146
|
+
|
|
147
|
+
## 4. Estrutura de Diretórios
|
|
148
|
+
|
|
149
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
150
|
+
OBJETIVO: Definir como o código é organizado no filesystem
|
|
151
|
+
REGRA: Use árvore de diretórios ou lista indentada
|
|
152
|
+
-->
|
|
153
|
+
|
|
154
|
+
### 4.1. Estrutura Backend
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
src/
|
|
158
|
+
├── Domain/ [Entidades e Value Objects]
|
|
159
|
+
│ ├── Entities/ [Entidades de domínio]
|
|
160
|
+
│ ├── ValueObjects/ [Value objects]
|
|
161
|
+
│ └── Events/ [Domain events]
|
|
162
|
+
├── Application/ [Use Cases e Application Logic]
|
|
163
|
+
│ ├── Commands/ [Command CQRS]
|
|
164
|
+
│ ├── Queries/ [Query CQRS]
|
|
165
|
+
│ ├── Handlers/ [Handlers]
|
|
166
|
+
│ └── DTOs/ [Data Transfer Objects]
|
|
167
|
+
├── Infrastructure/ [Implementações concretas]
|
|
168
|
+
│ ├── Persistence/ [Repositories, DB context]
|
|
169
|
+
│ ├── ExternalServices/ [Integrações externas]
|
|
170
|
+
│ └── Messaging/ [Message brokers]
|
|
171
|
+
└── Interface/ [Controllers, APIs, Presenters]
|
|
172
|
+
├── Controllers/ [HTTP endpoints]
|
|
173
|
+
└── Presenters/ [Response formatting]
|
|
174
|
+
tests/
|
|
175
|
+
├── Unit/ [Testes de unidade]
|
|
176
|
+
├── Integration/ [Testes de integração]
|
|
177
|
+
└── E2E/ [Testes end-to-end]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 4.2. Estrutura Frontend
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
src/
|
|
184
|
+
├── components/ [Componentes reutilizáveis]
|
|
185
|
+
│ ├── ui/ [Componentes base]
|
|
186
|
+
│ └── features/ [Componentes específicos]
|
|
187
|
+
├── composables/ [Vue Composition API hooks]
|
|
188
|
+
├── stores/ [State management (Pinia)]
|
|
189
|
+
├── router/ [Rotas e navegação]
|
|
190
|
+
├── services/ [API clients, business logic]
|
|
191
|
+
├── utils/ [Helpers, formatters]
|
|
192
|
+
├── types/ [TypeScript types/interfaces]
|
|
193
|
+
└── assets/ [Imagens, fontes, styles globais]
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Regras de Organização:**
|
|
197
|
+
* [ ] **Regra 1:** [Ex: "Features que compartilham código ficam em /shared"]
|
|
198
|
+
* [ ] **Regra 2:** [Ex: "Cada feature tem seu próprio diretório"]
|
|
199
|
+
|
|
200
|
+
{{END_IF}}
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
{{IF MEDIUM_DETAIL OR COMPREHENSIVE}}
|
|
205
|
+
|
|
206
|
+
## 5. Contratos e Interfaces Padrão
|
|
207
|
+
|
|
208
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
209
|
+
OBJETIVO: Definir padrões de APIs e comunicação entre componentes
|
|
210
|
+
-->
|
|
211
|
+
|
|
212
|
+
### 5.1. Contratos de API (REST)
|
|
213
|
+
|
|
214
|
+
**Versionamento:**
|
|
215
|
+
* [Ex: "Versionamento por URL: /api/v1/resource"]
|
|
216
|
+
|
|
217
|
+
**Padrão de Respostas:**
|
|
218
|
+
|
|
219
|
+
**Success Response (200/201):**
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"data": { /* ou [/* array */] },
|
|
223
|
+
"meta": {
|
|
224
|
+
"timestamp": "2024-03-01T10:00:00Z",
|
|
225
|
+
"correlationId": "uuid-v4"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Error Response (4xx/5xx):**
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"error": {
|
|
234
|
+
"code": "ERROR_CODE_ENUM",
|
|
235
|
+
"message": "Human-readable message",
|
|
236
|
+
"details": { /* contexto adicional */ }
|
|
237
|
+
},
|
|
238
|
+
"meta": {
|
|
239
|
+
"timestamp": "2024-03-01T10:00:00Z",
|
|
240
|
+
"correlationId": "uuid-v4"
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Status Codes Padrão:**
|
|
246
|
+
* `200 OK`: [Quando usar?]
|
|
247
|
+
* `201 Created`: [Quando usar?]
|
|
248
|
+
* `204 No Content`: [Quando usar?]
|
|
249
|
+
* `400 Bad Request`: [Quando usar?]
|
|
250
|
+
* `401 Unauthorized`: [Quando usar?]
|
|
251
|
+
* `403 Forbidden`: [Quando usar?]
|
|
252
|
+
* `404 Not Found`: [Quando usar?]
|
|
253
|
+
* `422 Unprocessable Entity`: [Quando usar?]
|
|
254
|
+
* `500 Internal Server Error`: [Quando usar?]
|
|
255
|
+
|
|
256
|
+
### 5.2. Padrões de Mensageria (se aplicável)
|
|
257
|
+
|
|
258
|
+
**Formato de Mensagens:**
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"messageId": "uuid-v4",
|
|
262
|
+
"eventType": "OrderCreated",
|
|
263
|
+
"timestamp": "2024-03-01T10:00:00Z",
|
|
264
|
+
"data": { /* payload do evento */ },
|
|
265
|
+
"metadata": {
|
|
266
|
+
"correlationId": "uuid-v4",
|
|
267
|
+
"causationId": "uuid-v4"
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Convenções de Nomenclatura:**
|
|
273
|
+
* [Ex: "Eventos no passado: OrderCreated, PaymentFailed"]
|
|
274
|
+
* [Ex: "Comandos no imperativo: CreateOrder, ProcessPayment"]
|
|
275
|
+
|
|
276
|
+
**Topics/Queues Padrão:**
|
|
277
|
+
* [Ex: "Events: {Aggregate}.{Action}"]
|
|
278
|
+
* [Ex: "Commands: {Domain}.command.{Action}"]
|
|
279
|
+
|
|
280
|
+
{{END_IF}}
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
{{IF COMPREHENSIVE}}
|
|
285
|
+
|
|
286
|
+
## 6. Pipeline de CI/CD
|
|
287
|
+
|
|
288
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
289
|
+
OBJETIVO: Definir estratégia de integração contínua e deploy
|
|
290
|
+
-->
|
|
291
|
+
|
|
292
|
+
### 6.1. Pipeline de CI
|
|
293
|
+
|
|
294
|
+
**Ferramenta:**
|
|
295
|
+
* [Ex: GitHub Actions, GitLab CI, Azure DevOps]
|
|
296
|
+
|
|
297
|
+
**Estágios Obrigatórios:**
|
|
298
|
+
|
|
299
|
+
| Estágio | O que Faz | Ferramentas |
|
|
300
|
+
|:---|:---|:---|
|
|
301
|
+
| **Lint** | [Validação de código e estilo] | [Ex: ESLint, StyleCop] |
|
|
302
|
+
| **Type Check** | [Validação de tipos estáticos] | [Ex: tsc, csc] |
|
|
303
|
+
| **Unit Tests** | [Testes de unidade] | [Ex: xUnit, Jest] |
|
|
304
|
+
| **Integration Tests** | [Testes de integração] | [Ex: TestContainers] |
|
|
305
|
+
| **Build** | [Compilação e empacotamento] | [Ex: Docker build] |
|
|
306
|
+
| **Security Scan** | [Varredura de vulnerabilidades] | [Ex: Snyk, OWASP] |
|
|
307
|
+
|
|
308
|
+
**Critérios de Sucesso:**
|
|
309
|
+
* [ ] [Ex: "Coverage mínimo: 80%"]
|
|
310
|
+
* [ ] [Ex: "Zero erros de lint"]
|
|
311
|
+
* [ ] [Ex: "Zero vulnerabilidades críticas"]
|
|
312
|
+
|
|
313
|
+
### 6.2. Pipeline de CD
|
|
314
|
+
|
|
315
|
+
**Estratégia de Deploy:**
|
|
316
|
+
* [Ex: "Continuous Delivery: deploy manual em staging, automático em produção"]
|
|
317
|
+
|
|
318
|
+
**Ambientes:**
|
|
319
|
+
|
|
320
|
+
| Ambiente | Propósito | Deploy Trigger | URL |
|
|
321
|
+
|:---|:---|:---|:---|
|
|
322
|
+
| **Development** | [Desenvolvimento local] | [Ex: Docker Compose local] | [localhost] |
|
|
323
|
+
| **Staging** | [Testes de aceitação] | [Ex: Auto em merge em main] | [staging.example.com] |
|
|
324
|
+
| **Production** | [Produção] | [Ex: Manual pós-staging] | [app.example.com] |
|
|
325
|
+
|
|
326
|
+
**Estratégia de Rollback:**
|
|
327
|
+
* [Ex: "Reverter para versão anterior em caso de erro crítico"]
|
|
328
|
+
* [Ex: "Blue-green deployment para zero downtime"]
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## 7. Estratégia de Observabilidade
|
|
333
|
+
|
|
334
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
335
|
+
OBJETIVO: Definir como monitorar e debugar a aplicação em produção
|
|
336
|
+
-->
|
|
337
|
+
|
|
338
|
+
### 7.1. Logging
|
|
339
|
+
|
|
340
|
+
**Ferramenta:**
|
|
341
|
+
* [Ex: Serilog + Elasticsearch/Kibana, CloudWatch]
|
|
342
|
+
|
|
343
|
+
**Estrutura de Log:**
|
|
344
|
+
```json
|
|
345
|
+
{
|
|
346
|
+
"timestamp": "2024-03-01T10:00:00Z",
|
|
347
|
+
"level": "INFO",
|
|
348
|
+
"message": "User created order",
|
|
349
|
+
"context": {
|
|
350
|
+
"userId": "uuid-v4",
|
|
351
|
+
"orderId": "uuid-v4",
|
|
352
|
+
"correlationId": "uuid-v4",
|
|
353
|
+
"action": "CreateOrder"
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Logs Obrigatórios:**
|
|
359
|
+
* [ ] [Ex: "Todo request HTTP com correlationId"]
|
|
360
|
+
* [ ] [Ex: "Todo erro com stack trace e contexto"]
|
|
361
|
+
* [ ] [Ex: "Eventos de negócio críticos"]
|
|
362
|
+
|
|
363
|
+
### 7.2. Métricas
|
|
364
|
+
|
|
365
|
+
**Ferramenta:**
|
|
366
|
+
* [Ex: Prometheus + Grafana, DataDog, CloudWatch]
|
|
367
|
+
|
|
368
|
+
**Métricas Padrão:**
|
|
369
|
+
|
|
370
|
+
| Categoria | Métricas Exemplo |
|
|
371
|
+
|:---|:---|
|
|
372
|
+
| **Application** | [Ex: request_count, request_duration, error_count] |
|
|
373
|
+
| **Business** | [Ex: orders_created, users_registered, payment_success_rate] |
|
|
374
|
+
| **Infrastructure** | [Ex: cpu_usage, memory_usage, disk_io] |
|
|
375
|
+
|
|
376
|
+
**Alertas Configurados:**
|
|
377
|
+
* [ ] [Ex: "Erro rate > 5% em 5min"]
|
|
378
|
+
* [ ] [Ex: "Latência P95 > 1s em 5min"]
|
|
379
|
+
* [ ] [Ex: "CPU > 80% por 10min"]
|
|
380
|
+
|
|
381
|
+
### 7.3. Distributed Tracing
|
|
382
|
+
|
|
383
|
+
**Ferramenta:**
|
|
384
|
+
* [Ex: OpenTelemetry, Jaeger, AWS X-Ray]
|
|
385
|
+
|
|
386
|
+
**O que Traçar:**
|
|
387
|
+
* [ ] [Ex: "Requests HTTP com propagação de contexto"]
|
|
388
|
+
* [ ] [Ex: "Mensagens assíncronas com correlationId"]
|
|
389
|
+
* [ ] [Ex: "Queries de banco de dados lentas"]
|
|
390
|
+
|
|
391
|
+
{{END_IF}}
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## 8. Padrões de Testes
|
|
396
|
+
|
|
397
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
398
|
+
OBJETIVO: Definir estratégia de testes
|
|
399
|
+
-->
|
|
400
|
+
|
|
401
|
+
### 8.1. Pirâmide de Testes
|
|
402
|
+
|
|
403
|
+
| Tipo | Percentual Alvo | Exemplo |
|
|
404
|
+
|:---|:---:|:---|
|
|
405
|
+
| **Unit Tests** | [Ex: 70%] | [Testar handlers, services em isolamento] |
|
|
406
|
+
| **Integration Tests** | [Ex: 20%] | [Testar repositories, APIs externas] |
|
|
407
|
+
| **E2E Tests** | [Ex: 10%] | [Testar fluxos críticos de usuário] |
|
|
408
|
+
|
|
409
|
+
### 8.2. Ferramentas de Teste
|
|
410
|
+
|
|
411
|
+
| Categoria | Ferramenta | Versão |
|
|
412
|
+
|:---|:---|:---|
|
|
413
|
+
| **Framework** | [Ex: xUnit, Jest, Pytest] | [Versão] |
|
|
414
|
+
| **Mocks** | [Ex: Moq, unittest.mock] | [Versão] |
|
|
415
|
+
| **Assertions** | [Ex: FluentAssertions, chai] | [Versão] |
|
|
416
|
+
| **Test Containers** | [Ex: TestContainers, Docker] | [Versão] |
|
|
417
|
+
|
|
418
|
+
### 8.3. Convenções de Testes
|
|
419
|
+
|
|
420
|
+
**Nomenclatura de Testes:**
|
|
421
|
+
* [Ex: "MethodName_Scenario_ExpectedResult"]
|
|
422
|
+
|
|
423
|
+
**Exemplo:**
|
|
424
|
+
```csharp
|
|
425
|
+
[Fact]
|
|
426
|
+
public void CreateOrder_WithValidInput_ReturnsSuccess()
|
|
427
|
+
{
|
|
428
|
+
// Arrange
|
|
429
|
+
// Act
|
|
430
|
+
// Assert
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Setup/Teardown:**
|
|
435
|
+
* [Ex: "Usar fixtures para setup comum"]
|
|
436
|
+
* [Ex: "Cada teste deve ser independente"]
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## 9. Segurança
|
|
441
|
+
|
|
442
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
443
|
+
OBJETIVO: Definir padrões de segurança
|
|
444
|
+
-->
|
|
445
|
+
|
|
446
|
+
### 9.1. Autenticação e Autorização
|
|
447
|
+
|
|
448
|
+
**Autenticação:**
|
|
449
|
+
* [Ex: "JWT com refresh tokens"]
|
|
450
|
+
* [Ex: "OAuth 2.0 / OpenID Connect"]
|
|
451
|
+
|
|
452
|
+
**Autorização:**
|
|
453
|
+
* [Ex: "Role-based access control (RBAC)"]
|
|
454
|
+
* [Ex: "Claims-based authorization"]
|
|
455
|
+
|
|
456
|
+
**Escopos de Acesso:**
|
|
457
|
+
* [ ] [Ex: "Admin: acesso total"]
|
|
458
|
+
* [ ] [Ex: "User: acesso aos próprios recursos"]
|
|
459
|
+
* [ ] [Ex: "Guest: acesso somente leitura"]
|
|
460
|
+
|
|
461
|
+
### 9.2. Proteção de Dados
|
|
462
|
+
|
|
463
|
+
**Dados Sensíveis:**
|
|
464
|
+
* [Ex: "Senhas hasheadas com Argon2id"]
|
|
465
|
+
* [Ex: "PII criptografado em repouso (AES-256)"]
|
|
466
|
+
* [Ex: "Logs não podem conter dados sensíveis"]
|
|
467
|
+
|
|
468
|
+
**Comunicação:**
|
|
469
|
+
* [Ex: "HTTPS obrigatório em todos os ambientes"]
|
|
470
|
+
* [Ex: "TLS 1.3+"]
|
|
471
|
+
|
|
472
|
+
### 9.3. Validação de Input
|
|
473
|
+
|
|
474
|
+
**Regras Padrão:**
|
|
475
|
+
* [ ] [Ex: "Validar tipo, tamanho e formato de todo input"]
|
|
476
|
+
* [ ] [Ex: "Sanitizar HTML para prevenir XSS"]
|
|
477
|
+
* [ ] [Ex: "Parametrizar queries para prevenir SQL injection"]
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## 10. Governança e Convenções de Repositório
|
|
482
|
+
|
|
483
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
484
|
+
OBJETIVO: Definir como o time trabalha com o repositório
|
|
485
|
+
-->
|
|
486
|
+
|
|
487
|
+
### 10.1. Estrutura de Branches
|
|
488
|
+
|
|
489
|
+
| Branch | Propósito | Regras |
|
|
490
|
+
|:---|:---|:---|
|
|
491
|
+
| **main** | [Produção] | [Ex: Protegido, requer PR + aprovação] |
|
|
492
|
+
| **develop** | [Integração] | [Ex: Deploy automático em staging] |
|
|
493
|
+
| **feature/*** | [Novas features] | [Ex: Criar a partir de develop] |
|
|
494
|
+
|
|
495
|
+
### 10.2. Padrões de Commit
|
|
496
|
+
|
|
497
|
+
**Convenção:**
|
|
498
|
+
* [Ex: "Conventional Commits: type(scope): description"]
|
|
499
|
+
|
|
500
|
+
**Tipos de Commit:**
|
|
501
|
+
* `feat`: Nova funcionalidade
|
|
502
|
+
* `fix`: Bug fix
|
|
503
|
+
* `refactor`: Refatoração
|
|
504
|
+
* `test`: Adicionar/atualizar testes
|
|
505
|
+
* `docs`: Documentação
|
|
506
|
+
* `chore`: Manutenção
|
|
507
|
+
|
|
508
|
+
**Exemplo:**
|
|
509
|
+
```
|
|
510
|
+
feat(auth): implement JWT token refresh
|
|
511
|
+
|
|
512
|
+
- Add refresh token endpoint
|
|
513
|
+
- Update token validation logic
|
|
514
|
+
- Add integration tests
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### 10.3. Pull Request Guidelines
|
|
518
|
+
|
|
519
|
+
**Template de PR:**
|
|
520
|
+
```markdown
|
|
521
|
+
## Descrição
|
|
522
|
+
[Breve descrição da mudança]
|
|
523
|
+
|
|
524
|
+
## Tipo de Mudança
|
|
525
|
+
- [ ] Bug fix
|
|
526
|
+
- [ ] Feature
|
|
527
|
+
- [ ] Breaking change
|
|
528
|
+
- [ ] Refatoração
|
|
529
|
+
|
|
530
|
+
## Testing
|
|
531
|
+
- [ ] Unit tests
|
|
532
|
+
- [ ] Integration tests
|
|
533
|
+
- [ ] Manual testing
|
|
534
|
+
|
|
535
|
+
## Checklist
|
|
536
|
+
- [ ] Código segue convenções
|
|
537
|
+
- [ ] Tests passando
|
|
538
|
+
- [ ] Documentação atualizada
|
|
539
|
+
- [ ] Sem conflitos de merge
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
**Critérios de Aprovação:**
|
|
543
|
+
* [ ] [Ex: "Pelo menos 1 approval de senior dev"]
|
|
544
|
+
* [ ] [Ex: "CI passando"]
|
|
545
|
+
* [ ] [Ex: "Coverage não diminuiu"]
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
## 11. Não-Goals (O que NÃO faremos)
|
|
550
|
+
|
|
551
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
552
|
+
OBJETIVO: Explicitar escolhas arquiteturais que foram deliberadamente excluídas
|
|
553
|
+
-->
|
|
554
|
+
|
|
555
|
+
**Tecnologias/Abordagens Excluídas:**
|
|
556
|
+
|
|
557
|
+
| Tecnologia/Abordagem | Por que NÃO usar? |
|
|
558
|
+
|:---|:---|
|
|
559
|
+
| **[Ex: MongoDB]** | [Ex: "Requerimentos de consistência transacional forte"] |
|
|
560
|
+
| **[Ex: Microservices]** | [Ex: "Projeto inicial, complexidade não justificada"] |
|
|
561
|
+
| **[Ex: GraphQL]** | [Ex: "Time não tem experiência, REST é suficiente"] |
|
|
562
|
+
|
|
563
|
+
**Anti-Padrões Proibidos:**
|
|
564
|
+
* [ ] [Ex: "NUNCA misturar camadas (ex: domain chamando infrastructure)"]
|
|
565
|
+
* [ ] [Ex: "NUNCA retornar entidades de domínio direto da API"]
|
|
566
|
+
* [ ] [Ex: "NUNCA fazer lógica de negócio em controllers"]
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
## 12. Integrações Externas
|
|
571
|
+
|
|
572
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
573
|
+
OBJETIVO: Mapear APIs de terceiros, serviços e dependências externas
|
|
574
|
+
REGRA: Documentar tipo, versão, autenticação e uso no sistema
|
|
575
|
+
-->
|
|
576
|
+
|
|
577
|
+
### 12.1. APIs de Terceiros
|
|
578
|
+
|
|
579
|
+
| Serviço | Tipo | Versão | Autenticação | Rate Limit | Observações |
|
|
580
|
+
|:---|:---|:---|:---|:---|:---|
|
|
581
|
+
| **[Ex: Stripe]** | [Payment] | [v2023-10-01] | [API Key Secret] | [100 req/min] | [Webhooks em /api/webhooks/stripe] |
|
|
582
|
+
| **[Ex: SendGrid]** | [Email] | [v7.7] | [API Key] | [Sem limite] | [Templates transactionais] |
|
|
583
|
+
| **[AWS S3]** | [Storage] | [v3.450] | [Access Key + Secret] | [N/A] | [Presigned URLs para uploads] |
|
|
584
|
+
|
|
585
|
+
### 12.2. Webhooks e Callbacks
|
|
586
|
+
|
|
587
|
+
| Webhook | Fonte | Endpoint | Eventos | Segurança |
|
|
588
|
+
|:---|:---|:---|:---|:---|
|
|
589
|
+
| **[Ex: Stripe]** | [Stripe Dashboard] | [/api/webhooks/stripe] | [payment_intent.succeeded, payment_intent.failed] | [Signature verification] |
|
|
590
|
+
| **[Ex: GitHub]** | [GitHub App] | [/api/webhooks/github] | [push, pull_request] | [HMAC SHA256] |
|
|
591
|
+
|
|
592
|
+
### 12.3. Rate Limiting e Retries
|
|
593
|
+
|
|
594
|
+
| Serviço | Rate Limit | Retry Strategy | Backoff | Circuit Breaker |
|
|
595
|
+
|:---|:---|:---|:---|:---|
|
|
596
|
+
| **[Ex: Stripe API]** | [100 req/min] | [3 retries] | [Exponential: 1s, 2s, 4s] | [Sim: opossum] |
|
|
597
|
+
| **[Ex: Redis]** | [10.000 req/min] | [Não aplicável] | [Não aplicável] | [Não] |
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
601
|
+
## 13. Maturidade de Testes
|
|
602
|
+
|
|
603
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
604
|
+
OBJETIVO: Avaliar qualidade e cobertura de testes existentes
|
|
605
|
+
-->
|
|
606
|
+
|
|
607
|
+
### 13.1. Framework de Testes
|
|
608
|
+
|
|
609
|
+
| Categoria | Framework | Versão | Configuração |
|
|
610
|
+
|:---|:---|:---|:---|
|
|
611
|
+
| **Framework Principal** | [Ex: Jest] | [v29.7] | [jest.config.js] |
|
|
612
|
+
| **Assertion Library** | [Ex: Testing Library] | [v5.1] | [@testing-library/dom] |
|
|
613
|
+
| **Mocks/Fixtures** | [Ex: Faker.js] | [v8.4] | [__tests__/fixtures] |
|
|
614
|
+
| **Coverage Tool** | [Ex: Istanbul/nyc] | [Built-in] | [coverageThreshold: 70%] |
|
|
615
|
+
|
|
616
|
+
### 13.2. Tipos de Testes
|
|
617
|
+
|
|
618
|
+
| Tipo | Percentual Alvo | Localização | Observações |
|
|
619
|
+
|:---|:---:|:---|:---|
|
|
620
|
+
| **Unit Tests** | [70%] | [/tests/unit/] | [Testam handlers, services em isolamento] |
|
|
621
|
+
| **Integration Tests** | [20%] | [/tests/integration/] | [Testam repositories, APIs externas] |
|
|
622
|
+
| **E2E Tests** | [10%] | [/tests/e2e/, cypress/] | [Testam fluxos críticos de usuário] |
|
|
623
|
+
|
|
624
|
+
### 13.3. Métricas de Cobertura
|
|
625
|
+
|
|
626
|
+
| Métrica | Valor Atual | Meta | Status |
|
|
627
|
+
|:---|:---|:---|:---:|
|
|
628
|
+
| **Statements** | [62%] | [80%] | [[WARNING] Abaixo da meta] |
|
|
629
|
+
| **Branches** | [54%] | [80%] | [[X] Crítico] |
|
|
630
|
+
| **Functions** | [65%] | [80%] | [[WARNING] Abaixo da meta] |
|
|
631
|
+
| **Lines** | [62%] | [80%] | [[WARNING] Abaixo da meta] |
|
|
632
|
+
|
|
633
|
+
### 13.4. Nível de Maturidade
|
|
634
|
+
|
|
635
|
+
**Classificação:**
|
|
636
|
+
- [ ] **BÁSICO** - Framework configurado, poucos testes
|
|
637
|
+
- [ ] **INTERMEDIÁRIO** - Framework + unit + integration, cobertura parcial
|
|
638
|
+
- [ ] **AVANÇADO** - Framework + todos os tipos, cobertura alta (>80%)
|
|
639
|
+
|
|
640
|
+
**Status Atual:** [INTERMEDIÁRIO]
|
|
641
|
+
```
|
|
642
|
+
[OK] Framework configurado (Jest v29.7)
|
|
643
|
+
[OK] Testes de unidade presentes (/tests/unit)
|
|
644
|
+
[OK] Testes de integração presentes (/tests/integration)
|
|
645
|
+
[WARNING] Coverage abaixo de 70% (atual: 62%)
|
|
646
|
+
[X] Ausência de testes E2E completos
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
---
|
|
650
|
+
|
|
651
|
+
## 14. Domínio Inferido (DDD)
|
|
652
|
+
|
|
653
|
+
<!-- INSTRUÇÕES DE PREENCHIMENTO:
|
|
654
|
+
OBJETIVO: Documentar elementos de Domain-Driven Design detectados no código
|
|
655
|
+
REGRA: Atribuir níveis de confiança a cada inferência
|
|
656
|
+
-->
|
|
657
|
+
|
|
658
|
+
### 14.1. Bounded Contexts
|
|
659
|
+
|
|
660
|
+
| Contexto | Confiança | Descrição | Aggregates |
|
|
661
|
+
|:---|:---:|:---|:---|
|
|
662
|
+
| **[Users]** | [85%] | [Gestão de usuários e autenticação] | [User] |
|
|
663
|
+
| **[Orders]** | [72%] | [Ciclo de vida de pedidos] | [Order, OrderItem] |
|
|
664
|
+
| **[Payments]** | [40%] | [Processamento de pagamentos] | [Payment - anêmico] |
|
|
665
|
+
|
|
666
|
+
### 14.2. Aggregates e Entities
|
|
667
|
+
|
|
668
|
+
| Aggregate | Confiança | Root Entity | Value Objects | Invariants |
|
|
669
|
+
|:---|:---:|:---|:---|:---|
|
|
670
|
+
| **[User]** | [90%] | [User] | [Email, CPF] | [Email único, CPF válido] |
|
|
671
|
+
| **[Order]** | [85%] | [Order] | [Money, Address] | [Total > 0, Status transitions válidas] |
|
|
672
|
+
| **[Payment]** | [50%] | [Payment] | [CardNumber] | [Pouca lógica de domínio] |
|
|
673
|
+
|
|
674
|
+
### 14.3. Value Objects
|
|
675
|
+
|
|
676
|
+
| Value Object | Confiança | Tipo | Imutável | Observações |
|
|
677
|
+
|:---|:---:|:---|:---:|:---|
|
|
678
|
+
| **[Email]** | [95%] | [record C#] | [[OK]] | [Validação de formato] |
|
|
679
|
+
| **[CPF]** | [88%] | [record C#] | [[OK]] | [Validação de dígito] |
|
|
680
|
+
| **[Money]** | [N/A] | [decimal] | [[X]] | [Usa decimal simples] |
|
|
681
|
+
| **[Address]** | [70%] | [class] | [[X]] | [Deveria ser imutável] |
|
|
682
|
+
|
|
683
|
+
### 14.4. Domain Events
|
|
684
|
+
|
|
685
|
+
| Evento | Confiança | Dispatcher | Handler | Quando Ocorre |
|
|
686
|
+
|:---|:---:|:---|:---|:---|
|
|
687
|
+
| **[UserCreated]** | [80%] | [MediatR] | [SendWelcomeEmail] | [Após registro bem-sucedido] |
|
|
688
|
+
| **[OrderPaid]** | [82%] | [MediatR] | [UpdateOrderStatus] | [Após confirmação do Stripe] |
|
|
689
|
+
|
|
690
|
+
### 14.5. Repositories
|
|
691
|
+
|
|
692
|
+
| Repository | Confiança | Implementação | ORM | Observações |
|
|
693
|
+
|:---|:---:|:---|:---|:---|
|
|
694
|
+
| **[IUserRepository]** | [92%] | [DapperUserRepository] | [Dapper] | [Interface em Domain] |
|
|
695
|
+
| **[IOrderRepository]** | [92%] | [DapperOrderRepository] | [Dapper] | [Interface em Domain] |
|
|
696
|
+
| **[IPaymentRepository]** | [40%] | [Não implementada] | [N/A] | [Apenas interface] |
|
|
697
|
+
|
|
698
|
+
### 14.6. Nível de Maturidade DDD
|
|
699
|
+
|
|
700
|
+
**Classificação:**
|
|
701
|
+
- [ ] **INICIANTE** - Poucos elementos DDD, código anêmico
|
|
702
|
+
- [ ] **INTERMEDIÁRIO** - Bounded contexts, aggregates, events parciais
|
|
703
|
+
- [ ] **AVANÇADO** - DDD completo com todos os elementos
|
|
704
|
+
|
|
705
|
+
**Status Atual:** [INTERMEDIÁRIO]
|
|
706
|
+
```
|
|
707
|
+
[OK] Bounded contexts definidos (Users, Orders, Payments)
|
|
708
|
+
[OK] Aggregates e entities identificadas
|
|
709
|
+
[WARNING] Value_objects parciais (nem todos imutáveis)
|
|
710
|
+
[OK] Domain events implementados via MediatR
|
|
711
|
+
[OK] Repositories pattern aplicado
|
|
712
|
+
[WARNING] Alguns serviços de domínio em camada errada
|
|
713
|
+
[X] Faltam: Specifications, Domain Services explícitos
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
---
|
|
717
|
+
|
|
718
|
+
**Notas de Decisão:**
|
|
719
|
+
<!--
|
|
720
|
+
Documente aqui decisões técnicas importantes e o porquê.
|
|
721
|
+
Exemplo: "Escolhemos Prisma sobre TypeORM porque type-safety é prioridade"
|
|
722
|
+
-->
|
|
723
|
+
|
|
724
|
+
---
|
|
725
|
+
|
|
726
|
+
**Validação de Qualidade (Zero-Business Check):**
|
|
727
|
+
- [ ] Zero menções a funcionalidades específicas do produto
|
|
728
|
+
- [ ] Zero menções a regras de negócio ou user stories
|
|
729
|
+
- [ ] Zero menções a personas ou comportamentos de usuário
|
|
730
|
+
- [ ] Todo conteúdo focado em decisões técnicas e implementação
|
|
731
|
+
- [ ] Versões específicas definidas para todas as tecnologias
|
|
732
|
+
|
|
733
|
+
---
|
|
734
|
+
|
|
735
|
+
**Template Version:** 0.2.0
|
|
736
|
+
**Command:** `/gerar-visao` - Fase Técnica | `/gerar-contexto` - Brownfield Analysis
|