{"id":51024537,"url":"https://github.com/hgurung/ai-application-factory","last_synced_at":"2026-06-21T18:30:48.353Z","repository":{"id":357891096,"uuid":"1237934665","full_name":"hgurung/ai-application-factory","owner":"hgurung","description":"AI-powered code generation pipeline with parallel validation, BullMQ job queue, and blue-green deployment","archived":false,"fork":false,"pushed_at":"2026-05-14T17:22:06.000Z","size":214,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-14T19:13:21.155Z","etag":null,"topics":["ai","blue-green-deployment","bullmq","docker","monorepo","nestjs","nginx","nx","postgresql","redis","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hgurung.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-13T16:44:20.000Z","updated_at":"2026-05-14T17:22:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hgurung/ai-application-factory","commit_stats":null,"previous_names":["hgurung/ai-application-factory"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/hgurung/ai-application-factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgurung%2Fai-application-factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgurung%2Fai-application-factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgurung%2Fai-application-factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgurung%2Fai-application-factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hgurung","download_url":"https://codeload.github.com/hgurung/ai-application-factory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgurung%2Fai-application-factory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34622271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","blue-green-deployment","bullmq","docker","monorepo","nestjs","nginx","nx","postgresql","redis","typescript"],"created_at":"2026-06-21T18:30:46.476Z","updated_at":"2026-06-21T18:30:48.348Z","avatar_url":"https://github.com/hgurung.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI Application Factory\n\nAn autonomous code generation pipeline — describe a feature in plain English, get production-ready NestJS code generated by Claude AI, validated across 5 quality dimensions in parallel, and deployed with zero downtime.\n\n---\n\n## Architecture\n\n```\nClient\n  │\n  ▼\nnginx (reverse proxy)\n  │\n  ├── /api/jobs  ──────────────────────► generator-agent\n  │                                           │\n  │                                    BullMQ Queue (Redis)\n  │                                           │\n  │                                      Job Worker\n  │                                           │\n  │                              ┌────────────▼────────────┐\n  │                              │    Claude AI / Mock      │\n  │                              │    Code Generator        │\n  │                              └────────────┬────────────┘\n  │                                           │\n  │                              ┌────────────▼────────────┐\n  │                              │   validation-agent       │\n  │                              │                          │\n  │                              │  SecurityValidator       │\n  │                              │  ArchitectureValidator   │\n  │                              │  PerformanceValidator    │ (parallel)\n  │                              │  TypeScriptValidator     │\n  │                              │  TestCoverageValidator   │\n  │                              └────────────┬────────────┘\n  │                                           │\n  │                                     PostgreSQL\n  │\n  └── /api/validate ──────────────────► validation-agent\n\n\nBlue-Green Deployment:\n  nginx → blue (live)   →  ./deploy-green.sh  →  nginx → green (live), blue stopped\n  nginx → green (live)  →  ./rollback-blue.sh →  nginx → blue (live), green stopped\n```\n\n---\n\n## Tech Stack\n\n| Layer | Technology |\n|-------|-----------|\n| Monorepo | Nx + NestJS |\n| Language | TypeScript |\n| Code Generation | Claude AI (Anthropic) with mock fallback |\n| Job Queue | BullMQ + Redis |\n| Database | PostgreSQL + TypeORM |\n| Reverse Proxy | nginx |\n| Deployment | Docker Compose with blue-green strategy |\n| Testing | Jest (unit tests for validators and services) |\n\n---\n\n## How It Works\n\n1. **POST /api/jobs** — client sends a `clientName` and `requirement` (e.g. \"payment module\"). The job is saved to PostgreSQL with status `pending` and enqueued into Redis. The API returns immediately.\n\n2. **BullMQ Worker** picks up the job asynchronously. It calls the Claude AI API (or a mock during development) to generate a NestJS module from the requirement.\n\n3. **Validation Pipeline** — the generated code is sent to `validation-agent`, which runs 5 validators simultaneously using `Promise.allSettled()`:\n   - **SecurityValidator** — checks for `eval()`, hardcoded secrets, missing guards\n   - **ArchitectureValidator** — checks for proper NestJS module structure\n   - **PerformanceValidator** — flags N+1 queries, missing pagination\n   - **TypeScriptValidator** — checks for `any` types, proper typing\n   - **TestCoverageValidator** — requires test files to be present\n\n4. **GET /api/jobs/:id** — client polls for the result. Final status is `done` (all validators passed) or `failed` (with a detailed error message showing which validators failed and why).\n\n---\n\n## Project Structure\n\n```\n.\n├── apps/\n│   ├── generator-agent/        # NestJS app — receives jobs, generates code\n│   │   └── src/job/\n│   │       ├── job.controller.ts\n│   │       ├── job.service.ts\n│   │       ├── job.processor.ts   # BullMQ worker\n│   │       ├── job.entity.ts\n│   │       └── generator.service.ts\n│   ├── validation-agent/       # NestJS app — parallel validation pipeline\n│   │   └── src/validation/\n│   │       ├── validation.service.ts\n│   │       └── validators/\n│   │           ├── security.validator.ts\n│   │           ├── architecture.validator.ts\n│   │           ├── performance.validator.ts\n│   │           ├── typescript.validator.ts\n│   │           └── test-coverage.validator.ts\n│   └── shared/                 # Shared types and DB config\n├── nginx/\n│   └── nginx.conf              # Swapped by deploy scripts\n├── deploy-green.sh             # Zero-downtime deploy to green slot\n├── rollback-blue.sh            # Instant rollback to blue slot\n└── docker-compose.yml\n```\n\n---\n\n## Quick Start\n\n**Prerequisites:** Docker Desktop, Node.js 20+\n\n```bash\n# Clone the repo\ngit clone https://github.com/harrisgurung/ai-application-factory.git\ncd ai-application-factory\n\n# Install dependencies\nnpm install\n\n# Start all services (nginx, postgres, redis, blue slot)\ndocker compose up -d --build\n\n# Submit a job\ncurl -X POST http://localhost/api/jobs \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"clientName\": \"Demo\", \"requirement\": \"user authentication module\"}'\n\n# Poll for result (use the id from above)\ncurl http://localhost/api/jobs/\u003cid\u003e\n\n# List all jobs\ncurl http://localhost/api/jobs\n```\n\n---\n\n## Environment Variables\n\nCreate a `.env` file at the root (copy from `.env.example`):\n\n```env\n# Toggle real Claude API vs mock generator\nUSE_CLAUDE=false\nCLAUDE_API_KEY=your-api-key-here\n\n# Database\nPOSTGRES_HOST=localhost\nPOSTGRES_PORT=5433\nPOSTGRES_USER=agent\nPOSTGRES_PASSWORD=password\nPOSTGRES_DB=agentdb\n\n# Redis\nREDIS_HOST=localhost\nREDIS_PORT=6379\n```\n\nSet `USE_CLAUDE=true` and add your Anthropic API key to use real AI generation. The mock generator works out of the box with no API key needed.\n\n---\n\n## Blue-Green Deployment\n\nThe system runs two identical slots — **blue** (live) and **green** (standby). Deployments switch traffic between them via nginx reload, giving zero downtime.\n\n```bash\n# Deploy new version to green, switch nginx, stop blue\n./deploy-green.sh\n\n# Instantly roll back to blue if anything goes wrong\n./rollback-blue.sh\n```\n\nThe deploy script:\n1. Builds and starts green containers\n2. Health checks green until it responds\n3. Writes new nginx config pointing to green directly into the container\n4. Reloads nginx gracefully (in-flight requests finish on blue)\n5. Stops blue\n\n---\n\n## Running Tests\n\n```bash\n# Run all unit tests\nnpx nx run-many --target=test --projects=generator-agent,validation-agent\n\n# Run tests for a single app\nnpx nx test validation-agent\nnpx nx test generator-agent\n```\n\nTests cover:\n- `SecurityValidator` — 8 cases including eval detection, hardcoded secrets, score floor\n- `ValidationService` — parallel execution, crashed validator handling, score averaging\n- `JobService` — repository calls, status transitions, data merging\n\n---\n\n## API Reference\n\n### POST /api/jobs\nSubmit a new code generation job.\n\n```json\n// Request\n{ \"clientName\": \"string\", \"requirement\": \"string\" }\n\n// Response (immediate — job is queued)\n{\n  \"id\": \"uuid\",\n  \"clientName\": \"Demo\",\n  \"requirement\": \"payment module\",\n  \"status\": \"pending\",\n  \"generatedCode\": null,\n  \"errorMessage\": null,\n  \"createdAt\": \"2026-05-13T10:00:00.000Z\",\n  \"updatedAt\": \"2026-05-13T10:00:00.000Z\"\n}\n```\n\n### GET /api/jobs/:id\nPoll for job result.\n\n```json\n// Response when complete\n{\n  \"id\": \"uuid\",\n  \"status\": \"done\" | \"failed\",\n  \"generatedCode\": \"import { Controller ... }\",\n  \"errorMessage\": null | \"Validation failed (score: 91). Issues: ...\"\n}\n```\n\n### GET /api/jobs\nList all jobs ordered by creation date (newest first).\n\n---\n\n## Author\n\n**Harris Gurung** — Senior Full Stack Engineer  \n12+ years building production systems across IoT, cloud, and enterprise platforms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhgurung%2Fai-application-factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhgurung%2Fai-application-factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhgurung%2Fai-application-factory/lists"}