# ACC Services Migration - Quick Start Guide

**Total Services**: 33 (1 completed, 32 pending)
**Source**: Airtable `c60-Migration` base, table `CICD-Pipeline-Migration`

## 🚀 Get Started in 3 Steps

### Step 1: Clone All Repositories (5-10 minutes)

```bash
./scripts/clone-acc-services.sh
```

This clones all 32 pending ACC service repositories to:
`/Users/iakpabio/Desktop/git-code/tbi-code/`

### Step 2: Analyze Services (2-3 minutes)

```bash
./scripts/analyze-acc-services.sh
```

This generates `ACC-SERVICES-ANALYSIS.md` with:
- Technology stack (Node.js, Python, Java)
- Framework detection (NestJS, Express, FastAPI)
- Existing CI/CD status
- Entry points and dependencies

### Step 3: Start Migrating

Choose your approach:

#### Option A: Quick Wins (Recommended for First Day)
Start with **Batch 3: Gimmonix Services** (7 services, dev only)
- Simple, similar configuration
- Low risk (dev environment only)
- Fast to complete (~30-45 min each)

```bash
# Services to migrate:
# - tbi-acc-gimmonix-automation
# - tbi-acc-gimmonix-automation-cron
# - tbi-acc-gimmonix-automation-cron-2
# - tbi-acc-gimmonix-automation-cron-3
# - tbi-acc-gimmonix-automation-cron-4
# - tbi-acc-gimmonix-automation-cron-5
# - tbi-acc-gimmonix-automation-cron-6
```

#### Option B: High Priority Services
Start with **Batch 1: Core Services** (5 services, 6 environments each)
- Critical business services
- Higher complexity
- Longer to complete (~2-3 hours each)

```bash
# Services to migrate:
# - tbi-acc-hotel-service
# - tbi-acc-package-service
# - tbi-acc-hotel-service-connector
# - tbi-acc-travelbrandsagent
# - tbi-acc-profile-service
```

## 📋 Migration Workflow (Per Service)

### 1. Gather Information (5 min)

```bash
SERVICE_NAME="tbi-acc-booking-service"
SERVICE_DIR="/Users/iakpabio/Desktop/git-code/tbi-code/${SERVICE_NAME}"

# Check technology stack
cat ${SERVICE_DIR}/package.json | grep -A 5 '"scripts"'
cat ${SERVICE_DIR}/package.json | grep -A 5 '"dependencies"'

# Check for existing configs
ls -la ${SERVICE_DIR}/.circleci/
ls -la ${SERVICE_DIR}/Dockerfile
```

**Determine:**
- ✅ Namespace (redtag, access, privatelabel)
- ✅ Technology (Node.js 20, Python 3.11, etc.)
- ✅ Framework (NestJS, Express, FastAPI)
- ✅ Entry point (dist/main.js, dist/index.js)
- ✅ Environments (dev, qa, uat, prod)

### 2. Create CI/CD Config (15-20 min)

Use the reference service as template:
```bash
# Copy and modify from reference
cp -r dev/tbi-acc-hotel-mapping-service dev/${SERVICE_NAME}

# Update all files with new service name
# - .circleci/config.yml
# - docker/Dockerfile
# - scripts/deploy-services.sh
# - charts/[service-name]/
```

Or use the CircleCI Pipeline Deployment Agent for automation.

### 3. Create Values & Secrets (10-15 min)

```bash
cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments

# Create values file
cp dev/values/tbi-acc-hotel-mapping-service.yaml dev/values/${SERVICE_NAME}.yaml

# Create secrets file
cp dev/secrets/secrets.tbi-acc-hotel-mapping-service.yaml dev/secrets/secrets.${SERVICE_NAME}.yaml

# Update requirements.yaml
# Add entry for new service

# Encrypt secrets
sops -e -i dev/secrets/secrets.${SERVICE_NAME}.yaml
```

### 4. Create Service Repo Files (5 min)

```bash
cd ${SERVICE_DIR}

# Create VERSION file
echo "1.0.0" > VERSION

# Copy GitHub Actions workflow
mkdir -p .github/workflows
cp /path/to/template/manage-secrets.yml .github/workflows/
```

### 5. Commit & Push (5 min)

```bash
# tbi-devops-environments
cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-environments
git add dev/${SERVICE_NAME}
git commit -m "Add CI/CD pipeline for ${SERVICE_NAME}"
git push origin master

# tbi-environments
cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments
git add dev/values/${SERVICE_NAME}.yaml dev/secrets/secrets.${SERVICE_NAME}.yaml dev/requirements.yaml
git commit -m "Add values and secrets for ${SERVICE_NAME}"
git push origin master

# Service repository
cd ${SERVICE_DIR}
git checkout develop
git add VERSION .github/workflows/manage-secrets.yml
git commit -m "Add VERSION file and secrets workflow"
git push origin develop
```

### 6. Test Deployment (10-15 min)

```bash
# Trigger CircleCI by pushing to develop branch
# Monitor: https://app.circleci.com/pipelines/github/redlabelvacations

# Check deployment
kubectl get pods -n [namespace] | grep ${SERVICE_NAME}
kubectl logs -n [namespace] [pod-name]
kubectl get ingress -n [namespace] | grep ${SERVICE_NAME}
```

### 7. Document (5 min)

Update `AIRTABLE-MIGRATION-TRACKER.md`:
- Move service from "Pending" to "Completed"
- Add documentation link
- Note any issues encountered

## 📊 Progress Tracking

Track your progress in:
1. **AIRTABLE-MIGRATION-TRACKER.md** - Main tracker
2. **ACC-SERVICES-ANALYSIS.md** - Technical details
3. **Airtable** (optional) - Update source table

## 🎯 Recommended First Day Plan

**Goal**: Complete 3-5 services

1. **Morning** (2-3 hours):
   - Run clone script
   - Run analysis script
   - Review analysis report
   - Select first service

2. **Afternoon** (3-4 hours):
   - Migrate 2-3 Gimmonix services (quick wins)
   - Document learnings
   - Identify any blockers

3. **End of Day**:
   - Update tracker
   - Plan next batch
   - Note any questions for team

## 🔧 Tools & Resources

### Scripts
- `./scripts/clone-acc-services.sh` - Clone repositories
- `./scripts/analyze-acc-services.sh` - Analyze services

### Documentation
- `ACC-SERVICES-MIGRATION-PLAN.md` - Complete plan
- `AIRTABLE-MIGRATION-TRACKER.md` - Progress tracker
- `.kiro/steering/circleci-pipeline-patterns.md` - Patterns guide
- `docs/SETUP-COMPLETE-tbi-acc-hotel-mapping-service.md` - Reference

### Reference Service
- `dev/tbi-acc-hotel-mapping-service/` - Complete working example

### Agent
- `.kiro/agents/circleci-pipeline-deployment-agent.json` - Automation agent

## ⚠️ Common Issues

### Repository doesn't exist
**Solution**: May need to create new repository or check naming

### Can't determine entry point
**Solution**: Check package.json `start:prod` script

### Namespace unclear
**Solution**: Use `redtag` as default for ACC services

### Missing environment variables
**Solution**: Check existing deployment or ask team

## 📞 Need Help?

1. Check `.kiro/steering/circleci-pipeline-patterns.md` for patterns
2. Review reference service: `dev/tbi-acc-hotel-mapping-service/`
3. Use CircleCI Pipeline Deployment Agent for automation
4. Ask DevOps team for clarification

## 🎉 Success Criteria

For each service:
- ✅ CI/CD pipeline created in tbi-devops-environments
- ✅ Values and secrets created in tbi-environments
- ✅ VERSION file and workflow in service repository
- ✅ Successful deployment to dev environment
- ✅ Pod running and healthy
- ✅ Ingress configured (if needed)
- ✅ Documentation updated

---

**Ready to start?** Run `./scripts/clone-acc-services.sh` now!
