diff --git a/.github/workflows/ci-auth-service.yml b/.github/workflows/ci-iam-service.yml similarity index 79% rename from .github/workflows/ci-auth-service.yml rename to .github/workflows/ci-iam-service.yml index b5237983..e47a2cf8 100644 --- a/.github/workflows/ci-auth-service.yml +++ b/.github/workflows/ci-iam-service.yml @@ -1,13 +1,13 @@ -name: Auth Service CI +name: IAM Service CI on: push: paths: - - 'services/auth-service/**' + - 'services/iam-service/**' - 'packages/**' pull_request: paths: - - 'services/auth-service/**' + - 'services/iam-service/**' - 'packages/**' jobs: @@ -48,26 +48,26 @@ jobs: run: pnpm install --frozen-lockfile - name: Generate Prisma Client - run: pnpm --filter @goodgo/auth-service prisma:generate + run: pnpm --filter @goodgo/iam-service prisma:generate env: # Use Neon test DB if available, otherwise fallback to local PostgreSQL DATABASE_URL: ${{ secrets.NEON_DATABASE_URL_TEST != '' && secrets.NEON_DATABASE_URL_TEST || 'postgresql://testuser:testpass@localhost:5432/test_db' }} - name: Run migrations - run: pnpm --filter @goodgo/auth-service prisma migrate deploy + run: pnpm --filter @goodgo/iam-service prisma migrate deploy env: DATABASE_URL: ${{ secrets.NEON_DATABASE_URL_TEST != '' && secrets.NEON_DATABASE_URL_TEST || 'postgresql://testuser:testpass@localhost:5432/test_db' }} - name: Lint - run: pnpm --filter @goodgo/auth-service lint + run: pnpm --filter @goodgo/iam-service lint - name: Type check - run: pnpm --filter @goodgo/auth-service typecheck + run: pnpm --filter @goodgo/iam-service typecheck - name: Build - run: pnpm --filter @goodgo/auth-service build + run: pnpm --filter @goodgo/iam-service build - name: Test - run: pnpm --filter @goodgo/auth-service test + run: pnpm --filter @goodgo/iam-service test env: DATABASE_URL: ${{ secrets.NEON_DATABASE_URL_TEST != '' && secrets.NEON_DATABASE_URL_TEST || 'postgresql://testuser:testpass@localhost:5432/test_db' }} diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml index 3a4e29c6..b8508e7a 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-production.yml @@ -29,7 +29,7 @@ jobs: - name: Run database migrations run: | - cd services/auth-service + cd services/iam-service pnpm prisma generate pnpm prisma migrate deploy env: @@ -43,13 +43,13 @@ jobs: echo "${{ secrets.KUBECONFIG_PRODUCTION }}" | base64 -d > kubeconfig export KUBECONFIG=./kubeconfig - - name: Deploy Auth Service + - name: Deploy IAM Service run: | export KUBECONFIG=./kubeconfig - kubectl apply -f deployments/production/kubernetes/auth-service.yaml - kubectl apply -f deployments/production/kubernetes/configmap.yaml + kubectl apply -f deployments/production/kubernetes/iam-service.yaml + kubectl apply -f deployments/production/kubernetes/iam-service-configmap.yaml kubectl apply -f deployments/production/kubernetes/ingress.yaml - kubectl rollout status deployment/auth-service -n production + kubectl rollout status deployment/iam-service -n production - name: Deploy Web App run: | diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 749e9b14..ed262f7e 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -28,7 +28,7 @@ jobs: - name: Run database migrations run: | - cd services/auth-service + cd services/iam-service pnpm prisma generate pnpm prisma migrate deploy env: @@ -42,13 +42,13 @@ jobs: echo "${{ secrets.KUBECONFIG_STAGING }}" | base64 -d > kubeconfig export KUBECONFIG=./kubeconfig - - name: Deploy Auth Service + - name: Deploy IAM Service run: | export KUBECONFIG=./kubeconfig - kubectl apply -f deployments/staging/kubernetes/auth-service.yaml - kubectl apply -f deployments/staging/kubernetes/configmap.yaml + kubectl apply -f deployments/staging/kubernetes/iam-service.yaml + kubectl apply -f deployments/staging/kubernetes/iam-service-configmap.yaml kubectl apply -f deployments/staging/kubernetes/ingress.yaml - kubectl rollout status deployment/auth-service -n staging + kubectl rollout status deployment/iam-service -n staging - name: Deploy Web App run: | diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 81db41de..630c1aac 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,12 +6,12 @@ on: - main - develop paths: - - 'services/auth-service/**' + - 'services/iam-service/**' - 'apps/web-*/**' workflow_dispatch: jobs: - build-auth-service: + build-iam-service: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -25,16 +25,16 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push Auth Service + - name: Build and push IAM Service uses: docker/build-push-action@v5 with: - context: ./services/auth-service + context: ./services/iam-service push: true tags: | - goodgo/auth-service:latest - goodgo/auth-service:${{ github.sha }} - cache-from: type=registry,ref=goodgo/auth-service:buildcache - cache-to: type=registry,ref=goodgo/auth-service:buildcache,mode=max + goodgo/iam-service:latest + goodgo/iam-service:${{ github.sha }} + cache-from: type=registry,ref=goodgo/iam-service:buildcache + cache-to: type=registry,ref=goodgo/iam-service:buildcache,mode=max build-web-admin: runs-on: ubuntu-latest diff --git a/README.vi.md b/README.vi.md index 60bc0ed5..a5f17c0c 100644 --- a/README.vi.md +++ b/README.vi.md @@ -23,7 +23,7 @@ Monorepo này tuân theo mô hình kiến trúc microservices với: │ ├── app-admin/ # App admin (Flutter) │ └── app-client/ # App client (Flutter) ├── services/ # Backend microservices -│ ├── auth-service/ # Dịch vụ xác thực (Node.js) +│ ├── iam-service/ # Dịch vụ IAM (Identity & Access Management) (Node.js) │ └── _template/ # Template mẫu cho service mới ├── packages/ # Thư viện dùng chung │ ├── auth-sdk/ # Tiện ích xác thực và guards @@ -107,14 +107,14 @@ pnpm prisma:generate 3. **Chạy Migrations**: ```bash - ./scripts/db/migrate.sh auth-service dev + ./scripts/db/migrate.sh iam-service dev ``` 4. **Khởi động Services**: ```bash ./scripts/dev/start-all.sh # Hoặc khởi động service cụ thể: - # ./scripts/dev/start-service.sh auth-service + # ./scripts/dev/start-service.sh iam-service ``` ## 🛠️ Các Script Hỗ trợ diff --git a/deployments/local/env.local.example b/deployments/local/env.local.example index bab47e06..1059430a 100644 --- a/deployments/local/env.local.example +++ b/deployments/local/env.local.example @@ -76,7 +76,7 @@ EMAIL_FROM=noreply@goodgo.vn # --------------------------------- # The following are defined PER SERVICE in docker-compose.yml: # - PORT: Unique port for each service (5001, 5002, 5003, etc.) -# - SERVICE_NAME: Service identifier (auth-service, user-service, etc.) +# - SERVICE_NAME: Service identifier (iam-service, user-service, etc.) # - DATABASE_URL: Can override for service-specific database # # Traefik API Gateway: diff --git a/deployments/production/kubernetes/secrets.yaml.example b/deployments/production/kubernetes/secrets.yaml.example index 22c503e9..82e0abda 100644 --- a/deployments/production/kubernetes/secrets.yaml.example +++ b/deployments/production/kubernetes/secrets.yaml.example @@ -3,7 +3,7 @@ # Use this as a template to create secrets # Create secret using kubectl: -# kubectl create secret generic auth-service-secrets \ +# kubectl create secret generic iam-service-secrets \ # --from-literal=database-url='postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require&pgbouncer=true' \ # --from-literal=jwt-secret='your-production-jwt-secret-min-32-chars' \ # --from-literal=jwt-refresh-secret='your-production-refresh-secret-min-32-chars' \ @@ -18,7 +18,7 @@ apiVersion: v1 kind: Secret metadata: - name: auth-service-secrets + name: iam-service-secrets namespace: production type: Opaque stringData: diff --git a/deployments/staging/kubernetes/secrets.yaml.example b/deployments/staging/kubernetes/secrets.yaml.example index 0666a35e..df0fbb27 100644 --- a/deployments/staging/kubernetes/secrets.yaml.example +++ b/deployments/staging/kubernetes/secrets.yaml.example @@ -3,7 +3,7 @@ # Use this as a template to create secrets # Create secret using kubectl: -# kubectl create secret generic auth-service-secrets \ +# kubectl create secret generic iam-service-secrets \ # --from-literal=database-url='postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require&pgbouncer=true' \ # --from-literal=jwt-secret='your-staging-jwt-secret-min-32-chars' \ # --from-literal=jwt-refresh-secret='your-staging-refresh-secret-min-32-chars' \ @@ -18,7 +18,7 @@ apiVersion: v1 kind: Secret metadata: - name: auth-service-secrets + name: iam-service-secrets namespace: staging type: Opaque stringData: diff --git a/infra/databases/neon/README.md b/infra/databases/neon/README.md index 9e3432d2..605aae9e 100644 --- a/infra/databases/neon/README.md +++ b/infra/databases/neon/README.md @@ -67,7 +67,7 @@ postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require&pgbouncer= ### Development ```bash -cd services/auth-service +cd services/iam-service pnpm prisma migrate dev ``` diff --git a/infra/databases/neon/setup.sh b/infra/databases/neon/setup.sh index d326d18a..0ed9f27b 100755 --- a/infra/databases/neon/setup.sh +++ b/infra/databases/neon/setup.sh @@ -59,6 +59,6 @@ echo "" echo "1. Add staging URL to GitHub Secrets: NEON_DATABASE_URL_STAGING" echo "2. Add production URL to GitHub Secrets: NEON_DATABASE_URL_PRODUCTION" echo "3. Create Kubernetes secrets for staging/production" -echo "4. Run migrations: ./scripts/db/migrate.sh auth-service dev" +echo "4. Run migrations: ./scripts/db/migrate.sh iam-service dev" echo "" echo "✅ Setup complete! See infra/databases/neon/README.md for details." diff --git a/packages/logger/README.md b/packages/logger/README.md index b953b90a..f192bc3f 100644 --- a/packages/logger/README.md +++ b/packages/logger/README.md @@ -14,7 +14,7 @@ logger.error('Error occurred', { error: err }); // Create custom logger const customLogger = createLogger({ level: 'debug', - serviceName: 'auth-service', + serviceName: 'iam-service', enableFile: true, logDir: './logs', }); diff --git a/packages/tracing/README.md b/packages/tracing/README.md index 761b56d0..95abd59d 100644 --- a/packages/tracing/README.md +++ b/packages/tracing/README.md @@ -9,7 +9,7 @@ import { initTracing } from '@goodgo/tracing'; // Initialize tracing at application startup initTracing({ - serviceName: 'auth-service', + serviceName: 'iam-service', jaegerEndpoint: process.env.JAEGER_ENDPOINT, enabled: process.env.TRACING_ENABLED === 'true', }); diff --git a/scripts/db/backup.sh b/scripts/db/backup.sh index 4a98a638..6d76fb4e 100755 --- a/scripts/db/backup.sh +++ b/scripts/db/backup.sh @@ -9,7 +9,7 @@ BACKUP_DIR="${2:-./backups}" # VI: Xác thực tham số if [ -z "$SERVICE" ]; then echo "Usage: $0 [backup-dir]" - echo "Example: $0 auth-service" + echo "Example: $0 iam-service" exit 1 fi diff --git a/scripts/db/migrate.sh b/scripts/db/migrate.sh index 789d2c87..c034a9e1 100755 --- a/scripts/db/migrate.sh +++ b/scripts/db/migrate.sh @@ -10,8 +10,8 @@ SERVICE=$1 # VI: Xác thực tham số tên service if [ -z "$SERVICE" ]; then echo "Usage: $0 [dev|deploy] / Cách dùng: $0 [dev|deploy]" - echo "Example: $0 auth-service dev / Ví dụ: $0 auth-service dev" - echo "Example: $0 auth-service deploy / Ví dụ: $0 auth-service deploy" + echo "Example: $0 iam-service dev / Ví dụ: $0 iam-service dev" + echo "Example: $0 iam-service deploy / Ví dụ: $0 iam-service deploy" exit 1 fi diff --git a/scripts/db/seed.sh b/scripts/db/seed.sh index 92a81dd4..0ef340f6 100755 --- a/scripts/db/seed.sh +++ b/scripts/db/seed.sh @@ -8,7 +8,7 @@ SERVICE=$1 # VI: Xác thực tham số if [ -z "$SERVICE" ]; then echo "Usage: $0 " - echo "Example: $0 auth-service" + echo "Example: $0 iam-service" exit 1 fi diff --git a/scripts/db/setup-neon.sh b/scripts/db/setup-neon.sh index c19d4c50..12740bba 100755 --- a/scripts/db/setup-neon.sh +++ b/scripts/db/setup-neon.sh @@ -63,10 +63,10 @@ echo " See: deployments/staging/kubernetes/secrets.yaml.example" echo " See: deployments/production/kubernetes/secrets.yaml.example" echo "" echo "3. Run initial migration:" -echo " ./scripts/db/migrate.sh auth-service dev" +echo " ./scripts/db/migrate.sh iam-service dev" echo "" echo "4. Seed database (optional):" -echo " ./scripts/db/seed.sh auth-service" +echo " ./scripts/db/seed.sh iam-service" echo "" echo -e "${GREEN}✅ Setup instructions complete!${NC}" echo "" diff --git a/scripts/deploy/deploy-prod.sh b/scripts/deploy/deploy-prod.sh index 408c5391..1fa067c7 100755 --- a/scripts/deploy/deploy-prod.sh +++ b/scripts/deploy/deploy-prod.sh @@ -26,6 +26,6 @@ fi # EN: Apply Kubernetes configurations and wait for rollout # VI: Áp dụng cấu hình Kubernetes và đợi quá trình rollout hoàn tất kubectl apply -f deployments/production/kubernetes/ -kubectl rollout status deployment/auth-service -n production +kubectl rollout status deployment/iam-service -n production echo "✅ Deployment completed!" diff --git a/scripts/deploy/deploy-staging.sh b/scripts/deploy/deploy-staging.sh index de91ebff..3e13848f 100755 --- a/scripts/deploy/deploy-staging.sh +++ b/scripts/deploy/deploy-staging.sh @@ -14,6 +14,6 @@ fi # EN: Apply Kubernetes configurations and wait for rollout # VI: Áp dụng cấu hình Kubernetes và đợi quá trình rollout hoàn tất kubectl apply -f deployments/staging/kubernetes/ -kubectl rollout status deployment/auth-service -n staging +kubectl rollout status deployment/iam-service -n staging echo "✅ Deployment completed!" diff --git a/scripts/dev/logs.sh b/scripts/dev/logs.sh index da7a7ad6..03230e2e 100755 --- a/scripts/dev/logs.sh +++ b/scripts/dev/logs.sh @@ -6,7 +6,7 @@ SERVICE=$1 # VI: Kiểm tra cách sử dụng if [ -z "$SERVICE" ]; then echo "Usage: $0 / Cách dùng: $0 " - echo "Example: $0 auth-service" + echo "Example: $0 iam-service" echo "" echo "Or use 'docker' to view Docker logs: / Hoặc dùng 'docker' để xem log Docker:" echo " $0 docker " diff --git a/scripts/dev/setup-env.sh b/scripts/dev/setup-env.sh index 3d203667..b5ebe689 100755 --- a/scripts/dev/setup-env.sh +++ b/scripts/dev/setup-env.sh @@ -92,12 +92,12 @@ echo " - Set DATABASE_URL from Neon Console" echo " - Each service needs its own database" echo "" echo "3. Create databases in Neon:" -echo " - goodgo_auth_dev (for auth-service)" +echo " - goodgo_iam_dev (for iam-service)" echo " - goodgo_user_dev (for user-service)" echo " - etc." echo "" echo "4. Run migrations:" -echo " ./scripts/db/migrate.sh auth-service dev" +echo " ./scripts/db/migrate.sh iam-service dev" echo "" echo "5. Start development:" echo " ./scripts/dev/start-all.sh" diff --git a/scripts/dev/start-service.sh b/scripts/dev/start-service.sh index c293be66..98ff0350 100755 --- a/scripts/dev/start-service.sh +++ b/scripts/dev/start-service.sh @@ -8,7 +8,7 @@ SERVICE=$1 # VI: Xác thực tham số if [ -z "$SERVICE" ]; then echo "Usage: $0 " - echo "Example: $0 auth-service" + echo "Example: $0 iam-service" exit 1 fi diff --git a/scripts/setup/init-project.sh b/scripts/setup/init-project.sh index be6dcff9..b02c3a56 100755 --- a/scripts/setup/init-project.sh +++ b/scripts/setup/init-project.sh @@ -23,16 +23,15 @@ pnpm install # EN: Generate Prisma clients # VI: Tạo Prisma generic clients echo "🔧 Generating Prisma clients..." -cd services/auth-service +cd services/iam-service pnpm prisma:generate || echo "⚠️ Prisma generation skipped (database not available)" cd ../.. # EN: Setup environment files # VI: Thiết lập các file biến môi trường echo "📝 Setting up environment files..." -if [ ! -f "services/auth-service/.env" ]; then - cp services/auth-service/env.example services/auth-service/.env - echo "✅ Created services/auth-service/.env" +if [ ! -f "services/iam-service/.env" ]; then + cp services/iam-service/env.local.example services/iam-service/.env.local 2>/dev/null || echo "⚠️ IAM service .env file not found" fi if [ ! -f "deployments/local/.env.local" ]; then @@ -55,8 +54,8 @@ echo "Next steps:" echo "1. Setup Neon database: ./scripts/db/setup-neon.sh" echo "2. Update .env files with your Neon DATABASE_URL" echo "3. Start all services: ./scripts/dev/start-all.sh" -echo "4. Run migrations: ./scripts/db/migrate.sh auth-service dev" -echo "5. Seed database: ./scripts/db/seed.sh auth-service" +echo "4. Run migrations: ./scripts/db/migrate.sh iam-service dev" +echo "5. Seed database: ./scripts/db/seed.sh iam-service" echo "6. Start services: pnpm dev" echo "" echo "📚 See infra/databases/neon/README.md for Neon setup details" diff --git a/services/iam-service/docs/QUICK_START.md b/services/iam-service/docs/QUICK_START.md index d565d26e..8911bb1a 100644 --- a/services/iam-service/docs/QUICK_START.md +++ b/services/iam-service/docs/QUICK_START.md @@ -122,7 +122,7 @@ curl -X GET "http://localhost:4000/api/v1/rbac/permissions/check?resource=users& ```bash cd ../../deployments/local -docker-compose up -d auth-service +docker-compose up -d iam-service ``` ## 📚 Documentation