2.3 KiB
2.3 KiB
Hướng Dẫn Development
Cấu Trúc Dự Án
├── apps/ # Frontend applications
├── services/ # Backend microservices
├── packages/ # Shared libraries
├── infra/ # Infrastructure configs
├── deployments/ # Deployment configs
├── scripts/ # Automation scripts
└── docs/ # Documentation
Quy Trình Development
1. Tạo Feature Branch
git checkout -b feature/my-feature
2. Thực Hiện Thay Đổi
- Viết code tuân theo TypeScript strict mode
- Thêm tests cho chức năng mới
- Cập nhật tài liệu nếu cần
3. Chạy Tests Locally
# Tất cả tests
pnpm test
# Service cụ thể
pnpm --filter @goodgo/iam-service test
4. Lint và Format
pnpm lint
pnpm format
5. Tạo Pull Request
- Push branch của bạn
- Tạo PR target
develop - CI/CD sẽ chạy tự động
Thêm Service Mới
-
Sử dụng template:
./scripts/utils/create-service.sh my-new-service -
Cập nhật cấu hình service
-
Implement business logic
-
Thêm tests
-
Cập nhật tài liệu
Thêm Package Mới
- Tạo package trong
packages/new-package - Thêm vào workspace trong
pnpm-workspace.yaml - Export từ
index.ts - Thêm tests
- Ghi lại cách sử dụng
Database Migrations
Database Migrations
# Tạo migration (dev)
./scripts/db/migrate.sh iam-service dev
# Áp dụng migrations (production)
./scripts/db/migrate.sh iam-service deploy
Kubernetes Deployment
Local Kubernetes (Docker Desktop)
# Enable Kubernetes trong Docker Desktop
# Settings → Kubernetes → Enable Kubernetes
# Deploy service
cd deployments/local/kubernetes
./deploy.sh
# Verify deployment
kubectl get pods -n iam-local
kubectl logs -f -n iam-local -l app=iam-service
# Port forward để test
kubectl port-forward svc/iam-service 5002:80 -n iam-local
curl http://localhost:5002/health/live
Xem hướng dẫn chi tiết: Kubernetes Local Deployment Guide
Debugging
- Sử dụng logger từ
@goodgo/logger - Kiểm tra Traefik logs:
docker logs traefik-local - Kiểm tra service logs:
./scripts/dev/logs.sh iam-service