@codigodoleo/wp-kit 4.0.0 → 5.0.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.
@@ -1,420 +1,106 @@
1
- # 🏗️ Arquitetura
1
+ # Arquitetura
2
2
 
3
- Documentação completa da arquitetura técnica do site {{projectTitle}}, incluindo infraestrutura, tecnologias e planos futuros.
3
+ High-level technical architecture of **{{projectTitle}}**.
4
4
 
5
- ## 🎯 **Visão Geral da Arquitetura**
5
+ > This document covers what is *known* from the scaffold (local dev,
6
+ > repository, build pipeline). Production-side details (cloud provider,
7
+ > orchestrator, database, CDN) are marked `{{ "{{TODO}}" }}` and must be
8
+ > filled in as those decisions are made.
6
9
 
7
- O site {{projectTitle}} é construído com uma arquitetura moderna e escalável, utilizando WordPress customizado em containers orquestrados por Kubernetes, com pipeline de CI/CD totalmente automatizado.
8
-
9
- ## 🏛️ **Arquitetura de Alto Nível**
10
+ ## Overview
10
11
 
11
12
  ```mermaid
12
13
  graph TB
13
- subgraph "👨‍💻 Desenvolvimento"
14
- DEV[Desenvolvedores]
14
+ subgraph "Developer"
15
+ DEV[Engineers]
15
16
  LOCAL[{{projectDomain}}<br/>Lando + Docker]
16
17
  end
17
18
 
18
- subgraph "🔄 CI/CD Pipeline"
19
- GITLAB[GitLab CI/CD]
20
- REGISTRY[Container Registry]
19
+ subgraph "CI / CD"
20
+ REPO[{{repositoryHost}}<br/>{{repositoryPath}}]
21
+ CI[{{ciSystem}}]
22
+ REG[{{ "{{TODO: container registry}}" }}]
21
23
  end
22
24
 
23
- subgraph "☁️ Cloud Infrastructure"
24
- CF[CloudFlare<br/>CDN + DNS]
25
- LB[Load Balancer<br/>OCI]
26
-
27
- subgraph "🎛️ Kubernetes Cluster"
28
- K8S_DEV[website-dev<br/>{{projectDevDomain}}]
29
- K8S_STG[website-stg<br/>{{projectStagingDomain}}]
30
- K8S_PROD[website-prod<br/>{{projectProductionDomain}}]
31
- end
32
-
33
- subgraph "💾 Persistence"
34
- DB[MySQL Database]
35
- STORAGE[File Storage]
36
- end
25
+ subgraph "Runtime"
26
+ EDGE[{{ "{{TODO: CDN / Edge}}" }}]
27
+ APP[{{ "{{TODO: app runtime}}" }}]
28
+ DB[(Database)]
29
+ STORE[{{ "{{TODO: object storage}}" }}]
37
30
  end
38
31
 
39
32
  DEV --> LOCAL
40
- DEV --> GITLAB
41
- GITLAB --> REGISTRY
42
- GITLAB --> K8S_DEV
43
- GITLAB --> K8S_STG
44
- GITLAB --> K8S_PROD
45
-
46
- CF --> LB
47
- LB --> K8S_DEV
48
- LB --> K8S_STG
49
- LB --> K8S_PROD
50
-
51
- K8S_DEV --> DB
52
- K8S_STG --> DB
53
- K8S_PROD --> DB
54
- K8S_DEV --> STORAGE
55
- K8S_STG --> STORAGE
56
- K8S_PROD --> STORAGE
33
+ DEV --> REPO
34
+ REPO --> CI
35
+ CI --> REG
36
+ REG --> APP
37
+ EDGE --> APP
38
+ APP --> DB
39
+ APP --> STORE
57
40
  ```
58
41
 
59
- ## 🛠️ **Stack Tecnológico Detalhado**
60
-
61
- ### **Frontend & CMS**
62
-
63
- | Componente | Tecnologia | Versão | Finalidade |
64
- | ------------- | ------------------------- | ------ | --------------------------------------- |
65
- | **CMS** | WordPress | Latest | Sistema de gerenciamento de conteúdo |
66
- | **Tema** | {{projectTitle}} Theme (Custom) | 1.1.7 | Interface e funcionalidades específicas |
67
- | **Blocks** | Gutenberg Custom Blocks | - | Blocos personalizados para editores |
68
- | **Languages** | PHP, JavaScript, CSS/Sass | - | Desenvolvimento frontend/backend |
69
-
70
- ### **Containerização & Orquestração**
71
-
72
- | Componente | Tecnologia | Versão | Finalidade |
73
- | ---------------- | ---------- | ------- | --------------------------------------- |
74
- | **Containers** | Docker | 20.0+ | Containerização da aplicação |
75
- | **Orquestração** | Kubernetes | 1.25+ | Gerenciamento de containers em produção |
76
- | **Dev Local** | Lando | 3.0+ | Ambiente de desenvolvimento local |
77
- | **🎯 Futuro** | **Helm** | **3.x** | **Gerenciamento de deployments K8s** |
78
-
79
- ### **CI/CD & DevOps**
80
-
81
- | Componente | Tecnologia | Versão | Finalidade |
82
- | ------------ | ------------------------- | ------ | ------------------------------- |
83
- | **CI/CD** | GitLab CI/CD | - | Pipeline automatizado |
84
- | **Registry** | GitLab Container Registry | - | Armazenamento de imagens Docker |
85
- | **IaC** | Terraform | 1.5+ | Infraestrutura como código |
86
- | **Secrets** | Kubernetes Secrets | - | Gerenciamento de credenciais |
42
+ ## Components
87
43
 
88
- ### **Infraestrutura Cloud**
44
+ ### Application layer
89
45
 
90
- | Componente | Tecnologia | Versão | Finalidade |
91
- | ------------------ | ------------------ | ------ | ---------------------------- |
92
- | **Cloud Provider** | OCI (Oracle Cloud) | - | Infraestrutura principal |
93
- | **CDN/DNS** | CloudFlare | - | CDN, DNS e proteção DDoS |
94
- | **Load Balancer** | OCI Load Balancer | - | Distribuição de tráfego |
95
- | **Database** | MySQL | 8.0+ | Banco de dados WordPress |
96
- | **Storage** | OCI Object Storage | - | Arquivos estáticos e uploads |
46
+ | Component | Technology | Notes |
47
+ | --- | --- | --- |
48
+ | CMS | WordPress {{wpCoreVersion}} | Composer-managed via Roots Bedrock layout |
49
+ {{#if useSage}}| Theme | Sage {{sageVersion}} + Acorn | Blade templating, Vite assets |
50
+ {{/if}}| Language runtime | PHP {{phpVersion}} | |
51
+ | Build pipeline | Node.js {{nodeVersion}} + Vite | |
97
52
 
98
- ## 🌍 **Ambientes e Namespaces**
53
+ ### Persistence
99
54
 
100
- ### **Estrutura de Ambientes**
55
+ | Component | Technology | Notes |
56
+ | --- | --- | --- |
57
+ | Database | `{{ "{{TODO: MySQL / MariaDB / managed service}}" }}` | Local dev uses MariaDB via Lando |
58
+ | Object storage | `{{ "{{TODO: S3 / GCS / Azure Blob / NFS}}" }}` | For uploads, backups |
59
+ | Cache | `{{ "{{TODO: Redis / Memcached / none}}" }}` | Object cache, sessions |
101
60
 
102
- ```yaml
103
- # Kubernetes Namespaces Structure
104
- environments:
105
- local:
106
- url: '{{projectDomain}}'
107
- type: 'Lando Container'
108
- purpose: 'Desenvolvimento local'
109
-
110
- development:
111
- url: '{{projectDevDomain}}'
112
- namespace: 'website-dev'
113
- branch: 'development'
114
- auto_deploy: true
115
- purpose: 'Testes contínuos e integração'
116
-
117
- staging:
118
- url: '{{projectStagingDomain}}'
119
- namespace: 'website-stg'
120
- branch: 'staging'
121
- auto_deploy: false
122
- purpose: 'Homologação e testes finais'
123
-
124
- production:
125
- url: '{{projectProductionDomain}}'
126
- namespace: 'website-prod'
127
- branch: 'master'
128
- auto_deploy: false
129
- purpose: 'Site oficial em produção'
130
- ```
131
-
132
- ### **Recursos por Ambiente**
133
-
134
- | Recurso | Development | Staging | Production |
135
- | ------------------- | ----------- | ------- | ---------- |
136
- | **CPU Requests** | 100m | 200m | 500m |
137
- | **Memory Requests** | 256Mi | 512Mi | 1Gi |
138
- | **CPU Limits** | 500m | 1 | 2 |
139
- | **Memory Limits** | 512Mi | 1Gi | 2Gi |
140
- | **Replicas** | 1 | 1 | 3 |
141
- | **Storage** | 5Gi | 10Gi | 50Gi |
142
- | **Backup** | Daily | Daily | Hourly |
143
-
144
- ## 📁 **Estrutura de Arquivos Kubernetes**
145
-
146
- ### **Organização Atual (Kubernetes Nativo)**
147
-
148
- ```
149
- k8s/
150
- ├── 📂 base/ # Configurações base
151
- │ ├── 📄 deployment.yaml # Deployment principal
152
- │ ├── 📄 service.yaml # Service interno
153
- │ ├── 📄 ingress.yaml # Ingress controller
154
- │ ├── 📄 configmap.yaml # Configurações
155
- │ └── 📄 secret.yaml # Secrets (template)
156
- ├── 📂 environments/
157
- │ ├── 📂 development/ # Namespace website-dev
158
- │ │ ├── 📄 kustomization.yaml
159
- │ │ └── 📄 values-dev.yaml
160
- │ ├── 📂 staging/ # Namespace website-stg
161
- │ │ ├── 📄 kustomization.yaml
162
- │ │ └── 📄 values-stg.yaml
163
- │ └── 📂 production/ # Namespace website-prod
164
- │ ├── 📄 kustomization.yaml
165
- │ └── 📄 values-prod.yaml
166
- └── 📄 README.md
167
- ```
168
-
169
- ### **🎯 Estrutura Futura (Helm)**
170
-
171
- ```
172
- helm/
173
- ├── 📂 {{projectName}}/ # Chart principal
174
- │ ├── 📄 Chart.yaml # Metadados do chart
175
- │ ├── 📄 values.yaml # Valores padrão
176
- │ ├── 📂 templates/ # Templates Kubernetes
177
- │ │ ├── 📄 deployment.yaml
178
- │ │ ├── 📄 service.yaml
179
- │ │ ├── 📄 ingress.yaml
180
- │ │ ├── 📄 configmap.yaml
181
- │ │ └── 📄 secret.yaml
182
- │ └── 📂 charts/ # Sub-charts (se necessário)
183
- ├── 📂 environments/
184
- │ ├── 📄 values-dev.yaml # Valores para development
185
- │ ├── 📄 values-stg.yaml # Valores para staging
186
- │ └── 📄 values-prod.yaml # Valores para production
187
- └── 📄 README.md
188
- ```
189
-
190
- ## 🔄 **Pipeline de Deploy**
191
-
192
- ### **Workflow Atual (Kubernetes)**
193
-
194
- ```mermaid
195
- graph LR
196
- A[Git Push] --> B[GitLab CI/CD]
197
- B --> C[Build Image]
198
- C --> D[Push Registry]
199
- D --> E{Branch?}
200
-
201
- E -->|development| F[kubectl apply dev]
202
- E -->|staging| G[Manual Deploy STG]
203
- E -->|master| H[Manual Deploy PROD]
204
-
205
- F --> I[website-dev namespace]
206
- G --> J[website-stg namespace]
207
- H --> K[website-prod namespace]
208
-
209
- I --> L[{{projectDevDomain}}]
210
- J --> M[{{projectStagingDomain}}]
211
- K --> N[{{projectProductionDomain}}]
212
- ```
213
-
214
- ### **🎯 Pipeline Futuro (Helm)**
215
-
216
- ```mermaid
217
- graph LR
218
- A[Git Push] --> B[GitLab CI/CD]
219
- B --> C[Build Image]
220
- C --> D[Push Registry]
221
- D --> E{Branch?}
222
-
223
- E -->|development| F[helm upgrade dev]
224
- E -->|staging| G[helm upgrade stg]
225
- E -->|master| H[helm upgrade prod]
226
-
227
- F --> I[website-dev namespace]
228
- G --> J[website-stg namespace]
229
- H --> K[website-prod namespace]
230
-
231
- I --> L[{{projectDevDomain}}]
232
- J --> M[{{projectStagingDomain}}]
233
- K --> N[{{projectProductionDomain}}]
234
- ```
235
-
236
- ## 🛡️ **Segurança e Monitoramento**
237
-
238
- ### **Segurança**
239
-
240
- - **HTTPS Forçado**: Todos os ambientes com SSL/TLS
241
- - **CloudFlare Protection**: DDoS protection e WAF
242
- - **Kubernetes Secrets**: Credenciais criptografadas
243
- - **Network Policies**: Isolamento de namespaces
244
- - **RBAC**: Controle de acesso baseado em roles
245
-
246
- ### **Monitoramento**
247
-
248
- ```yaml
249
- # Health Checks Configurados
250
- health_checks:
251
- liveness_probe:
252
- path: '/wp-admin/admin-ajax.php'
253
- interval: 30s
254
- timeout: 5s
255
-
256
- readiness_probe:
257
- path: '/wp-json/wp/v2/'
258
- interval: 10s
259
- timeout: 3s
260
-
261
- startup_probe:
262
- path: '/'
263
- interval: 10s
264
- timeout: 30s
265
- ```
266
-
267
- ## 🗄️ **Persistência de Dados**
268
-
269
- ### **Banco de Dados**
270
-
271
- ```yaml
272
- # MySQL Configuration
273
- database:
274
- engine: 'MySQL 8.0+'
275
- storage: 'OCI Block Storage'
276
- backup_frequency: 'Hourly (Prod) / Daily (Others)'
277
- retention: '30 days'
278
- high_availability: true # Produção apenas
279
-
280
- connection_pooling:
281
- max_connections: 100
282
- pool_size: 20
283
- ```
284
-
285
- ### **Armazenamento de Arquivos**
286
-
287
- ```yaml
288
- # WordPress Uploads & Assets
289
- file_storage:
290
- type: 'OCI Object Storage'
291
- mount_path: '/app/dist/wp-content/uploads'
292
- access_mode: 'ReadWriteMany'
293
-
294
- backup:
295
- frequency: 'Daily'
296
- retention: '90 days'
297
-
298
- cdn_integration:
299
- provider: 'CloudFlare'
300
- cache_ttl: '1 hour'
301
- ```
302
-
303
- ## 🚀 **Plano de Migração para Helm**
304
-
305
- ### **🎯 Objetivos da Migração**
306
-
307
- - **Simplificação**: Deploy mais simples com `helm upgrade`
308
- - **Versionamento**: Controle de versões de releases
309
- - **Rollback**: Rollback automatizado em caso de problemas
310
- - **Reutilização**: Templates reutilizáveis entre ambientes
311
- - **Ecosystem**: Integração com ecosystem Helm
312
-
313
- ### **📅 Cronograma Planejado**
314
-
315
- ```mermaid
316
- gantt
317
- title Migração Kubernetes → Helm
318
- dateFormat YYYY-MM-DD
319
- section Preparação
320
- Criação Charts Base :prep1, 2025-07-01, 2025-07-15
321
- Templates Conversion :prep2, after prep1, 10d
322
- section Ambientes
323
- Development Migration :dev, after prep2, 5d
324
- Staging Migration :stg, after dev, 5d
325
- Production Migration :prod, after stg, 10d
326
- section Finalização
327
- Documentation Update :docs, after prod, 5d
328
- Team Training :train, after docs, 5d
329
- ```
330
-
331
- ### **🔄 Estratégia de Migração**
332
-
333
- 1. **Fase 1**: Criação dos Helm Charts baseados nos YAMLs atuais
334
- 2. **Fase 2**: Teste em ambiente de Development
335
- 3. **Fase 3**: Migração Staging com validação completa
336
- 4. **Fase 4**: Migração Production com strategy Blue/Green
337
- 5. **Fase 5**: Cleanup dos manifestos K8s antigos
338
-
339
- ### **✅ Benefícios Esperados**
340
-
341
- - **Deploy**: Redução de 50% no tempo de deploy
342
- - **Manutenção**: Código mais limpo e organizados
343
- - **Debugging**: Melhor rastreabilidade de mudanças
344
- - **Collaboration**: Facilita contribuições da equipe
345
- - **Standards**: Alinhamento com padrões da indústria
346
-
347
- ## 🔧 **Comandos de Infraestrutura**
348
-
349
- ### **Kubernetes Atual**
350
-
351
- ```bash
352
- # Deploy para diferentes ambientes
353
- kubectl apply -f k8s/environments/development/ -n website-dev
354
- kubectl apply -f k8s/environments/staging/ -n website-stg
355
- kubectl apply -f k8s/environments/production/ -n website-prod
356
-
357
- # Verificar status
358
- kubectl get pods -n website-prod
359
- kubectl get services -n website-prod
360
- kubectl get ingress -n website-prod
361
-
362
- # Logs e debugging
363
- kubectl logs -f deployment/{{projectName}} -n website-prod
364
- kubectl describe pod <pod-name> -n website-prod
365
- ```
366
-
367
- ### **🎯 Helm Futuro**
368
-
369
- ```bash
370
- # Deploy usando Helm
371
- helm upgrade --install {{projectName}}-dev ./helm/{{projectName}} -f helm/environments/values-dev.yaml -n website-dev
372
- helm upgrade --install {{projectName}}-stg ./helm/{{projectName}} -f helm/environments/values-stg.yaml -n website-stg
373
- helm upgrade --install {{projectName}}-prod ./helm/{{projectName}} -f helm/environments/values-prod.yaml -n website-prod
374
-
375
- # Verificar releases
376
- helm list -n website-prod
377
- helm status {{projectName}}-prod -n website-prod
378
-
379
- # Rollback se necessário
380
- helm rollback {{projectName}}-prod 1 -n website-prod
381
- ```
61
+ ### Edge / delivery
382
62
 
383
- ## 📊 **Métricas e Performance**
63
+ | Component | Technology | Notes |
64
+ | --- | --- | --- |
65
+ | CDN | `{{ "{{TODO}}" }}` | |
66
+ | DNS | `{{ "{{TODO}}" }}` | |
67
+ | TLS termination | `{{ "{{TODO}}" }}` | |
68
+ | WAF | `{{ "{{TODO}}" }}` | |
384
69
 
385
- ### **SLAs Definidos**
70
+ ### Build / deploy
386
71
 
387
- | Métrica | Development | Staging | Production |
388
- | ----------------- | ----------- | ------- | ---------- |
389
- | **Uptime** | 95% | 99% | 99.9% |
390
- | **Response Time** | < 2s | < 1.5s | < 1s |
391
- | **Error Rate** | < 5% | < 2% | < 0.5% |
392
- | **Deploy Time** | < 5min | < 10min | < 15min |
72
+ | Component | Technology | Notes |
73
+ | --- | --- | --- |
74
+ | CI/CD | {{ciSystem}} | Pipelines defined in `.github/`, `.gitlab/`, or `bitbucket-pipelines.yml` |
75
+ | Container registry | `{{ "{{TODO}}" }}` | |
76
+ | Runtime platform | `{{ "{{TODO: Kubernetes / ECS / Fargate / nomad / SSH}}" }}` | |
77
+ | Infrastructure as code | `{{ "{{TODO: Terraform / Pulumi / CloudFormation / none}}" }}` | |
393
78
 
394
- ### **Recursos de Observabilidade**
79
+ ## Environments
395
80
 
396
- - **Health Checks**: Configurados em todos os pods
397
- - **Logs Centralizados**: Via GitLab CI/CD logs
398
- - **Alertas**: Configuração via Kubernetes events
399
- - **Dashboards**: Métricas de infraestrutura OCI
81
+ | Environment | URL | Purpose |
82
+ | --- | --- | --- |
83
+ | Local | https://{{projectDomain}} | Day-to-day development |
84
+ | Development | https://{{projectDevDomain}} | Integration / QA |
85
+ | Staging | https://{{projectStagingDomain}} | Pre-production validation |
86
+ | Production | https://{{projectProductionDomain}} | Live |
400
87
 
401
- ## 🎯 **Próximos Passos da Arquitetura**
88
+ Each non-local environment auto-deploys from a long-lived git branch —
89
+ see [Deploy-Pipeline](./Deploy-Pipeline.md).
402
90
 
403
- 1. **[Deploy Pipeline](Deploy-Pipeline)** - Processo detalhado de CI/CD
404
- 2. **[Infraestrutura](Infraestrutura)** - Configurações Terraform e OCI
405
- 3. **[Monitoramento](Monitoramento)** - Health checks e observabilidade
406
- 4. **[Helm Migration Guide](Helm-Migration)** - Guia da migração futura
91
+ ## Decision log
407
92
 
408
- ## 📞 **Suporte Técnico**
93
+ When making a stack decision, record it as an ADR (Architecture Decision
94
+ Record) under `docs/decisions/`. Each ADR captures **context, options
95
+ considered, decision, trade-offs, and revisit criteria**. ADRs let
96
+ future you understand *why* the architecture looks the way it does.
409
97
 
410
- - **Infraestrutura**: Equipe DevOps (ver [CODEOWNERS]({{repositoryWebUrl}}/-/blob/master/CODEOWNERS))
411
- - **Kubernetes Issues**: [GitLab Issues - Label: infrastructure]({{repositoryWebUrl}}/-/issues?label_name=infrastructure)
412
- - **Helm Planning**: [GitLab Issues - Label: helm-migration]({{repositoryWebUrl}}/-/issues?label_name=helm-migration)
98
+ `{{ "{{TODO: create docs/decisions/ and add ADR-001 for the first major decision}}" }}`
413
99
 
414
- ---
100
+ ## Cross-cutting concerns
415
101
 
416
- 📝 **Última atualização**: Junho 2025
417
- 🏗️ **Arquitetura atual**: Kubernetes nativo
418
- 🎯 **Próxima evolução**: Migração para Helm (Q3 2025)
419
- ☁️ **Cloud Provider**: OCI (Oracle Cloud Infrastructure)
420
- 🔄 **Pipeline**: GitLab CI/CD totalmente automatizado
102
+ - **Authentication / authorization**: `{{ "{{TODO}}" }}`
103
+ - **Background jobs**: `{{ "{{TODO: Action Scheduler / queue worker / cron}}" }}`
104
+ - **Search**: `{{ "{{TODO: native MySQL / Elasticsearch / Algolia}}" }}`
105
+ - **Email**: `{{ "{{TODO: SMTP provider / transactional service}}" }}`
106
+ - **Secrets management**: `{{ "{{TODO: env vars / Vault / cloud secret manager}}" }}`