@maestro-ai/mcp-server 5.7.0 → 6.1.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.
Files changed (158) hide show
  1. package/dist/analyzers/security-analyzer.js +1 -1
  2. package/dist/analyzers/security-analyzer.js.map +1 -1
  3. package/dist/constants.d.ts +1 -1
  4. package/dist/constants.js +1 -1
  5. package/dist/content/skills/specialist-api-contract/SKILL.md +98 -0
  6. package/dist/content/skills/specialist-api-contract/resources/checklists/gate-checklist.md +38 -0
  7. package/dist/content/skills/specialist-api-contract/resources/reference/guide.md +109 -0
  8. package/dist/content/skills/specialist-architect/SKILL.md +111 -0
  9. package/dist/content/skills/specialist-architect/resources/checklists/gate-checklist.md +45 -0
  10. package/dist/content/skills/specialist-architect/resources/examples/example-architecture.md +345 -0
  11. package/dist/content/skills/specialist-architect/resources/reference/guide.md +86 -0
  12. package/dist/content/skills/specialist-architect/resources/templates/arquitetura.md +282 -0
  13. package/dist/content/skills/specialist-backend/SKILL.md +100 -0
  14. package/dist/content/skills/specialist-backend/resources/checklists/gate-checklist.md +38 -0
  15. package/dist/content/skills/specialist-backend/resources/reference/guide.md +160 -0
  16. package/dist/content/skills/specialist-design/SKILL.md +107 -0
  17. package/dist/content/skills/specialist-design/resources/checklists/gate-checklist.md +45 -0
  18. package/dist/content/skills/specialist-design/resources/examples/example-design.md +294 -0
  19. package/dist/content/skills/specialist-design/resources/reference/guide.md +67 -0
  20. package/dist/content/skills/specialist-design/resources/templates/design-doc.md +232 -0
  21. package/dist/content/skills/specialist-devops/SKILL.md +99 -0
  22. package/dist/content/skills/specialist-devops/resources/checklists/gate-checklist.md +38 -0
  23. package/dist/content/skills/specialist-devops/resources/reference/guide.md +116 -0
  24. package/dist/content/skills/specialist-discovery/SKILL.md +109 -0
  25. package/dist/content/skills/specialist-discovery/resources/checklists/gate-checklist.md +45 -0
  26. package/dist/content/skills/specialist-discovery/resources/examples/example-discovery.md +179 -0
  27. package/dist/content/skills/specialist-discovery/resources/reference/guide.md +48 -0
  28. package/dist/content/skills/specialist-discovery/resources/templates/discovery.md +187 -0
  29. package/dist/content/skills/specialist-domain/SKILL.md +105 -0
  30. package/dist/content/skills/specialist-domain/resources/checklists/gate-checklist.md +37 -0
  31. package/dist/content/skills/specialist-domain/resources/reference/guide.md +80 -0
  32. package/dist/content/skills/specialist-frontend/SKILL.md +99 -0
  33. package/dist/content/skills/specialist-frontend/resources/checklists/gate-checklist.md +38 -0
  34. package/dist/content/skills/specialist-frontend/resources/reference/guide.md +90 -0
  35. package/dist/content/skills/specialist-operations/SKILL.md +109 -0
  36. package/dist/content/skills/specialist-operations/resources/checklists/gate-checklist.md +38 -0
  37. package/dist/content/skills/specialist-operations/resources/reference/guide.md +129 -0
  38. package/dist/content/skills/specialist-planning/SKILL.md +100 -0
  39. package/dist/content/skills/specialist-planning/resources/checklists/gate-checklist.md +38 -0
  40. package/dist/content/skills/specialist-planning/resources/reference/guide.md +88 -0
  41. package/dist/content/skills/specialist-product/SKILL.md +113 -0
  42. package/dist/content/skills/specialist-product/resources/checklists/gate-checklist.md +40 -0
  43. package/dist/content/skills/specialist-product/resources/reference/guide.md +43 -0
  44. package/dist/content/skills/specialist-product/resources/templates/PRD.md +191 -0
  45. package/dist/content/skills/specialist-requirements/SKILL.md +107 -0
  46. package/dist/content/skills/specialist-requirements/resources/checklists/gate-checklist.md +36 -0
  47. package/dist/content/skills/specialist-requirements/resources/reference/guide.md +66 -0
  48. package/dist/content/skills/specialist-technical-design/SKILL.md +114 -0
  49. package/dist/content/skills/specialist-technical-design/resources/checklists/gate-checklist.md +38 -0
  50. package/dist/content/skills/specialist-technical-design/resources/reference/guide.md +86 -0
  51. package/dist/core/adr/ADRGenerator.js +2 -2
  52. package/dist/core/adr/ADRGenerator.js.map +1 -1
  53. package/dist/core/architecture/FitnessFunctions.js +2 -2
  54. package/dist/core/architecture/FitnessFunctions.js.map +1 -1
  55. package/dist/core/atam/ATAMAnalyzer.js +6 -6
  56. package/dist/core/atam/ATAMAnalyzer.js.map +1 -1
  57. package/dist/core/atam/ATAMReporter.js +2 -2
  58. package/dist/core/atam/ATAMReporter.js.map +1 -1
  59. package/dist/core/atam/QualityScenarios.js +1 -1
  60. package/dist/core/atam/QualityScenarios.js.map +1 -1
  61. package/dist/core/atam/RiskRegistry.js +5 -5
  62. package/dist/core/atam/RiskRegistry.js.map +1 -1
  63. package/dist/core/authority/AuthorityManager.js +3 -3
  64. package/dist/core/authority/AuthorityManager.js.map +1 -1
  65. package/dist/core/automation/AutoExecutor.js +2 -2
  66. package/dist/core/automation/AutoExecutor.js.map +1 -1
  67. package/dist/core/consistency/ConsistencyAnalyzer.js +2 -2
  68. package/dist/core/consistency/ConsistencyAnalyzer.js.map +1 -1
  69. package/dist/core/context/ContextDetector.js +2 -2
  70. package/dist/core/context/ContextDetector.js.map +1 -1
  71. package/dist/core/decision/AlternativeGenerator.js +1 -1
  72. package/dist/core/decision/AlternativeGenerator.js.map +1 -1
  73. package/dist/core/decision/ConfidenceCalculator.js +5 -5
  74. package/dist/core/decision/ConfidenceCalculator.js.map +1 -1
  75. package/dist/core/decision/DecisionEngine.js +6 -6
  76. package/dist/core/decision/DecisionEngine.js.map +1 -1
  77. package/dist/core/decision/DecisionMatrix.js +1 -1
  78. package/dist/core/decision/DecisionMatrix.js.map +1 -1
  79. package/dist/core/feedback/FeedbackLoop.js +1 -1
  80. package/dist/core/feedback/FeedbackLoop.js.map +1 -1
  81. package/dist/core/growth/GrowthProjector.js +2 -2
  82. package/dist/core/growth/GrowthProjector.js.map +1 -1
  83. package/dist/core/impact/ImpactAnalyzer.js +1 -1
  84. package/dist/core/impact/ImpactAnalyzer.js.map +1 -1
  85. package/dist/core/notification/NotificationManager.js +2 -2
  86. package/dist/core/notification/NotificationManager.js.map +1 -1
  87. package/dist/core/roadmap/RoadmapManager.js +3 -3
  88. package/dist/core/roadmap/RoadmapManager.js.map +1 -1
  89. package/dist/core/strangler/StranglerOrchestrator.js +6 -6
  90. package/dist/core/strangler/StranglerOrchestrator.js.map +1 -1
  91. package/dist/core/testing/TestRunner.js +2 -2
  92. package/dist/core/testing/TestRunner.js.map +1 -1
  93. package/dist/core/tradeoff/TradeoffAnalyzer.js +1 -1
  94. package/dist/core/tradeoff/TradeoffAnalyzer.js.map +1 -1
  95. package/dist/core/validation/ValidationPipeline.js +5 -5
  96. package/dist/core/validation/ValidationPipeline.js.map +1 -1
  97. package/dist/flows/types.d.ts +13 -8
  98. package/dist/flows/types.d.ts.map +1 -1
  99. package/dist/flows/types.js +256 -324
  100. package/dist/flows/types.js.map +1 -1
  101. package/dist/gates/readiness-gate.d.ts +48 -0
  102. package/dist/gates/readiness-gate.d.ts.map +1 -0
  103. package/dist/gates/readiness-gate.js +301 -0
  104. package/dist/gates/readiness-gate.js.map +1 -0
  105. package/dist/handlers/code-phase-handler.js +14 -7
  106. package/dist/handlers/code-phase-handler.js.map +1 -1
  107. package/dist/handlers/specialist-phase-handler.d.ts +11 -10
  108. package/dist/handlers/specialist-phase-handler.d.ts.map +1 -1
  109. package/dist/handlers/specialist-phase-handler.js +160 -64
  110. package/dist/handlers/specialist-phase-handler.js.map +1 -1
  111. package/dist/middleware/adr-generation.middleware.js +2 -2
  112. package/dist/middleware/adr-generation.middleware.js.map +1 -1
  113. package/dist/middleware/orchestration-pipeline.middleware.d.ts.map +1 -1
  114. package/dist/middleware/orchestration-pipeline.middleware.js +0 -3
  115. package/dist/middleware/orchestration-pipeline.middleware.js.map +1 -1
  116. package/dist/services/deliverable-gate.service.js +1 -1
  117. package/dist/services/deliverable-gate.service.js.map +1 -1
  118. package/dist/services/phase-config-loader.d.ts +28 -0
  119. package/dist/services/phase-config-loader.d.ts.map +1 -0
  120. package/dist/services/phase-config-loader.js +200 -0
  121. package/dist/services/phase-config-loader.js.map +1 -0
  122. package/dist/services/scoring-config.d.ts.map +1 -1
  123. package/dist/services/scoring-config.js +13 -10
  124. package/dist/services/scoring-config.js.map +1 -1
  125. package/dist/services/watcher.service.js +3 -3
  126. package/dist/services/watcher.service.js.map +1 -1
  127. package/dist/tools/consolidated/avancar.d.ts.map +1 -1
  128. package/dist/tools/consolidated/avancar.js +86 -5
  129. package/dist/tools/consolidated/avancar.js.map +1 -1
  130. package/dist/tools/iniciar-projeto.d.ts.map +1 -1
  131. package/dist/tools/iniciar-projeto.js +46 -0
  132. package/dist/tools/iniciar-projeto.js.map +1 -1
  133. package/dist/tools/proximo.d.ts +1 -0
  134. package/dist/tools/proximo.d.ts.map +1 -1
  135. package/dist/tools/proximo.js +44 -30
  136. package/dist/tools/proximo.js.map +1 -1
  137. package/dist/types/index.d.ts +2 -0
  138. package/dist/types/index.d.ts.map +1 -1
  139. package/dist/types/index.js.map +1 -1
  140. package/dist/types/phase-config.d.ts +65 -0
  141. package/dist/types/phase-config.d.ts.map +1 -0
  142. package/dist/types/phase-config.js +11 -0
  143. package/dist/types/phase-config.js.map +1 -0
  144. package/dist/utils/gate-orientation.js +1 -1
  145. package/dist/utils/gate-orientation.js.map +1 -1
  146. package/dist/utils/migration-v10.d.ts +31 -0
  147. package/dist/utils/migration-v10.d.ts.map +1 -0
  148. package/dist/utils/migration-v10.js +145 -0
  149. package/dist/utils/migration-v10.js.map +1 -0
  150. package/dist/utils/prompt-mapper.d.ts +6 -2
  151. package/dist/utils/prompt-mapper.d.ts.map +1 -1
  152. package/dist/utils/prompt-mapper.js +72 -91
  153. package/dist/utils/prompt-mapper.js.map +1 -1
  154. package/dist/utils/skill-deployer.d.ts +32 -0
  155. package/dist/utils/skill-deployer.d.ts.map +1 -0
  156. package/dist/utils/skill-deployer.js +150 -0
  157. package/dist/utils/skill-deployer.js.map +1 -0
  158. package/package.json +2 -2
@@ -0,0 +1,345 @@
1
+ # Arquitetura — TaskFlow
2
+
3
+ > **Fase:** 3 · Arquitetura
4
+ > **Data:** 2026-03-01
5
+ > **Status:** Aprovado
6
+ > **Base:** Discovery + Design Doc
7
+
8
+ ---
9
+
10
+ ## 1. Sumário Executivo
11
+
12
+ TaskFlow é um SaaS monolítico usando Next.js 14 (frontend SSR) + Node.js/Express (API REST) + PostgreSQL 16, hospedado na Vercel (frontend) + Railway (backend + banco). Autenticação via JWT com refresh tokens + Google OAuth. Arquitetura limpa com separação API → Services → Repositories. Decisão por monolito justificada pelo tamanho do time (1-2 devs) e escopo do MVP.
13
+
14
+ ---
15
+
16
+ ## 2. Stack Tecnológica
17
+
18
+ ### 2.1 Frontend
19
+
20
+ | Tecnologia | Versão | Justificativa |
21
+ |-----------|--------|---------------|
22
+ | Next.js | 14.x | App Router, Server Components para SEO, ISR para performance |
23
+ | TypeScript | 5.x | Type-safety end-to-end com Prisma + Zod |
24
+ | Tailwind CSS | 3.x | Utility-first, consistente com design system, sem CSS custom |
25
+ | shadcn/ui | latest | Componentes acessíveis (Radix), customizáveis, sem vendor lock-in |
26
+ | Zustand | 4.x | State management simples — 1 store por domínio, sem boilerplate |
27
+ | React Query | 5.x | Cache de dados do servidor, refetch automático, optimistic updates |
28
+
29
+ ### 2.2 Backend
30
+
31
+ | Tecnologia | Versão | Justificativa |
32
+ |-----------|--------|---------------|
33
+ | Node.js | 20 LTS | Mesmo ecossistema do frontend, async I/O nativo, LTS até 2026 |
34
+ | Express | 4.x | Maduro, extensível, middleware ecosystem rico |
35
+ | Prisma | 5.x | Type-safe ORM, auto-generated types, migrations versionadas, Prisma Studio |
36
+ | Zod | 3.x | Validação de input runtime + compile-time, integra com TypeScript |
37
+ | jsonwebtoken | 9.x | JWT padrão da indústria, refresh token rotation |
38
+ | bcryptjs | 2.x | Hash de senhas, cost factor 12 |
39
+
40
+ ### 2.3 Banco de Dados
41
+
42
+ | Tecnologia | Justificativa |
43
+ |-----------|---------------|
44
+ | PostgreSQL 16 | ACID compliance, extensões ricas, performance, free tier Railway |
45
+
46
+ ### 2.4 Infraestrutura
47
+
48
+ | Componente | Tecnologia | Justificativa |
49
+ |-----------|-----------|---------------|
50
+ | Frontend hosting | Vercel | Deploy automático do Next.js, CDN global, free tier generoso |
51
+ | Backend hosting | Railway | Deploy via Dockerfile, PostgreSQL incluso, $5/mês starter |
52
+ | CI/CD | GitHub Actions | Integrado ao repositório, lint → test → build → deploy |
53
+ | Monitoramento | Sentry | Error tracking, performance monitoring, free tier 5k events |
54
+ | Analytics | Vercel Analytics | Web Vitals, page views, zero config |
55
+
56
+ ---
57
+
58
+ ## 3. Diagrama C4
59
+
60
+ ### 3.1 Nível 1 — Contexto
61
+
62
+ ```
63
+ ┌──────────────┐
64
+ │ Usuários │
65
+ │ (Marina, │
66
+ │ Carlos) │
67
+ └──────┬───────┘
68
+ │ HTTPS
69
+
70
+ ┌──────────────┐
71
+ │ TaskFlow │
72
+ │ Web App │
73
+ └──────┬───────┘
74
+
75
+ ┌────────────┼────────────┐
76
+ ▼ ▼ ▼
77
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
78
+ │ Google │ │ SendGrid │ │ Sentry │
79
+ │ OAuth │ │ (Email) │ │ (Errors) │
80
+ └──────────┘ └──────────┘ └──────────┘
81
+ ```
82
+
83
+ ### 3.2 Nível 2 — Containers
84
+
85
+ ```
86
+ ┌───────────────────────────────────────────┐
87
+ │ TaskFlow System │
88
+ │ │
89
+ │ ┌─────────────────┐ ┌────────────────┐ │
90
+ │ │ Frontend │ │ Backend API │ │
91
+ │ │ (Next.js) │─▶│ (Express) │ │
92
+ │ │ Vercel │ │ Railway │ │
93
+ │ │ Port: 443 │ │ Port: 3001 │ │
94
+ │ └─────────────────┘ └───────┬────────┘ │
95
+ │ │ │
96
+ │ ┌──────┴───────┐ │
97
+ │ │ PostgreSQL │ │
98
+ │ │ Railway │ │
99
+ │ │ Port: 5432 │ │
100
+ │ └──────────────┘ │
101
+ └───────────────────────────────────────────┘
102
+ ```
103
+
104
+ ---
105
+
106
+ ## 4. Modelo de Dados
107
+
108
+ ### 4.1 Entidades Principais
109
+
110
+ #### User
111
+
112
+ | Atributo | Tipo | Obrigatório | Descrição |
113
+ |----------|------|:-----------:|-----------|
114
+ | id | UUID | ✅ | PK, gen_random_uuid() |
115
+ | email | VARCHAR(255) | ✅ | Unique, usado para login |
116
+ | name | VARCHAR(100) | ✅ | Nome de exibição |
117
+ | password_hash | VARCHAR(255) | ❌ | Null se OAuth-only |
118
+ | avatar_url | TEXT | ❌ | URL do avatar (Google ou upload) |
119
+ | google_id | VARCHAR(255) | ❌ | ID do Google OAuth, unique |
120
+ | created_at | TIMESTAMP | ✅ | Default NOW() |
121
+ | updated_at | TIMESTAMP | ✅ | Default NOW() |
122
+
123
+ #### Project
124
+
125
+ | Atributo | Tipo | Obrigatório | Descrição |
126
+ |----------|------|:-----------:|-----------|
127
+ | id | UUID | ✅ | PK |
128
+ | name | VARCHAR(100) | ✅ | Nome do projeto |
129
+ | description | TEXT | ❌ | Descrição opcional |
130
+ | owner_id | UUID | ✅ | FK → User.id |
131
+ | status | ENUM | ✅ | 'active', 'archived' |
132
+ | created_at | TIMESTAMP | ✅ | Default NOW() |
133
+ | updated_at | TIMESTAMP | ✅ | Default NOW() |
134
+
135
+ #### ProjectMember
136
+
137
+ | Atributo | Tipo | Obrigatório | Descrição |
138
+ |----------|------|:-----------:|-----------|
139
+ | id | UUID | ✅ | PK |
140
+ | project_id | UUID | ✅ | FK → Project.id |
141
+ | user_id | UUID | ✅ | FK → User.id |
142
+ | role | ENUM | ✅ | 'admin', 'member', 'viewer' |
143
+ | joined_at | TIMESTAMP | ✅ | Default NOW() |
144
+
145
+ #### Task
146
+
147
+ | Atributo | Tipo | Obrigatório | Descrição |
148
+ |----------|------|:-----------:|-----------|
149
+ | id | UUID | ✅ | PK |
150
+ | project_id | UUID | ✅ | FK → Project.id |
151
+ | title | VARCHAR(200) | ✅ | Título da tarefa |
152
+ | description | TEXT | ❌ | Descrição em markdown |
153
+ | status | ENUM | ✅ | 'todo', 'doing', 'review', 'done' |
154
+ | priority | ENUM | ✅ | 'p1', 'p2', 'p3', 'p4'. Default 'p3' |
155
+ | assignee_id | UUID | ❌ | FK → User.id |
156
+ | due_date | DATE | ❌ | Prazo |
157
+ | position | INTEGER | ✅ | Ordem no kanban (para drag-and-drop) |
158
+ | created_by | UUID | ✅ | FK → User.id |
159
+ | created_at | TIMESTAMP | ✅ | Default NOW() |
160
+ | updated_at | TIMESTAMP | ✅ | Default NOW() |
161
+
162
+ #### Subtask
163
+
164
+ | Atributo | Tipo | Obrigatório | Descrição |
165
+ |----------|------|:-----------:|-----------|
166
+ | id | UUID | ✅ | PK |
167
+ | task_id | UUID | ✅ | FK → Task.id, CASCADE delete |
168
+ | title | VARCHAR(200) | ✅ | Título da subtarefa |
169
+ | completed | BOOLEAN | ✅ | Default false |
170
+ | position | INTEGER | ✅ | Ordem na lista |
171
+
172
+ #### Comment
173
+
174
+ | Atributo | Tipo | Obrigatório | Descrição |
175
+ |----------|------|:-----------:|-----------|
176
+ | id | UUID | ✅ | PK |
177
+ | task_id | UUID | ✅ | FK → Task.id, CASCADE delete |
178
+ | author_id | UUID | ✅ | FK → User.id |
179
+ | content | TEXT | ✅ | Conteúdo em markdown |
180
+ | created_at | TIMESTAMP | ✅ | Default NOW() |
181
+
182
+ #### Label
183
+
184
+ | Atributo | Tipo | Obrigatório | Descrição |
185
+ |----------|------|:-----------:|-----------|
186
+ | id | UUID | ✅ | PK |
187
+ | project_id | UUID | ✅ | FK → Project.id |
188
+ | name | VARCHAR(50) | ✅ | Nome do label |
189
+ | color | VARCHAR(7) | ✅ | Hex color (#FF5733) |
190
+
191
+ #### TaskLabel (N:N)
192
+
193
+ | Atributo | Tipo | Obrigatório | Descrição |
194
+ |----------|------|:-----------:|-----------|
195
+ | task_id | UUID | ✅ | FK → Task.id |
196
+ | label_id | UUID | ✅ | FK → Label.id |
197
+ | PK composta | (task_id, label_id) | ✅ | |
198
+
199
+ ### 4.2 Relacionamentos
200
+
201
+ | Entidade A | Relação | Entidade B | Descrição |
202
+ |-----------|---------|-----------|-----------|
203
+ | User | 1:N | Project | Um usuário é dono de muitos projetos |
204
+ | User | N:N | Project | Muitos membros em muitos projetos (via ProjectMember) |
205
+ | Project | 1:N | Task | Um projeto tem muitas tarefas |
206
+ | Task | 1:N | Subtask | Uma tarefa tem muitas subtarefas |
207
+ | Task | 1:N | Comment | Uma tarefa tem muitos comentários |
208
+ | Task | N:N | Label | Muitas tarefas com muitos labels (via TaskLabel) |
209
+ | User | 1:N | Task (assignee) | Um usuário é responsável por muitas tarefas |
210
+ | User | 1:N | Comment | Um usuário é autor de muitos comentários |
211
+
212
+ ---
213
+
214
+ ## 5. Schema de Banco
215
+
216
+ ### 5.1 Índices Planejados
217
+
218
+ | Tabela | Índice | Colunas | Tipo | Justificativa |
219
+ |--------|--------|---------|------|---------------|
220
+ | users | idx_users_email | email | UNIQUE | Login lookup — query mais frequente |
221
+ | users | idx_users_google_id | google_id | UNIQUE | OAuth lookup |
222
+ | project_members | idx_pm_project_user | (project_id, user_id) | UNIQUE | Evitar membro duplicado, query de autorização |
223
+ | tasks | idx_tasks_project_status | (project_id, status) | INDEX | Kanban: filtrar tarefas por projeto e status |
224
+ | tasks | idx_tasks_assignee | assignee_id | INDEX | "Minhas tarefas": filtrar por responsável |
225
+ | tasks | idx_tasks_due_date | due_date | INDEX | Dashboard: tarefas atrasadas (WHERE due_date < NOW()) |
226
+ | comments | idx_comments_task | task_id | INDEX | Carregar comentários de uma tarefa |
227
+
228
+ ### 5.2 Migrations
229
+
230
+ | Ferramenta | Prisma Migrate |
231
+ |-----------|---------------|
232
+ | **Estratégia** | Migrations versionadas em `prisma/migrations/`, aplicadas via `prisma migrate deploy` no CI/CD |
233
+ | **Rollback** | Cada migration documentada. Em emergência: `prisma migrate resolve` + script SQL manual |
234
+ | **Seeds** | `prisma/seed.ts` com dados de desenvolvimento (2 users, 2 projects, 10 tasks) |
235
+
236
+ ---
237
+
238
+ ## 6. ADRs
239
+
240
+ ### ADR-001: Monolito vs Microserviços
241
+
242
+ | Campo | Valor |
243
+ |-------|-------|
244
+ | **Status** | Aceito |
245
+ | **Contexto** | MVP com 1-2 devs, escopo de 6 features, 500 usuários no target. Precisa de velocidade de entrega. |
246
+ | **Decisão** | Monolito com separação por módulos (users/, projects/, tasks/). Frontend e backend em repos separados. |
247
+ | **Alternativas** | 1) Microserviços — rejeitado: overhead de infra (service mesh, API gateway) desproporcional para 1-2 devs. 2) Serverless (Lambda) — rejeitado: cold starts prejudicam UX do kanban drag-and-drop. |
248
+ | **Consequências** | (+) Deploy simples, DX melhor, debug fácil. (-) Escala vertical apenas, eventual refactor se crescer >10k users. |
249
+
250
+ ### ADR-002: PostgreSQL vs MongoDB
251
+
252
+ | Campo | Valor |
253
+ |-------|-------|
254
+ | **Status** | Aceito |
255
+ | **Contexto** | Dados relacionais fortes (User → Project → Task → Subtask/Comment). Precisa de transações ACID para mover tarefas. |
256
+ | **Decisão** | PostgreSQL 16 via Railway (managed). |
257
+ | **Alternativas** | 1) MongoDB — rejeitado: dados altamente relacionais, joins complexos para dashboard. 2) SQLite — rejeitado: sem suporte a conexões concorrentes em produção. |
258
+ | **Consequências** | (+) ACID, queries complexas eficientes, Prisma excelente com Postgres. (-) Requer managed service (Railway $5/mês). |
259
+
260
+ ### ADR-003: JWT vs Sessions
261
+
262
+ | Campo | Valor |
263
+ |-------|-------|
264
+ | **Status** | Aceito |
265
+ | **Contexto** | Frontend SPA (Next.js client components) precisa de autenticação stateless para API. |
266
+ | **Decisão** | JWT com access token (15min) + refresh token (7 dias) com rotação. Tokens em cookies HttpOnly Secure SameSite=Strict. |
267
+ | **Alternativas** | 1) Sessions server-side — rejeitado: requer Redis para scaling horizontal, overhead para MVP. 2) NextAuth sessions — rejeitado: lock-in no Next.js, dificulta API mobile futura. |
268
+ | **Consequências** | (+) Stateless, escala horizontal fácil no futuro, compatível com mobile. (-) Complexidade de refresh token rotation. |
269
+
270
+ ---
271
+
272
+ ## 7. Segurança
273
+
274
+ ### 7.1 Autenticação
275
+
276
+ | Aspecto | Implementação |
277
+ |---------|---------------|
278
+ | **Email/senha** | bcrypt cost 12, mín 8 chars. Rate limit: 5 tentativas/15min por IP |
279
+ | **Google OAuth** | via passport-google-oauth20, scopes: profile + email |
280
+ | **Access Token** | JWT, 15min expiry, payload: {userId, email, role} |
281
+ | **Refresh Token** | UUID opaco, 7 dias, armazenado em DB, rotação a cada uso |
282
+ | **Cookies** | HttpOnly, Secure, SameSite=Strict, path=/ |
283
+
284
+ ### 7.2 Autorização
285
+
286
+ | Recurso | Admin | Member | Viewer |
287
+ |---------|:-----:|:------:|:------:|
288
+ | Ver projetos | ✅ | ✅ | ✅ |
289
+ | Criar/editar tarefas | ✅ | ✅ | ❌ |
290
+ | Convidar membros | ✅ | ❌ | ❌ |
291
+ | Deletar projeto | ✅ | ❌ | ❌ |
292
+ | Editar settings | ✅ | ❌ | ❌ |
293
+
294
+ ### 7.3 OWASP Top 10
295
+
296
+ | Vulnerabilidade | Mitigação |
297
+ |----------------|-----------|
298
+ | SQL Injection | Prisma ORM — queries parametrizadas por padrão |
299
+ | XSS | React escapa por padrão, CSP headers via Vercel |
300
+ | Broken Auth | JWT com refresh rotation, rate limiting, bcrypt |
301
+ | CSRF | SameSite=Strict cookies, Double Submit Cookie pattern |
302
+ | SSRF | Sem fetch de URLs externas no MVP |
303
+ | Mass Assignment | Zod schemas validam EXATAMENTE os campos permitidos |
304
+
305
+ ### 7.4 LGPD
306
+
307
+ | Dado | Classificação | Proteção |
308
+ |------|--------------|----------|
309
+ | Email | PII | Criptografado em repouso (PostgreSQL encryption), acesso logado |
310
+ | Nome | PII | Exibido apenas para membros do mesmo projeto |
311
+ | Senha | Crítico | bcrypt hash, nunca armazenada em texto claro, nunca em logs |
312
+
313
+ ---
314
+
315
+ ## 8. Requisitos Não-Funcionais
316
+
317
+ | ID | Categoria | Requisito | Meta | Como Medir |
318
+ |----|-----------|-----------|------|------------|
319
+ | NFR-001 | Performance | API response time | p95 < 300ms | Sentry Performance |
320
+ | NFR-002 | Performance | First Contentful Paint | < 1.5s | Vercel Analytics |
321
+ | NFR-003 | Disponibilidade | Uptime mensal | 99.5% | Better Uptime (free) |
322
+ | NFR-004 | Escalabilidade | Concurrent users | 500 | k6 load test |
323
+ | NFR-005 | Observabilidade | Error tracking | 100% de erros | Sentry |
324
+
325
+ ---
326
+
327
+ ## 9. Estratégia de Deploy
328
+
329
+ ### 9.1 Ambientes
330
+
331
+ | Ambiente | URL | Branch | Deploy |
332
+ |----------|-----|--------|--------|
333
+ | Development | localhost:3000 / :3001 | feature/* | Manual |
334
+ | Preview | *.vercel.app | PR branches | Automático (Vercel) |
335
+ | Production | taskflow.app | main | Automático com checks verdes |
336
+
337
+ ### 9.2 CI/CD Pipeline (GitHub Actions)
338
+
339
+ ```
340
+ Push to PR:
341
+ → Lint (ESLint) → Type Check (tsc) → Test (Vitest) → Build → Vercel Preview
342
+
343
+ Merge to main:
344
+ → Lint → Type Check → Test → Build → Prisma Migrate → Deploy Prod
345
+ ```
@@ -0,0 +1,86 @@
1
+ # Guia de Referência — Arquitetura
2
+
3
+ ## Diagramas C4
4
+
5
+ ### Nível 1 — Context
6
+ - Mostra: sistema, atores (personas), sistemas externos
7
+ - Pergunta: "Quem usa? Com o que integra?"
8
+ - Formato: boxes com setas rotuladas
9
+
10
+ ### Nível 2 — Container
11
+ - Mostra: frontend, backend, banco, serviços
12
+ - Pergunta: "Quais são os containers de deploy?"
13
+ - Inclui: tecnologia e porta de cada container
14
+
15
+ ### Nível 3 — Component (opcional para MVP)
16
+ - Mostra: módulos internos de cada container
17
+ - Pergunta: "Como o backend é organizado internamente?"
18
+
19
+ ## Architecture Decision Records (ADRs)
20
+
21
+ ### Formato obrigatório
22
+ 1. **Contexto** — Por que essa decisão é necessária?
23
+ 2. **Decisão** — O que foi decidido?
24
+ 3. **Alternativas** — O que foi considerado e rejeitado? (com motivo)
25
+ 4. **Consequências** — Prós e contras da decisão
26
+
27
+ ### ADRs mínimos para qualquer projeto
28
+ - ADR-001: Monolito vs Microserviços
29
+ - ADR-002: Escolha do banco de dados
30
+ - ADR-003: Estratégia de autenticação
31
+
32
+ ## Stack Selection — Critérios
33
+
34
+ | Critério | Peso | Pergunta |
35
+ |----------|------|----------|
36
+ | **Time** | Alto | O time já domina? Curva de aprendizado? |
37
+ | **Ecossistema** | Alto | Tem libs/ferramentas maduras? |
38
+ | **Custo** | Médio | Free tier? Custo em escala? |
39
+ | **Performance** | Médio | Atende os NFRs definidos? |
40
+ | **Comunidade** | Baixo | Docs boas? Stack Overflow ativo? |
41
+
42
+ ### Stacks recomendadas por tipo de projeto
43
+
44
+ | Tipo | Frontend | Backend | Banco |
45
+ |------|----------|---------|-------|
46
+ | **SaaS Web** | Next.js + Tailwind + shadcn | Node.js/Express ou NestJS | PostgreSQL |
47
+ | **E-commerce** | Next.js + Tailwind | Node.js ou Python/Django | PostgreSQL |
48
+ | **API-first** | — | Express/Fastify ou FastAPI | PostgreSQL/MongoDB |
49
+ | **Real-time** | Next.js + Socket.io | Node.js + Socket.io | PostgreSQL + Redis |
50
+ | **Mobile** | React Native ou Flutter | Node.js/Express | PostgreSQL + Firebase |
51
+
52
+ ## Modelo de Dados — Checklist
53
+
54
+ - [ ] Todas as entidades do domínio listadas com atributos e tipos
55
+ - [ ] Relacionamentos com cardinalidade (1:1, 1:N, N:N)
56
+ - [ ] Tabelas intermediárias para N:N explícitas
57
+ - [ ] PKs definidas (UUID recomendado sobre autoincrement)
58
+ - [ ] created_at e updated_at em TODAS as tabelas
59
+ - [ ] Soft delete (deleted_at) quando necessário
60
+ - [ ] Índices para: login (email), FKs mais usadas, filtros frequentes
61
+
62
+ ## Segurança — OWASP Top 10 Resumo
63
+
64
+ | # | Vulnerabilidade | Mitigação padrão |
65
+ |---|----------------|-----------------|
66
+ | 1 | Injection | ORM com queries parametrizadas (Prisma, TypeORM) |
67
+ | 2 | Broken Auth | JWT com refresh rotation, rate limiting, bcrypt |
68
+ | 3 | Sensitive Data | HTTPS, criptografia em repouso, nunca logar PII |
69
+ | 4 | XXE | Não processar XML externo |
70
+ | 5 | Broken Access | RBAC middleware em cada rota |
71
+ | 6 | Misconfiguration | Headers de segurança (helmet), CSP, HSTS |
72
+ | 7 | XSS | React escapa por padrão, CSP, sanitize inputs |
73
+ | 8 | Deserialization | Validar com Zod antes de deserializar |
74
+ | 9 | Known Vulns | npm audit, Dependabot, updates regulares |
75
+ | 10 | Logging | Log de acesso, erros com Sentry, nunca logar senhas |
76
+
77
+ ## Anti-patterns de Arquitetura
78
+
79
+ | Anti-pattern | Por que é ruim | Correção |
80
+ |-------------|----------------|----------|
81
+ | Stack da moda sem justificativa | Time não domina → produtividade cai | ADR com contexto do time |
82
+ | Microserviços para MVP | Overhead de infra para 1-2 devs | Monolito modular |
83
+ | Sem schema de banco | Prisma/Migrations falham sem schema definido | Definir TODAS as tabelas |
84
+ | ADRs genéricos | "Escolhemos React" sem contexto | Sempre: contexto + alternativas + consequências |
85
+ | NFRs vagos | "Deve ser rápido" | Números: p95 < 200ms, 99.5% uptime |
86
+ | Ignorar segurança no MVP | Vazamento de dados no launch | OWASP Top 5 no mínimo |