@polymorphism-tech/morph-spec 4.3.4 → 4.3.6

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 (164) hide show
  1. package/.morph/.morphversion +5 -0
  2. package/.morph/config/agents.json +948 -0
  3. package/.morph/config/config.json +9 -9
  4. package/.morph/project/context/README.md +17 -0
  5. package/.morph/project/context/detection-log.md +16 -0
  6. package/.morph/project/standards/inferred.md +59 -0
  7. package/.morph/standards/ai-agents/blazor-ui.md +364 -0
  8. package/.morph/standards/ai-agents/production.md +415 -0
  9. package/.morph/standards/ai-agents/setup.md +418 -0
  10. package/.morph/standards/ai-agents/team-orchestration.md +479 -0
  11. package/.morph/standards/ai-agents/workflows.md +354 -0
  12. package/.morph/standards/architecture/ddd/aggregates.md +120 -0
  13. package/.morph/standards/architecture/ddd/entities.md +99 -0
  14. package/.morph/standards/architecture/ddd/value-objects.md +124 -0
  15. package/.morph/standards/backend/api/minimal-api.md +494 -0
  16. package/.morph/standards/backend/api/rest.md +492 -0
  17. package/.morph/standards/backend/api/validation.md +88 -0
  18. package/.morph/standards/backend/authentication/passkeys.md +428 -0
  19. package/.morph/standards/backend/database/ef-core.md +199 -0
  20. package/.morph/standards/backend/database/migrations.md +393 -0
  21. package/.morph/standards/backend/database/postgresql/database.md +352 -0
  22. package/.morph/standards/backend/database/repository-patterns.md +528 -0
  23. package/.morph/standards/backend/database/vector-search-rag.md +541 -0
  24. package/.morph/standards/backend/dotnet/async.md +366 -0
  25. package/.morph/standards/backend/dotnet/core.md +117 -0
  26. package/.morph/standards/backend/dotnet/di.md +439 -0
  27. package/.morph/standards/backend/dotnet/program-cs-checklist.md +92 -0
  28. package/.morph/standards/backend/integrations/asaas/asaas-api.md +216 -0
  29. package/.morph/standards/backend/integrations/clerk/clerk-auth.md +290 -0
  30. package/.morph/standards/backend/integrations/hangfire/hangfire-jobs.md +350 -0
  31. package/.morph/standards/backend/integrations/resend/resend-email.md +385 -0
  32. package/.morph/standards/context/analytics.md +96 -0
  33. package/.morph/standards/context/bundles.md +110 -0
  34. package/.morph/standards/context/priming.md +78 -0
  35. package/.morph/standards/core/architecture.md +185 -0
  36. package/.morph/standards/core/coding.md +214 -0
  37. package/.morph/standards/core/git-branching-strategy.md +403 -0
  38. package/.morph/standards/core/git.md +185 -0
  39. package/.morph/standards/core/testing.md +295 -0
  40. package/.morph/standards/data/nosql/blob-storage.md +102 -0
  41. package/.morph/standards/data/nosql/cache/redis.md +97 -0
  42. package/.morph/standards/data/nosql/cosmos-db.md +118 -0
  43. package/.morph/standards/data/vector-search/azure-ai-search.md +121 -0
  44. package/.morph/standards/data/vector-search/rag-chunking.md +104 -0
  45. package/.morph/standards/frontend/blazor/design-checklist.md +222 -0
  46. package/.morph/standards/frontend/blazor/fluent-ui-setup.md +595 -0
  47. package/.morph/standards/frontend/blazor/fluent-ui.md +137 -0
  48. package/.morph/standards/frontend/blazor/html-conversion.md +184 -0
  49. package/.morph/standards/frontend/blazor/lifecycle.md +195 -0
  50. package/.morph/standards/frontend/blazor/pitfalls.md +198 -0
  51. package/.morph/standards/frontend/blazor/state.md +191 -0
  52. package/.morph/standards/frontend/design-system/animations.md +151 -0
  53. package/.morph/standards/frontend/design-system/naming.md +64 -0
  54. package/.morph/standards/frontend/nextjs/nextjs-patterns.md +198 -0
  55. package/.morph/standards/infrastructure/azure/azure.md +624 -0
  56. package/.morph/standards/infrastructure/azure/bicep/bicep-patterns.md +422 -0
  57. package/.morph/standards/infrastructure/azure/devops/azure-devops-setup.md +516 -0
  58. package/.morph/standards/infrastructure/azure/devops/local-development.md +520 -0
  59. package/.morph/standards/infrastructure/azure/services/functions.md +486 -0
  60. package/.morph/standards/infrastructure/azure/services/service-bus.md +459 -0
  61. package/.morph/standards/infrastructure/azure/services/storage.md +407 -0
  62. package/.morph/standards/infrastructure/docker/easypanel-deploy.md +196 -0
  63. package/.morph/standards/infrastructure/supabase/mcp-setup.md +252 -0
  64. package/.morph/standards/infrastructure/supabase/supabase-auth.md +176 -0
  65. package/.morph/standards/infrastructure/supabase/supabase-pgvector.md +169 -0
  66. package/.morph/standards/infrastructure/supabase/supabase-rls.md +184 -0
  67. package/.morph/standards/infrastructure/supabase/supabase-storage.md +153 -0
  68. package/.morph/standards/integration/api/graphql.md +91 -0
  69. package/.morph/standards/integration/api/grpc.md +114 -0
  70. package/.morph/standards/integration/api/rest-design.md +95 -0
  71. package/.morph/standards/integration/event-driven/cqrs.md +101 -0
  72. package/.morph/standards/integration/event-driven/event-sourcing.md +124 -0
  73. package/.morph/standards/integration/event-driven/service-bus.md +95 -0
  74. package/.morph/standards/observability/logging.md +131 -0
  75. package/.morph/standards/observability/metrics.md +121 -0
  76. package/.morph/standards/observability/monitoring.md +114 -0
  77. package/.morph/standards/observability/tracing.md +132 -0
  78. package/.morph/standards/workflows/parallel-execution.md +112 -0
  79. package/.morph/standards/workflows/thread-management.md +113 -0
  80. package/.morph/templates/.idea/morph-templates.xml +92 -0
  81. package/.morph/templates/.vscode/morph-templates.code-snippets +186 -0
  82. package/.morph/templates/IDE-SNIPPETS.md +266 -0
  83. package/.morph/templates/README.md +814 -0
  84. package/.morph/templates/REGISTRY.json +1677 -0
  85. package/.morph/templates/code/dotnet/backend/repository.cs +141 -0
  86. package/.morph/templates/code/dotnet/backend/service.cs +139 -0
  87. package/.morph/templates/code/dotnet/contracts/Commands.cs +74 -0
  88. package/.morph/templates/code/dotnet/contracts/Entities.cs +25 -0
  89. package/.morph/templates/code/dotnet/contracts/Queries.cs +74 -0
  90. package/.morph/templates/code/dotnet/contracts/README.md +74 -0
  91. package/.morph/templates/code/dotnet/contracts/api-contracts.cs +173 -0
  92. package/.morph/templates/code/dotnet/contracts/contracts.cs +217 -0
  93. package/.morph/templates/code/dotnet/database/migration.cs +83 -0
  94. package/.morph/templates/code/dotnet/frontend/component.razor +239 -0
  95. package/.morph/templates/code/dotnet/jobs/agent.cs +163 -0
  96. package/.morph/templates/code/dotnet/jobs/job.cs +171 -0
  97. package/.morph/templates/code/dotnet/test.cs +239 -0
  98. package/.morph/templates/code/sql/rls-policy.sql +57 -0
  99. package/.morph/templates/code/sql/supabase-migration.sql +100 -0
  100. package/.morph/templates/code/sql/supabase-migration.template.sql +113 -0
  101. package/.morph/templates/code/typescript/contracts.ts +168 -0
  102. package/.morph/templates/context/CONTEXT-FEATURE.md +276 -0
  103. package/.morph/templates/context/CONTEXT.md +181 -0
  104. package/.morph/templates/docs/proposal.md +182 -0
  105. package/.morph/templates/docs/spec.md +149 -0
  106. package/.morph/templates/examples/design-system-examples.md +357 -0
  107. package/.morph/templates/examples/spec-examples.md +90 -0
  108. package/.morph/templates/feature/decisions.md +187 -0
  109. package/.morph/templates/feature/recap.md +146 -0
  110. package/.morph/templates/feature/tasks.md +199 -0
  111. package/.morph/templates/infrastructure/azure/Dockerfile.example +82 -0
  112. package/.morph/templates/infrastructure/azure/README.md +286 -0
  113. package/.morph/templates/infrastructure/azure/app-insights.bicep +63 -0
  114. package/.morph/templates/infrastructure/azure/app-service.bicep +164 -0
  115. package/.morph/templates/infrastructure/azure/container-app-env.bicep +49 -0
  116. package/.morph/templates/infrastructure/azure/container-app.bicep +156 -0
  117. package/.morph/templates/infrastructure/azure/deploy-checklist.md +426 -0
  118. package/.morph/templates/infrastructure/azure/deploy.ps1 +229 -0
  119. package/.morph/templates/infrastructure/azure/deploy.sh +208 -0
  120. package/.morph/templates/infrastructure/azure/key-vault.bicep +91 -0
  121. package/.morph/templates/infrastructure/azure/main.bicep +189 -0
  122. package/.morph/templates/infrastructure/azure/parameters.dev.json +29 -0
  123. package/.morph/templates/infrastructure/azure/parameters.prod.json +29 -0
  124. package/.morph/templates/infrastructure/azure/parameters.staging.json +29 -0
  125. package/.morph/templates/infrastructure/azure/sql-database.bicep +103 -0
  126. package/.morph/templates/infrastructure/azure/storage.bicep +106 -0
  127. package/.morph/templates/infrastructure/docker/Dockerfile.template +58 -0
  128. package/.morph/templates/infrastructure/docker/docker-compose.template.yml +67 -0
  129. package/.morph/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -0
  130. package/.morph/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -0
  131. package/.morph/templates/infrastructure/docker/easypanel.template.json +54 -0
  132. package/.morph/templates/infrastructure/github/README.md +593 -0
  133. package/.morph/templates/infrastructure/github/actions/azure-auth/action.yml.hbs +22 -0
  134. package/.morph/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +45 -0
  135. package/.morph/templates/infrastructure/github/actions/health-check/action.yml.hbs +27 -0
  136. package/.morph/templates/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +61 -0
  137. package/.morph/templates/infrastructure/github/workflows/deploy-easypanel.yml.hbs +31 -0
  138. package/.morph/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +59 -0
  139. package/.morph/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +39 -0
  140. package/.morph/templates/integrations/asaas-client.cs +387 -0
  141. package/.morph/templates/integrations/asaas-webhook.cs +351 -0
  142. package/.morph/templates/integrations/azure-identity-config.cs +288 -0
  143. package/.morph/templates/integrations/clerk-config.cs +258 -0
  144. package/.morph/templates/meta-prompts/fusion/fusion-agent.md +76 -0
  145. package/.morph/templates/meta-prompts/fusion/fusion-aggregator.md +100 -0
  146. package/.morph/templates/meta-prompts/hops/hop-retry.md +78 -0
  147. package/.morph/templates/meta-prompts/hops/hop-validation.md +97 -0
  148. package/.morph/templates/meta-prompts/hops/hop-wrapper.md +36 -0
  149. package/.morph/templates/meta-prompts/parallel-workers/parallel-coordinator.md +113 -0
  150. package/.morph/templates/meta-prompts/parallel-workers/parallel-worker.md +80 -0
  151. package/.morph/templates/meta-prompts/squad-leaders/backend-squad.md +90 -0
  152. package/.morph/templates/meta-prompts/squad-leaders/frontend-squad.md +126 -0
  153. package/.morph/templates/meta-prompts/squad-leaders/squad-leader.md +43 -0
  154. package/.morph/templates/meta-prompts/validators/checkpoint-validator.md +107 -0
  155. package/.morph/templates/meta-prompts/validators/pre-commit-validator.md +95 -0
  156. package/.morph/templates/saas/subscription.cs +347 -0
  157. package/.morph/templates/saas/tenant.cs +338 -0
  158. package/.morph/templates/state.template.json +17 -0
  159. package/.morph/templates/ui/FluentDesignTheme.cs +149 -0
  160. package/.morph/templates/ui/MudTheme.cs +281 -0
  161. package/.morph/templates/ui/design-system.css +226 -0
  162. package/bin/morph-spec.js +1 -1
  163. package/package.json +1 -1
  164. package/src/commands/project/update.js +185 -46
@@ -0,0 +1,520 @@
1
+ # Local Development with Azure Resources
2
+
3
+ > **Scope:** blazor-azure
4
+ > **Layer:** 2
5
+ > **Keywords:** local, development, azure, sql, key vault, storage, defaultazurecredential, azure cli
6
+ > **Load When:** Local development setup, Azure resource access, development environment
7
+
8
+ > Como rodar o projeto localmente e acessar recursos Azure do Staging
9
+
10
+ ---
11
+
12
+ ## 📋 Conceito
13
+
14
+ Developers **não precisam de ambiente próprio**. Ao invés disso:
15
+
16
+ - ✅ **Rodam o projeto LOCAL** (Visual Studio, Rider, VS Code)
17
+ - ✅ **Acessam recursos REMOTOS** do ambiente Staging (SQL, Storage, Key Vault)
18
+ - ✅ **Testam localmente** antes de commitar
19
+ - ✅ **Criam PRs** para Staging quando pronto
20
+
21
+ **Vantagens:**
22
+ - 💰 **Custo zero** para ambiente dev
23
+ - ⚡ **Desenvolvimento mais rápido** (hot reload, debug local)
24
+ - 🔄 **Dados compartilhados** (todos testam com mesmos dados)
25
+ - 🎯 **Ambiente staging sempre atualizado**
26
+
27
+ ---
28
+
29
+ ## ⚙️ Setup Inicial (Uma vez)
30
+
31
+ ### 1. Instalar Ferramentas
32
+
33
+ ```bash
34
+ # .NET SDK
35
+ winget install Microsoft.DotNet.SDK.8
36
+
37
+ # Azure CLI
38
+ winget install Microsoft.AzureCLI
39
+
40
+ # Git
41
+ winget install Git.Git
42
+
43
+ # Visual Studio ou VS Code
44
+ winget install Microsoft.VisualStudio.2022.Community
45
+ # ou
46
+ winget install Microsoft.VisualStudioCode
47
+ ```
48
+
49
+ ### 2. Login no Azure
50
+
51
+ ```bash
52
+ # Login com sua conta corporativa
53
+ az login
54
+
55
+ # Verificar subscription
56
+ az account show
57
+
58
+ # Se necessário, trocar subscription
59
+ az account set --subscription "<SUBSCRIPTION_ID>"
60
+ ```
61
+
62
+ ### 3. Obter Permissões Staging
63
+
64
+ Solicite ao tech lead para adicionar você ao ambiente staging:
65
+
66
+ ```bash
67
+ # Tech lead executa:
68
+ az role assignment create \
69
+ --assignee <developer-email> \
70
+ --role "Contributor" \
71
+ --scope "/subscriptions/<SUB_ID>/resourceGroups/rg-myapp-staging"
72
+
73
+ # Permissão SQL Database
74
+ az sql server ad-admin set \
75
+ --resource-group rg-myapp-staging \
76
+ --server-name sql-myapp-staging \
77
+ --display-name "<developer-name>" \
78
+ --object-id <developer-object-id>
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 🔧 Configuração do Projeto
84
+
85
+ ### 1. Clonar Repositório
86
+
87
+ ```bash
88
+ git clone https://dev.azure.com/org/project/_git/repo
89
+ cd repo
90
+ ```
91
+
92
+ ### 2. Criar appsettings.Development.json
93
+
94
+ ```json
95
+ {
96
+ "ConnectionStrings": {
97
+ "DefaultConnection": "Server=sql-myapp-staging.database.windows.net;Database=myapp;Authentication=Active Directory Default;"
98
+ },
99
+ "Azure": {
100
+ "KeyVault": "https://kv-myapp-staging.vault.azure.net/",
101
+ "Storage": {
102
+ "AccountName": "stmyappstaging",
103
+ "BlobEndpoint": "https://stmyappstaging.blob.core.windows.net"
104
+ }
105
+ },
106
+ "ApplicationInsights": {
107
+ "ConnectionString": "<copiar-do-azure-portal-staging>"
108
+ },
109
+ "Logging": {
110
+ "LogLevel": {
111
+ "Default": "Information",
112
+ "Microsoft.AspNetCore": "Warning"
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ **⚠️ IMPORTANTE:**
119
+ - ❌ **NUNCA commitar** `appsettings.Development.json`
120
+ - ✅ Já está no `.gitignore`
121
+ - ✅ Cada developer tem seu próprio arquivo local
122
+
123
+ ### 3. Configurar DefaultAzureCredential
124
+
125
+ No `Program.cs`:
126
+
127
+ ```csharp
128
+ builder.Services.AddDbContext<ApplicationDbContext>(options =>
129
+ {
130
+ var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
131
+ options.UseSqlServer(connectionString, sqlOptions =>
132
+ {
133
+ sqlOptions.EnableRetryOnFailure(
134
+ maxRetryCount: 3,
135
+ maxRetryDelay: TimeSpan.FromSeconds(30),
136
+ errorNumbersToAdd: null);
137
+ });
138
+ });
139
+
140
+ // Azure Key Vault
141
+ if (!builder.Environment.IsDevelopment())
142
+ {
143
+ var keyVaultUrl = builder.Configuration["Azure:KeyVault"];
144
+ builder.Configuration.AddAzureKeyVault(
145
+ new Uri(keyVaultUrl),
146
+ new DefaultAzureCredential());
147
+ }
148
+
149
+ // Azure Storage
150
+ builder.Services.AddSingleton(x =>
151
+ {
152
+ var accountName = builder.Configuration["Azure:Storage:AccountName"];
153
+ var blobServiceClient = new BlobServiceClient(
154
+ new Uri($"https://{accountName}.blob.core.windows.net"),
155
+ new DefaultAzureCredential());
156
+ return blobServiceClient;
157
+ });
158
+ ```
159
+
160
+ **DefaultAzureCredential** tenta autenticar nesta ordem:
161
+ 1. Environment variables (CI/CD)
162
+ 2. Managed Identity (Azure)
163
+ 3. **Azure CLI** (← usado localmente)
164
+ 4. Visual Studio
165
+ 5. VS Code
166
+
167
+ ---
168
+
169
+ ## 🚀 Rodando Localmente
170
+
171
+ ### Opção 1: Visual Studio
172
+
173
+ 1. Abrir `.sln`
174
+ 2. F5 (Debug) ou Ctrl+F5 (Run)
175
+ 3. Projeto abrirá em `https://localhost:7001`
176
+
177
+ ### Opção 2: Rider
178
+
179
+ 1. Abrir `.sln`
180
+ 2. Shift+F10 (Run) ou Shift+F9 (Debug)
181
+
182
+ ### Opção 3: VS Code
183
+
184
+ ```bash
185
+ # Restaurar dependências
186
+ dotnet restore
187
+
188
+ # Rodar projeto
189
+ dotnet run --project src/YourApp/YourApp.csproj
190
+
191
+ # Ou com watch (hot reload)
192
+ dotnet watch --project src/YourApp/YourApp.csproj
193
+ ```
194
+
195
+ ### Opção 4: CLI direto
196
+
197
+ ```bash
198
+ cd src/YourApp
199
+ dotnet run
200
+ ```
201
+
202
+ ---
203
+
204
+ ## 🗄️ Acesso ao Banco de Dados
205
+
206
+ ### Via Azure Data Studio
207
+
208
+ 1. Download: https://aka.ms/azuredatastudio
209
+ 2. Conectar:
210
+ - **Server**: `sql-myapp-staging.database.windows.net`
211
+ - **Database**: `myapp`
212
+ - **Authentication**: `Azure Active Directory - Universal with MFA`
213
+ - **Account**: Sua conta corporativa
214
+
215
+ ### Via SQL Server Management Studio (SSMS)
216
+
217
+ 1. Download: https://aka.ms/ssmsfullsetup
218
+ 2. Conectar:
219
+ - **Server**: `sql-myapp-staging.database.windows.net`
220
+ - **Authentication**: `Azure Active Directory - Universal with MFA`
221
+ - **Login**: Sua conta
222
+
223
+ ### Via Entity Framework Migrations
224
+
225
+ ```bash
226
+ # Criar migration
227
+ dotnet ef migrations add NomeDaMigration
228
+
229
+ # Aplicar migration no staging (CUIDADO!)
230
+ dotnet ef database update
231
+
232
+ # Reverter migration
233
+ dotnet ef database update PreviousMigration
234
+ ```
235
+
236
+ ⚠️ **ATENÇÃO**: Migrations aplicadas localmente afetam **TODOS** os developers!
237
+
238
+ **Melhor prática:**
239
+ - Criar migration localmente
240
+ - Commitar migration
241
+ - Deixar pipeline aplicar automaticamente
242
+
243
+ ---
244
+
245
+ ## 📦 Acesso ao Azure Storage
246
+
247
+ ### Via Azure Storage Explorer
248
+
249
+ 1. Download: https://aka.ms/storageexplorer
250
+ 2. Login com sua conta
251
+ 3. Navegue até: `stmyappstaging`
252
+ 4. Pode fazer upload/download de blobs
253
+
254
+ ### Via Código
255
+
256
+ ```csharp
257
+ // Upload blob
258
+ var blobClient = blobServiceClient
259
+ .GetBlobContainerClient("uploads")
260
+ .GetBlobClient("test.txt");
261
+
262
+ await blobClient.UploadAsync(
263
+ BinaryData.FromString("Hello from local!"),
264
+ overwrite: true);
265
+
266
+ // Download blob
267
+ var downloadedData = await blobClient.DownloadContentAsync();
268
+ Console.WriteLine(downloadedData.Value.Content.ToString());
269
+ ```
270
+
271
+ ---
272
+
273
+ ## 🔐 Acesso ao Key Vault
274
+
275
+ ### Via Azure CLI
276
+
277
+ ```bash
278
+ # Listar secrets
279
+ az keyvault secret list \
280
+ --vault-name kv-myapp-staging
281
+
282
+ # Obter secret
283
+ az keyvault secret show \
284
+ --vault-name kv-myapp-staging \
285
+ --name "ConnectionStrings--DefaultConnection"
286
+ ```
287
+
288
+ ### Via Código
289
+
290
+ ```csharp
291
+ // Program.cs já configurou automaticamente
292
+ // Acesse via IConfiguration normalmente:
293
+
294
+ var secret = builder.Configuration["MySecretKey"];
295
+ ```
296
+
297
+ ---
298
+
299
+ ## 🧪 Testes Locais
300
+
301
+ ### Unit Tests
302
+
303
+ ```bash
304
+ # Rodar todos os testes
305
+ dotnet test
306
+
307
+ # Rodar com cobertura
308
+ dotnet test --collect:"XPlat Code Coverage"
309
+
310
+ # Apenas testes de uma classe
311
+ dotnet test --filter "FullyQualifiedName~MyTests"
312
+ ```
313
+
314
+ ### Integration Tests
315
+
316
+ ```bash
317
+ # Integration tests usam staging database
318
+ dotnet test --filter "Category=Integration"
319
+ ```
320
+
321
+ ⚠️ **Cuidado**: Integration tests modificam dados staging!
322
+
323
+ **Melhor prática:**
324
+ - Use transações que fazem rollback
325
+ - Ou crie/delete dados de teste
326
+ - Ou use database separado para testes
327
+
328
+ ---
329
+
330
+ ## 🔄 Workflow Diário
331
+
332
+ ### 1. Começar Nova Feature
333
+
334
+ ```bash
335
+ # Atualizar staging
336
+ git checkout staging
337
+ git pull origin staging
338
+
339
+ # Criar feature branch
340
+ git checkout -b feature/minha-funcionalidade
341
+
342
+ # Rodar projeto local
343
+ dotnet run
344
+ ```
345
+
346
+ ### 2. Desenvolver
347
+
348
+ ```bash
349
+ # Fazer mudanças
350
+ # Testar localmente (conecta em staging resources)
351
+ # Commitar frequentemente
352
+
353
+ git add .
354
+ git commit -m "feat: adiciona funcionalidade X"
355
+ ```
356
+
357
+ ### 3. Testar
358
+
359
+ ```bash
360
+ # Unit tests
361
+ dotnet test
362
+
363
+ # Teste manual no browser
364
+ # http://localhost:5000
365
+ ```
366
+
367
+ ### 4. Push e PR
368
+
369
+ ```bash
370
+ # Push da feature branch
371
+ git push origin feature/minha-funcionalidade
372
+
373
+ # Criar PR para staging no Azure DevOps
374
+ # 1. Vá em Repos → Pull Requests → New Pull Request
375
+ # 2. Source: feature/minha-funcionalidade
376
+ # 3. Target: staging
377
+ # 4. Adicionar reviewers
378
+ # 5. Create
379
+ ```
380
+
381
+ ### 5. Code Review e Merge
382
+
383
+ ```
384
+ # Reviewer faz code review
385
+ # Após aprovação, merge
386
+ # Pipeline staging triggará automaticamente
387
+ ```
388
+
389
+ ### 6. Testar em Staging Deployado
390
+
391
+ ```bash
392
+ # Acessar URL staging
393
+ https://ca-myapp-staging.<region>.azurecontainerapps.io
394
+
395
+ # Validar funcionalidade
396
+ # Se OK, criar PR staging → main para prod
397
+ ```
398
+
399
+ ---
400
+
401
+ ## 🆘 Troubleshooting
402
+
403
+ ### Erro: "Login failed for user"
404
+
405
+ **Causa**: Azure CLI não autenticado ou token expirado.
406
+
407
+ **Solução**:
408
+ ```bash
409
+ az logout
410
+ az login
411
+ az account show
412
+ ```
413
+
414
+ ### Erro: "Cannot connect to SQL Server"
415
+
416
+ **Causa**: Firewall SQL bloqueando seu IP.
417
+
418
+ **Solução**:
419
+ ```bash
420
+ # Adicionar seu IP ao firewall
421
+ az sql server firewall-rule create \
422
+ --resource-group rg-myapp-staging \
423
+ --server sql-myapp-staging \
424
+ --name "DevIP-$(whoami)" \
425
+ --start-ip-address <SEU_IP> \
426
+ --end-ip-address <SEU_IP>
427
+
428
+ # Obter seu IP público
429
+ curl https://api.ipify.org
430
+ ```
431
+
432
+ ### Erro: "Access denied to Key Vault"
433
+
434
+ **Causa**: Sem permissão no Key Vault.
435
+
436
+ **Solução** (Tech lead):
437
+ ```bash
438
+ az keyvault set-policy \
439
+ --name kv-myapp-staging \
440
+ --upn <developer-email> \
441
+ --secret-permissions get list
442
+ ```
443
+
444
+ ### Erro: "Blob not found"
445
+
446
+ **Causa**: Container não existe ou sem permissão.
447
+
448
+ **Solução** (Tech lead):
449
+ ```bash
450
+ # Dar permissão Storage Blob Data Contributor
451
+ az role assignment create \
452
+ --assignee <developer-email> \
453
+ --role "Storage Blob Data Contributor" \
454
+ --scope "/subscriptions/<SUB_ID>/resourceGroups/rg-myapp-staging/providers/Microsoft.Storage/storageAccounts/stmyappstaging"
455
+ ```
456
+
457
+ ### Erro: "DefaultAzureCredential failed"
458
+
459
+ **Causa**: Nenhum método de autenticação funcionou.
460
+
461
+ **Solução**:
462
+ 1. Feche Visual Studio/Rider/VS Code
463
+ 2. `az logout && az login`
464
+ 3. Reabra IDE
465
+ 4. Rode novamente
466
+
467
+ ### Migration falhou
468
+
469
+ **Causa**: Conflito com migration de outro developer.
470
+
471
+ **Solução**:
472
+ ```bash
473
+ # Pull latest
474
+ git pull origin staging
475
+
476
+ # Deletar sua migration
477
+ dotnet ef migrations remove
478
+
479
+ # Aplicar migrations remotas
480
+ dotnet ef database update
481
+
482
+ # Recriar sua migration
483
+ dotnet ef migrations add SuaMigration
484
+ ```
485
+
486
+ ---
487
+
488
+ ## ✅ Checklist de Setup
489
+
490
+ Para novos developers:
491
+
492
+ - [ ] Instalar .NET SDK 8
493
+ - [ ] Instalar Azure CLI
494
+ - [ ] Instalar Git
495
+ - [ ] Instalar IDE (VS/Rider/VS Code)
496
+ - [ ] `az login` com conta corporativa
497
+ - [ ] Solicitar permissões staging (tech lead)
498
+ - [ ] Clonar repositório
499
+ - [ ] Criar `appsettings.Development.json`
500
+ - [ ] Testar conexão SQL (Azure Data Studio)
501
+ - [ ] Rodar projeto local (`dotnet run`)
502
+ - [ ] Acessar `https://localhost:7001`
503
+ - [ ] Rodar testes (`dotnet test`)
504
+ - [ ] Criar feature branch de teste
505
+ - [ ] Fazer commit de teste
506
+ - [ ] Criar PR de teste
507
+ - [ ] Deletar PR/branch de teste
508
+
509
+ ---
510
+
511
+ ## 📚 Referências
512
+
513
+ - [DefaultAzureCredential](https://learn.microsoft.com/dotnet/api/azure.identity.defaultazurecredential)
514
+ - [Azure SQL with Azure AD](https://learn.microsoft.com/azure/azure-sql/database/authentication-aad-configure)
515
+ - [Azure Storage SDK](https://learn.microsoft.com/azure/storage/blobs/storage-quickstart-blobs-dotnet)
516
+ - [Entity Framework Migrations](https://learn.microsoft.com/ef/core/managing-schemas/migrations/)
517
+
518
+ ---
519
+
520
+ *MORPH-SPEC by Polymorphism Tech*