Project 34: Full-Stack Application Generator
Project 34: Full-Stack Application Generator
Build a comprehensive agent that generates entire full-stack applications from natural language specifications - database schema, API endpoints, frontend components, tests, and deployment configuration - all orchestrated through Kiro CLI.
Quick Reference
| Attribute | Value |
|---|---|
| Difficulty | Master (Level 5) |
| Time Estimate | 1 month+ |
| Primary Language | TypeScript |
| Alternative Languages | Python, Go |
| Prerequisites | Projects 1-20, deep understanding of full-stack architecture |
| Key Topics | Domain-driven design, code generation, API design, schema design, orchestration |
| Kiro CLI Concepts | Custom agents, PostgreSQL MCP, Docker MCP, hooks, subagents, steering |
| Main Book Reference | โDomain-Driven Designโ by Eric Evans |
1. Learning Objectives
By completing this project, you will:
- Master natural language specification parsing: Extract entities, relationships, and business rules from prose descriptions
- Implement domain-driven design with AI: Use AI to identify bounded contexts, aggregates, and domain events
- Build sophisticated code generation pipelines: Create consistent, maintainable code across all layers of the stack
- Orchestrate multi-layer application scaffolding: Coordinate database, API, and frontend generation with proper dependencies
- Integrate real-world deployment infrastructure: Generate Docker, CI/CD, and infrastructure-as-code configurations
2. Deep Theoretical Foundation
2.1 The Challenge of Specification Interpretation
Generating applications from natural language requires bridging the gap between human intent and machine-executable code:
THE SPECIFICATION INTERPRETATION CHALLENGE
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ NATURAL LANGUAGE INPUT โ
โ โโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ "Build a project management app where teams can create projects, โ
โ assign tasks to members, track progress with status updates, โ
โ and attach files to tasks. Teams should have owners and members โ
โ with different permissions." โ
โ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ INTERPRETATION LAYERS โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ โ โ
โ โ LAYER 1: Entity Extraction โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ Entities: Team, Project, Task, Member, StatusUpdate, File โ โ
โ โ Actors: Owner, Member โ โ
โ โ โ โ
โ โ LAYER 2: Relationship Mapping โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ Team 1:N Projects โ โ
โ โ Project 1:N Tasks โ โ
โ โ Task N:1 Member (assignee) โ โ
โ โ Task 1:N StatusUpdates โ โ
โ โ Task 1:N Files โ โ
โ โ Team N:M Members (through TeamMembership) โ โ
โ โ โ โ
โ โ LAYER 3: Business Rules โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โข Only team owners can delete projects โ โ
โ โ โข Members can only be assigned tasks in their teams โ โ
โ โ โข Status updates are append-only (audit trail) โ โ
โ โ โ โ
โ โ LAYER 4: Implicit Requirements โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โข Authentication required (implied by "permissions") โ โ
โ โ โข File storage needed (implied by "attach files") โ โ
โ โ โข Timestamps on all records (implied by "track progress") โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2.2 Domain-Driven Design with AI
Eric Evansโ DDD provides the conceptual framework for understanding complex domains. AI can accelerate this process:
DDD CONCEPTS FOR CODE GENERATION
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ BOUNDED CONTEXTS โ
โ โโโโโโโโโโโโโโโโ โ
โ โ
โ A large application should be divided into bounded contexts, โ
โ each with its own ubiquitous language and models. โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ TEAM CONTEXT โ โ PROJECT CONTEXT โ โ
โ โ โ โ โ โ
โ โ โข Team โ โ โข Project โ โ
โ โ โข Member โ โ โข Task โ โ
โ โ โข TeamMembership โ โ โข StatusUpdate โ โ
โ โ โข Permission โ โ โข Attachment โ โ
โ โ โ โ โ โ
โ โ Language: โ โ Language: โ โ
โ โ "invite", "role" โ โ "assign", "status" โ โ
โ โ "owner", "member" โ โ "progress", "due" โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ AGGREGATES โ
โ โโโโโโโโโโ โ
โ โ
โ An aggregate is a cluster of entities treated as a unit. โ
โ Changes to the aggregate go through the aggregate root. โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ TASK AGGREGATE โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโ โ โ
โ โ โ Task โ โโโโ Aggregate Root โ โ
โ โ โ (root) โ โ โ
โ โ โโโโโโฌโโโโโโ โ โ
โ โ โ โ โ
โ โ โโโโโโโดโโโโโโ โ โ
โ โ โ โ โ โ
โ โ โผ โผ โ โ
โ โ โโโโโโโโโโ โโโโโโโโโโ โ โ
โ โ โ Status โ โ File โ โ โ
โ โ โ Update โ โ โ โ โ
โ โ โโโโโโโโโโ โโโโโโโโโโ โ โ
โ โ โ โ
โ โ Operations: โ โ
โ โ โข task.addStatusUpdate(status, author) โ โ
โ โ โข task.attachFile(file) โ โ
โ โ โข task.assignTo(member) โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ DOMAIN EVENTS โ
โ โโโโโโโโโโโโโ โ
โ โ
โ Events represent something that happened in the domain. โ
โ They enable loose coupling and event sourcing. โ
โ โ
โ TaskCreated { taskId, projectId, title, createdBy } โ
โ TaskAssigned { taskId, assigneeId, assignedBy } โ
โ TaskStatusChanged { taskId, oldStatus, newStatus, changedBy } โ
โ FileAttached { taskId, fileId, fileName } โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2.3 The Generation Pipeline Architecture
Full-stack generation requires a coordinated pipeline:
FULL-STACK GENERATION PIPELINE
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ PHASE 1: DOMAIN MODELING โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Input: Natural language specification โ
โ Output: Domain model (entities, relationships, rules) โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ AI Analysis โ โ
โ โ โข Extract entities and their properties โ โ
โ โ โข Identify relationships (1:1, 1:N, N:M) โ โ
โ โ โข Infer business rules from context โ โ
โ โ โข Determine authentication/authorization needs โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ PHASE 2: SCHEMA GENERATION โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Input: Domain model โ
โ Output: Database schema (SQL migrations) โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ [PostgreSQL MCP] โ โ
โ โ โข Generate CREATE TABLE statements โ โ
โ โ โข Add proper indexes for relationships โ โ
โ โ โข Create migration files โ โ
โ โ โข Generate seed data for development โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ PHASE 3: API GENERATION โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Input: Domain model + schema โ
โ Output: REST/GraphQL endpoints โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ [API Subagent] โ โ
โ โ โข Generate route handlers (CRUD) โ โ
โ โ โข Add validation schemas (Zod) โ โ
โ โ โข Implement authentication middleware โ โ
โ โ โข Create authorization checks โ โ
โ โ โข Generate OpenAPI spec โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ PHASE 4: FRONTEND GENERATION โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Input: API spec + domain model โ
โ Output: React/Vue components โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ [Frontend Subagent] โ โ
โ โ โข Generate page components โ โ
โ โ โข Create form components with validation โ โ
โ โ โข Add data fetching hooks โ โ
โ โ โข Implement routing โ โ
โ โ โข Apply styling (Tailwind) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ PHASE 5: TESTING GENERATION โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Input: Generated code โ
โ Output: Test files โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ [Test Subagent] โ โ
โ โ โข Generate unit tests for services โ โ
โ โ โข Create integration tests for API โ โ
โ โ โข Add component tests for frontend โ โ
โ โ โข Generate E2E tests for critical flows โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ PHASE 6: DEPLOYMENT GENERATION โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Input: Application structure โ
โ Output: Docker, CI/CD, infrastructure config โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ [DevOps Subagent] โ โ
โ โ โข Create Dockerfile and docker-compose.yml โ โ
โ โ โข Generate GitHub Actions workflows โ โ
โ โ โข Add environment configuration โ โ
โ โ โข Create deployment scripts โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2.4 Code Generation Patterns
Consistent code generation requires well-defined patterns:
CODE GENERATION PATTERNS
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ TEMPLATE-BASED GENERATION โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Templates provide consistent structure while AI fills in specifics. โ
โ โ
โ Template: api/routes/[entity].ts โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ import { Router } from 'express'; โ โ
โ โ import { {{Entity}}Service } from '../services/{{entity}}'; โ โ
โ โ import { validate{{Entity}} } from '../validators/{{entity}}'; โ โ
โ โ โ โ
โ โ const router = Router(); โ โ
โ โ โ โ
โ โ router.get('/', async (req, res) => { โ โ
โ โ const items = await {{Entity}}Service.findAll(req.query); โ โ
โ โ res.json(items); โ โ
โ โ }); โ โ
โ โ โ โ
โ โ router.post('/', validate{{Entity}}, async (req, res) => { โ โ
โ โ const item = await {{Entity}}Service.create(req.body); โ โ
โ โ res.status(201).json(item); โ โ
โ โ }); โ โ
โ โ โ โ
โ โ // ... more CRUD operations โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ AI-AUGMENTED GENERATION โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ AI adds domain-specific logic that templates can't capture. โ
โ โ
โ Entity: Task with status transitions โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ // AI-generated business logic โ โ
โ โ class TaskService { โ โ
โ โ async updateStatus(taskId: string, newStatus: Status) { โ โ
โ โ const task = await this.findById(taskId); โ โ
โ โ โ โ
โ โ // AI understands valid state transitions โ โ
โ โ const validTransitions = { โ โ
โ โ 'todo': ['in_progress'], โ โ
โ โ 'in_progress': ['review', 'blocked'], โ โ
โ โ 'review': ['done', 'in_progress'], โ โ
โ โ 'blocked': ['in_progress'], โ โ
โ โ 'done': [] // Terminal state โ โ
โ โ }; โ โ
โ โ โ โ
โ โ if (!validTransitions[task.status].includes(newStatus)) { โ โ
โ โ throw new InvalidTransitionError(task.status, newStatus);โ โ
โ โ } โ โ
โ โ โ โ
โ โ return this.update(taskId, { status: newStatus }); โ โ
โ โ } โ โ
โ โ } โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ COMPOSITION PATTERNS โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Generated code should follow composition patterns for maintainability.โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โ Controller Layer โ โ
โ โ โโโ Handles HTTP request/response โ โ
โ โ โ โ โ
โ โ โผ โ โ
โ โ Service Layer โ โ
โ โ โโโ Business logic, validation โ โ
โ โ โ โ โ
โ โ โผ โ โ
โ โ Repository Layer โ โ
โ โ โโโ Data access, queries โ โ
โ โ โ โ โ
โ โ โผ โ โ
โ โ Database โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2.5 The 80/20 Rule of Code Generation
AI can generate 80% of boilerplate, but 20% requires human refinement:
THE 80/20 GENERATION BOUNDARY
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ AI CAN GENERATE (80%) HUMANS MUST REFINE (20%) โ
โ โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โ CRUD operations โ Complex business rules โ
โ โ Basic validations โ Edge case handling โ
โ โ Standard UI components โ Custom UI interactions โ
โ โ Database schema โ Performance optimization โ
โ โ Authentication boilerplate โ Security hardening โ
โ โ Basic test structure โ Meaningful test assertions โ
โ โ Docker configuration โ Production tuning โ
โ โ API routing โ API design decisions โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ THE REFINEMENT WORKFLOW โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ 1. AI generates initial scaffolding โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Generated: src/services/TaskService.ts โ โ
โ โ Status: SCAFFOLD - needs review โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ 2. Human reviews and identifies gaps โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ TODO: Add concurrent update handling โ โ
โ โ TODO: Implement soft delete โ โ
โ โ TODO: Add audit logging โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ 3. AI assists with refinements โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Human: "Add optimistic locking for concurrent updates" โ โ
โ โ AI: Adds version column and conflict detection โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ 4. Human validates final implementation โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Status: REVIEWED - ready for production โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
3. Complete Project Specification
3.1 What You Will Build
A Kiro CLI agent that:
- Accepts natural language application specifications
- Parses and models the domain (entities, relationships, rules)
- Generates complete database schema with migrations
- Creates REST API with authentication and authorization
- Scaffolds frontend with components and routing
- Generates comprehensive tests
- Creates deployment configuration
3.2 Functional Requirements
| Requirement | Description |
|---|---|
| Spec Parsing | Extract entities, relationships, and rules from natural language |
| Domain Modeling | Create bounded contexts and aggregates |
| Schema Generation | Produce PostgreSQL schema with migrations |
| API Generation | Create REST endpoints with validation |
| Frontend Scaffolding | Generate React/Next.js components |
| Test Generation | Create unit, integration, and E2E tests |
| Deploy Config | Generate Docker and CI/CD files |
| Documentation | Produce API docs and README |
3.3 Non-Functional Requirements
- Maintainability: Generated code follows best practices
- Consistency: Uniform patterns across all generated files
- Extensibility: Easy to add custom code without conflicts
- Type Safety: Full TypeScript support throughout
4. Solution Architecture
4.1 System Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FULL-STACK APPLICATION GENERATOR โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ CLI INTERFACE โ โ
โ โ โ โ
โ โ kiro-cli --agent app-generator โ โ
โ โ > "Generate a SaaS application for project management..." โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ SPECIFICATION ANALYZER โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Entity โ โ Relationship โ โ Business Rule โ โ โ
โ โ โ Extractor โ โ Mapper โ โ Detector โ โ โ
โ โ โ โ โ โ โ โ โ โ
โ โ โ โข Parse nouns โ โ โข 1:1, 1:N, N:Mโ โ โข Permissions โ โ โ
โ โ โ โข Properties โ โ โข Join tables โ โ โข Constraints โ โ โ
โ โ โ โข Types โ โ โข Foreign keys โ โ โข Workflows โ โ โ
โ โ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ GENERATION ORCHESTRATOR โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ SUBAGENT COORDINATOR โ โ โ
โ โ โ โ โ โ
โ โ โ Phase 1 Phase 2 Phase 3 Phase 4 โ โ โ
โ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โ
โ โ โ โ Schema โโโโถโ API โโโโถโFrontend โโโโถโ Test โ โ โ โ
โ โ โ โ Agent โ โ Agent โ โ Agent โ โ Agent โ โ โ โ
โ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โ
โ โ โ โ โ โ โ โ โ โ
โ โ โ โผ โผ โผ โผ โ โ โ
โ โ โ migrations/ src/api/ src/app/ __tests__/ โ โ โ
โ โ โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ MCP INTEGRATIONS โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ โ
โ โ โ PostgreSQL โ โ Docker MCP โ โ File System โ โ โ
โ โ โ MCP โ โ โ โ โ โ โ
โ โ โ โ โ โข Dockerfile โ โ โข Write filesโ โ โ
โ โ โ โข Schema โ โ โข Compose โ โ โข Create dirsโ โ โ
โ โ โ โข Migrations โ โ โข Networks โ โ โข Templates โ โ โ
โ โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
4.2 Domain Model Schema
// Core types for application specification
interface ApplicationSpec {
name: string;
description: string;
entities: EntitySpec[];
relationships: RelationshipSpec[];
features: FeatureSpec[];
auth: AuthSpec;
deployment: DeploymentSpec;
}
interface EntitySpec {
name: string;
pluralName: string;
properties: PropertySpec[];
isAggregate: boolean;
aggregateRoot?: string;
timestamps: boolean;
softDelete: boolean;
}
interface PropertySpec {
name: string;
type: DataType;
required: boolean;
unique: boolean;
default?: string | number | boolean;
validation?: ValidationRule[];
}
type DataType =
| 'string'
| 'text'
| 'integer'
| 'float'
| 'boolean'
| 'date'
| 'datetime'
| 'json'
| 'enum'
| 'uuid';
interface RelationshipSpec {
from: string;
to: string;
type: '1:1' | '1:N' | 'N:M';
throughTable?: string;
onDelete: 'cascade' | 'set-null' | 'restrict';
required: boolean;
}
interface FeatureSpec {
name: string;
type: 'auth' | 'file-upload' | 'search' | 'notifications' | 'audit-log';
config: Record<string, unknown>;
}
interface AuthSpec {
type: 'jwt' | 'session' | 'oauth';
providers?: ('google' | 'github' | 'email')[];
roles: RoleSpec[];
}
interface RoleSpec {
name: string;
permissions: PermissionSpec[];
}
interface PermissionSpec {
entity: string;
actions: ('create' | 'read' | 'update' | 'delete')[];
conditions?: string; // e.g., "own" or "team"
}
interface DeploymentSpec {
platform: 'docker' | 'kubernetes' | 'vercel' | 'railway';
database: 'postgresql' | 'mysql' | 'sqlite';
storage?: 's3' | 'local';
ci: 'github-actions' | 'gitlab-ci';
}
interface GenerationContext {
spec: ApplicationSpec;
outputDir: string;
framework: {
backend: 'express' | 'fastify' | 'nestjs';
frontend: 'nextjs' | 'react' | 'vue';
orm: 'prisma' | 'drizzle' | 'typeorm';
styling: 'tailwind' | 'css-modules' | 'styled-components';
};
options: {
generateTests: boolean;
generateDocs: boolean;
generateDocker: boolean;
};
}
4.3 Generated File Structure
GENERATED APPLICATION STRUCTURE
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ project-management-app/ โ
โ โ โ
โ โโโ prisma/ # Database layer โ
โ โ โโโ schema.prisma # Schema definition โ
โ โ โโโ migrations/ # Migration files โ
โ โ โโโ 001_create_users.sql โ
โ โ โโโ 002_create_teams.sql โ
โ โ โโโ ... โ
โ โ โ
โ โโโ src/ โ
โ โ โโโ api/ # API layer โ
โ โ โ โโโ routes/ โ
โ โ โ โ โโโ users.ts # User CRUD โ
โ โ โ โ โโโ teams.ts # Team CRUD โ
โ โ โ โ โโโ projects.ts # Project CRUD โ
โ โ โ โ โโโ tasks.ts # Task CRUD โ
โ โ โ โโโ middleware/ โ
โ โ โ โ โโโ auth.ts # Authentication โ
โ โ โ โ โโโ authorize.ts # Authorization โ
โ โ โ โ โโโ validate.ts # Validation โ
โ โ โ โโโ index.ts # API entry โ
โ โ โ โ
โ โ โโโ services/ # Business logic โ
โ โ โ โโโ UserService.ts โ
โ โ โ โโโ TeamService.ts โ
โ โ โ โโโ ProjectService.ts โ
โ โ โ โโโ TaskService.ts โ
โ โ โ โ
โ โ โโโ validators/ # Input validation โ
โ โ โ โโโ user.ts โ
โ โ โ โโโ team.ts โ
โ โ โ โโโ project.ts โ
โ โ โ โโโ task.ts โ
โ โ โ โ
โ โ โโโ types/ # TypeScript types โ
โ โ โโโ index.ts โ
โ โ โ
โ โโโ app/ # Frontend (Next.js) โ
โ โ โโโ (auth)/ โ
โ โ โ โโโ login/page.tsx โ
โ โ โ โโโ register/page.tsx โ
โ โ โโโ (dashboard)/ โ
โ โ โ โโโ projects/ โ
โ โ โ โ โโโ page.tsx # Project list โ
โ โ โ โ โโโ [id]/page.tsx # Project detail โ
โ โ โ โโโ tasks/ โ
โ โ โ โโโ [id]/page.tsx # Task detail โ
โ โ โโโ layout.tsx โ
โ โ โ
โ โโโ components/ # UI components โ
โ โ โโโ ui/ # Base components โ
โ โ โ โโโ Button.tsx โ
โ โ โ โโโ Input.tsx โ
โ โ โ โโโ Card.tsx โ
โ โ โโโ features/ # Feature components โ
โ โ โโโ ProjectCard.tsx โ
โ โ โโโ TaskList.tsx โ
โ โ โโโ TeamSelector.tsx โ
โ โ โ
โ โโโ __tests__/ # Tests โ
โ โ โโโ api/ # API tests โ
โ โ โโโ services/ # Service tests โ
โ โ โโโ e2e/ # End-to-end tests โ
โ โ โ
โ โโโ docker-compose.yml # Local dev environment โ
โ โโโ Dockerfile # Production build โ
โ โโโ .github/workflows/ # CI/CD โ
โ โ โโโ ci.yml โ
โ โ โโโ deploy.yml โ
โ โ โ
โ โโโ docs/ # Documentation โ
โ โโโ api.md # API documentation โ
โ โโโ architecture.md # Architecture overview โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
5. Phased Implementation Guide
Phase 1: Specification Parser (Days 1-7)
Goals:
- Parse natural language into structured spec
- Extract entities and properties
- Identify relationships
Tasks:
- Create ApplicationSpec schema
- Build entity extraction prompts
- Implement relationship detection
- Add validation for parsed spec
- Create spec preview for user approval
Milestone Checkpoint:
$ kiro-cli --agent app-generator
> "Create a blog app with posts, comments, and users"
[Parser] Analyzing specification...
[Entities Detected]
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Entity โ Properties โ Type โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ User โ id, email, name, password, avatar โ Aggregate Root โ
โ Post โ id, title, content, published โ Aggregate Root โ
โ Comment โ id, content, author_id, post_id โ Entity (of Post) โ
โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ
[Relationships]
โข User 1:N Posts (user writes many posts)
โข Post 1:N Comments (post has many comments)
โข User 1:N Comments (user writes many comments)
[Inferred Features]
โข Authentication (email/password)
โข Timestamps on all entities
โข Soft delete for posts
Proceed with this model? [Y/n]
Hint 1: Use few-shot prompting with example specifications to improve entity extraction accuracy.
Phase 2: Schema Generation (Days 8-14)
Goals:
- Generate Prisma schema from spec
- Create migration files
- Add seed data generation
Tasks:
- Map entities to Prisma models
- Generate relationships (1:1, 1:N, N:M)
- Add proper indexes
- Create migration SQL files
- Generate seed data script
Milestone Checkpoint:
> "Generate database schema"
[PostgreSQL MCP] Generating schema...
Created: prisma/schema.prisma
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ model User { โ
โ id String @id @default(uuid()) โ
โ email String @unique โ
โ name String โ
โ password String โ
โ avatar String? โ
โ posts Post[] โ
โ comments Comment[] โ
โ createdAt DateTime @default(now()) โ
โ updatedAt DateTime @updatedAt โ
โ } โ
โ โ
โ model Post { โ
โ id String @id @default(uuid()) โ
โ title String โ
โ content String โ
โ published Boolean @default(false) โ
โ author User @relation(fields: [authorId], ...) โ
โ authorId String โ
โ comments Comment[] โ
โ createdAt DateTime @default(now()) โ
โ updatedAt DateTime @updatedAt โ
โ } โ
โ ... โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Created: prisma/migrations/001_initial.sql
Created: prisma/seed.ts
Hint 2: Generate @map and @@map annotations for snake_case database columns while keeping camelCase in TypeScript.
Phase 3: API Generation (Days 15-21)
Goals:
- Generate CRUD endpoints for all entities
- Add authentication and authorization
- Create validation schemas
Tasks:
- Create route files for each entity
- Generate service layer with business logic
- Implement Zod validation schemas
- Add authentication middleware
- Generate OpenAPI documentation
Milestone Checkpoint:
> "Generate API layer"
[API Subagent] Generating endpoints...
Created API routes:
โโโ src/api/routes/users.ts (6 endpoints)
โโโ src/api/routes/posts.ts (6 endpoints)
โโโ src/api/routes/comments.ts (5 endpoints)
โโโ src/api/routes/auth.ts (3 endpoints)
API Summary:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Method โ Endpoint โ Auth โ Description โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ GET โ /api/posts โ No โ List all posts โ
โ GET โ /api/posts/:id โ No โ Get post by ID โ
โ POST โ /api/posts โ Yes โ Create new post โ
โ PUT โ /api/posts/:id โ Yes โ Update post (owner only) โ
โ DELETE โ /api/posts/:id โ Yes โ Delete post (owner only) โ
โ ... โ ... โ ... โ ... โ
โโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Created: docs/api.md (OpenAPI specification)
Phase 4: Frontend Generation (Days 22-28)
Goals:
- Generate page components
- Create form components
- Implement data fetching
Tasks:
- Create page routes (Next.js app router)
- Generate list and detail views
- Build form components with validation
- Add data fetching with React Query
- Apply Tailwind styling
Milestone Checkpoint:
> "Generate frontend"
[Frontend Subagent] Generating components...
Created pages:
โโโ app/(auth)/login/page.tsx
โโโ app/(auth)/register/page.tsx
โโโ app/(dashboard)/posts/page.tsx
โโโ app/(dashboard)/posts/[id]/page.tsx
โโโ app/(dashboard)/posts/new/page.tsx
โโโ app/(dashboard)/profile/page.tsx
Created components:
โโโ components/features/PostCard.tsx
โโโ components/features/PostForm.tsx
โโโ components/features/CommentList.tsx
โโโ components/ui/Button.tsx
โโโ components/ui/Input.tsx
โโโ components/ui/Card.tsx
Created hooks:
โโโ hooks/usePosts.ts
โโโ hooks/usePost.ts
โโโ hooks/useAuth.ts
Phase 5: Test and Deploy (Days 29-35)
Goals:
- Generate comprehensive tests
- Create Docker configuration
- Set up CI/CD
Tasks:
- Generate API integration tests
- Create service unit tests
- Add component tests
- Build Dockerfile and docker-compose
- Create GitHub Actions workflows
Hint 3: Generate test fixtures from the seed data to ensure consistency between development and testing.
6. Testing Strategy
6.1 Generated Test Structure
// Example generated test
describe('PostService', () => {
beforeEach(async () => {
await db.post.deleteMany();
await db.user.deleteMany();
});
describe('create', () => {
it('should create a post for authenticated user', async () => {
const user = await createTestUser();
const post = await PostService.create({
title: 'Test Post',
content: 'Test content',
authorId: user.id
});
expect(post.title).toBe('Test Post');
expect(post.authorId).toBe(user.id);
});
it('should require authentication', async () => {
await expect(PostService.create({
title: 'Test',
content: 'Test',
authorId: 'invalid-id'
})).rejects.toThrow('Unauthorized');
});
});
});
6.2 Validation Tests
| Aspect | Test | Pass Criteria |
|---|---|---|
| Schema | Migrations apply cleanly | No SQL errors |
| API | All endpoints respond correctly | 2xx responses for valid requests |
| Auth | Protected routes require auth | 401 for unauthenticated |
| Frontend | Pages render without errors | No React errors |
| E2E | Full user flow works | Create, read, update, delete |
7. Common Pitfalls and Debugging
7.1 Common Issues
| Pitfall | Symptom | Solution |
|---|---|---|
| Circular dependencies | Import errors | Separate entity types into base module |
| Missing relationships | Foreign key errors | Review spec for implicit relationships |
| Auth scope issues | Unauthorized errors | Check permission rules in spec |
| Type mismatches | TypeScript errors | Regenerate types from schema |
| Migration conflicts | Database errors | Reset and regenerate migrations |
7.2 Debugging Strategies
1. Validate spec before generation:
> "Show me the parsed specification"
[Spec Validation]
โโโ Entities: 4 (User, Post, Comment, Tag)
โโโ Relationships: 5
โโโ Business Rules: 3
โโโ Warnings:
โ โโโ Post.published has no default - assuming false
โ โโโ Comment.content has no max length - assuming 1000
โโโ Status: Valid (with warnings)
2. Incremental generation:
> "Generate only the User entity first"
# Verify User works before generating all entities
3. Test isolation:
> "Run tests for the API layer only"
[Test Runner]
โโโ src/api/__tests__/users.test.ts โ (12 tests)
โโโ src/api/__tests__/posts.test.ts โ (1 failure)
โ โโโ FAIL: should require auth for create
โ Expected 401, got 200
โโโ Fix: Authentication middleware not applied to POST /posts
8. Extensions and Challenges
8.1 Beginner Extensions
- Add GraphQL API as alternative to REST
- Generate Storybook stories for components
- Add i18n support with generated translation files
8.2 Intermediate Extensions
- Support for real-time features (WebSockets)
- Generate mobile app with React Native
- Add multi-tenant architecture support
8.3 Advanced Extensions
- AI-powered spec refinement through conversation
- Generate microservices architecture
- Support for event sourcing and CQRS patterns
9. Real-World Connections
9.1 Industry Tools
| Tool | Similar Pattern | Company |
|---|---|---|
| Blitz.js | Full-stack scaffolding | Blitz |
| RedwoodJS | Full-stack framework | Redwood |
| Amplication | Backend generation | Amplication |
| Supabase | Database + API | Supabase |
9.2 Production Considerations
- Customization: Generated code should be clearly marked and easy to extend
- Regeneration: Changes to spec should not overwrite custom code
- Testing: Generated tests are starting points, not complete coverage
- Security: Generated auth is basic - always add security hardening
10. Self-Assessment Checklist
Understanding Verification
- I can explain domain-driven design concepts
- I understand the 80/20 rule for code generation
- I can identify aggregates and bounded contexts
- I know when to use 1:1, 1:N, and N:M relationships
- I understand the generation pipeline phases
Implementation Verification
- Spec parser extracts entities correctly
- Relationships are detected and modeled
- Schema generates valid Prisma models
- API endpoints work with authentication
- Frontend renders and fetches data
- Tests pass for generated code
Integration Verification
- Full application runs with docker-compose
- CI/CD pipeline builds and deploys
- Generated code is maintainable
- Custom code can be added without conflicts
11. Completion Criteria
Minimum Viable Completion
- Parse specification and extract entities
- Generate database schema
- Create basic CRUD API
- Scaffold simple frontend pages
- Docker configuration works
Full Completion
- Complete authentication with roles
- Authorization on all endpoints
- Full frontend with forms and validation
- Comprehensive test coverage
- CI/CD pipeline
Excellence (Going Above and Beyond)
- AI-powered spec refinement
- Multiple framework support
- Real-time feature generation
- Custom code protection on regeneration
- Visual spec editor
This guide was expanded from LEARN_KIRO_CLI_MASTERY.md. For the complete learning path, see the README.