# backlist-devops

**Unified DevOps CLI for create-backlist**

A comprehensive DevOps CLI that combines backend code generation (`create-backlist`) with production-grade deployment infrastructure (Docker, Kubernetes, Terraform, CI/CD).

## Features

### Backend Generation (create-backlist)
- AST-powered analysis of frontend code
- Support for 18+ backend stacks (Node.js, Python, Go, Rust, Java, C#, etc.)
- Auto-generated Prisma/TypeORM schemas
- Docker and CI/CD configuration

### DevOps Operations
- **Docker**: Build, run, compose
- **Kubernetes**: Deploy, scale, rollback, logs
- **Helm**: Chart management
- **Terraform**: Infrastructure as Code
- **CI/CD**: GitHub Actions, GitLab CI, Jenkins
- **Cloud**: AWS, Azure, GCP support

## Installation

### Option 1: NPM Package (Recommended)

```bash
npm install -g backlist-devops
```

### Option 2: From Source

```bash
# Clone repository
git clone https://github.com/WAH-ISHAN/backlist-npm.git
cd backlist-npm/backlist-devops

# Build Go binary (optional)
npm run build

# Link globally
npm link
```

## Quick Start

```bash
# Initialize project with backend + DevOps
backlist init

# Generate backend from frontend
backlist gen

# Check environment
backlist doctor

# Build and deploy
backlist deploy --k8s
```

## Unified CLI

### Single Entry Point

```bash
backlist <command> [options]
```

### Commands

| Command | Description |
|---------|-------------|
| `backlist gen` | Generate backend (create-backlist) |
| `backlist init` | Initialize project with backend + DevOps |
| `backlist deploy` | Deploy application |
| `backlist dev` | Start development mode |
| `backlist doctor` | Check environment |

### Docker Commands

```bash
backlist docker build           # Build image
backlist docker up             # Start containers
backlist docker down           # Stop containers
```

### Kubernetes Commands

```bash
backlist k8s apply             # Apply manifests
backlist k8s get pods          # List pods
backlist k8s logs              # View logs
```

### DevOps Commands

```bash
backlist devops build          # Build Docker images
backlist devops deploy         # Deploy to K8s
backlist devops infra plan     # Terraform plan
backlist devops ci run         # Run CI pipeline
```

## DevOps CLI (Standalone)

You can also use the DevOps CLI standalone:

```bash
# Using NPM package
npx backlist-devops devops --help

# Or link directly
npm link
devops --help
```

### DevOps Commands

| Command | Description |
|---------|-------------|
| `devops init` | Initialize DevOps project structure |
| `devops doctor` | Check environment dependencies |
| `devops build` | Build Docker images |
| `devops up` | Start development environment |
| `devops down` | Stop all services |
| `devops deploy` | Deploy to Kubernetes |
| `devops rollback` | Rollback to previous version |
| `devops status` | View deployment status |
| `devops logs` | Stream logs |
| `devops exec` | Execute command in container |
| `devops shell` | Shell into container |
| `devops clean` | Clean up resources |
| `devops helm` | Helm charts: create/install/upgrade/list/package |
| `devops infra` | Terraform operations |
| `devops ci` | CI/CD operations |
| `devops pipeline` | Full pipeline: test → build → deploy |
| `devops cloud` | Multi-cloud: status/aws/azure/gcp/eks/aks/gke |
| `devops monitor` | Observability: init/up/down/status/logs |
| `devops plugin` | Plugin management |

## Unified CLI (backlist)

`backlist` is the **All-in-One entry point** — backend generation, QA, and the entire DevOps engine behind a single command tree:

| Command | Description |
|---------|-------------|
| `backlist gen` | Generate backend from frontend (AST, 18+ stacks) |
| `backlist qa` | Real-browser QA: auto/scan/manual/history/post-gen |
| `backlist docker` | Docker: build/up/down/ps/logs/clean |
| `backlist k8s` | Kubernetes: deploy/rollback/scale/status/logs/top |
| `backlist helm` | Helm: create/install/upgrade/list/package/template |
| `backlist tf` | Terraform: init/plan/apply/destroy (alias: terraform, infra) |
| `backlist ci` | CI/CD: init/run/deploy/status |
| `backlist cloud` | Multi-cloud: status/login/aws/azure/gcp/eks/aks/gke |
| `backlist monitor` | Prometheus + Grafana: init/up/down/status/logs |
| `backlist deploy` | Full workflow: build → deploy [--k8s|--helm] [--qa] |
| `backlist pipeline` | Full pipeline: [--gen] [--qa] → test → build → deploy |
| `backlist init` | Backend + complete DevOps scaffold |
| `backlist doctor` | Toolchain check |
| `backlist dev` | Local development mode |

## Workflows

### 1. Full Stack Development

```bash
# 1. Analyze frontend and generate backend
backlist gen

# 2. Start local environment
backlist dev

# 3. Make changes to frontend
# 4. Regenerate backend if needed
backlist gen

# 5. Deploy
backlist deploy --production
```

### 2. Kubernetes Deployment

```bash
# 1. Initialize project
backlist init

# 2. Check environment
backlist doctor

# 3. Build and push image
devops build --tag myapp:v1.0.0

# 4. Deploy to Kubernetes
devops deploy --namespace production

# 5. Monitor
devops logs -f
devops status
```

### 3. Infrastructure as Code

```bash
# 1. Initialize Terraform
devops infra init

# 2. Plan changes
devops infra plan

# 3. Apply changes
devops infra apply

# 4. Deploy application
devops deploy
```

### 4. CI/CD Pipeline

```bash
# 1. Initialize CI/CD
devops ci init

# 2. Run pipeline locally
devops ci run

# 3. Deploy
devops ci deploy

# 4. Or the full pipeline in one shot
backlist pipeline --gen --qa
```

### 5. Helm Deployment

```bash
# 1. Scaffold a chart
backlist helm create myapp

# 2. Install the release
backlist helm install --namespace staging

# 3. Upgrade on new versions
backlist helm upgrade --namespace staging

# 4. Inspect & package
backlist helm list
backlist helm package myapp
```

### 6. Multi-Cloud

```bash
backlist cloud status                  # CLIs + identities + k8s context
backlist cloud login aws               # authenticate
backlist cloud eks myapp-cluster       # AWS EKS cluster
backlist cloud aks myapp-cluster       # Azure AKS cluster
backlist cloud gke myapp-cluster       # Google GKE cluster
backlist cloud aws s3 ls               # any provider CLI passthrough
```

### 7. Monitoring

```bash
backlist monitor init    # generate prometheus.yml + compose file
backlist monitor up      # Prometheus :9090 · Grafana :3001 · node-exporter · cAdvisor
backlist monitor status  # container health + scrape targets
backlist monitor logs    # stream observability logs
backlist monitor down    # stop the stack
```

## Architecture

```
┌─────────────────────────────────────────────────────────┐
│                    backlist CLI (npm)                   │
├─────────────────────────────────────────────────────────┤
│  backlist gen        → create-backlist (AST engine)    │
│  backlist qa         → Playwright QA engine            │
│  backlist docker/k8s/helm/tf/ci/cloud/monitor          │
│                     → DevOps engine (Go / Node.js)     │
└─────────────────────────────────────────────────────────┘
                         │
         ┌───────────────┼───────────────┐
         ▼               ▼               ▼
    ┌─────────┐     ┌─────────┐     ┌─────────┐
    │ Docker  │     │ K8s     │     │Terraform│
    └─────────┘     └─────────┘     └─────────┘
         │               │               │
         ▼               ▼               ▼
    ┌─────────┐     ┌─────────┐     ┌─────────┐
    │  Helm   │     │ Cloud   │     │ Monitor │
    └─────────┘     └─────────┘     └─────────┘
```

## Configuration

Create `devops.yml` in your project root:

```yaml
project:
  name: myapp
  version: 1.0.0

docker:
  context: .
  dockerfile: Dockerfile
  image: myapp
  tag: latest
  registry: ghcr.io/username

kubernetes:
  namespace: production
  manifests:
    - kubernetes/base

helm:
  chart: ./charts/myapp
  release: myapp

ci:
  provider: github

cloud:
  provider: aws
  region: us-west-2
```

## Comparison

| Feature | create-backlist | DevOps CLI | **backlist (All-in-One)** |
|---------|----------------|------------|-----------------|
| Backend Generation | ✅ | ❌ | ✅ |
| Docker Build | ✅ | ✅ | ✅ |
| Kubernetes Deploy | ❌ | ✅ | ✅ |
| Helm Charts | ❌ | ✅ | ✅ |
| Terraform IaC | ❌ | ✅ | ✅ |
| CI/CD Pipeline | ✅ | ✅ | ✅ |
| Multi-Cloud | ❌ | ✅ | ✅ |
| Monitoring | ❌ | ✅ | ✅ |
| QA Testing | ✅ | ❌ | ✅ |

## License

MIT - Built with ❤️ by W.A.H. ISHAN
