108 lines
2.8 KiB
Markdown
108 lines
2.8 KiB
Markdown
---
|
|
name: ipa-init
|
|
description: Initialize IPA documentation by reverse-engineering an existing codebase that has no docs. Use when applying the IPA workflow to a running project, extracting API routes and DB schema from code, or generating a documentation baseline for legacy systems. Trigger phrases: "extract docs from code", "initialize ipa for existing project", "reverse engineer ipa docs".
|
|
---
|
|
|
|
## Overview
|
|
|
|
Generates IPA-standard documentation from an existing codebase with no docs. Scans code for API routes, DB schema, and UI screens, then infers SRD from business logic. Runs ipa-validate automatically after generation.
|
|
|
|
## When to Use
|
|
|
|
- Existing project has no IPA docs
|
|
- Existing project has partial docs that need enhancement
|
|
- Separate frontend/backend repos need combined docs
|
|
- Microservices architecture needs unified documentation baseline
|
|
|
|
## Don't Use When
|
|
|
|
- Starting a brand new project from scratch (use lean + ipa-spec)
|
|
- Implementation tasks are done and only sync is needed (use ipa-docs-sync)
|
|
|
|
## Supported Structures
|
|
|
|
```
|
|
# Monorepo
|
|
ipa-init
|
|
ipa-init ./my-project
|
|
|
|
# Separate FE/BE repos
|
|
ipa-init ./frontend ./backend
|
|
|
|
# Microservices
|
|
ipa-init ./user-service ./order-service ./payment-service
|
|
```
|
|
|
|
## Workflow
|
|
|
|
### Step 1: Detect Tech Stack
|
|
|
|
Scan for:
|
|
- `package.json` → Node.js ecosystem
|
|
- `requirements.txt` / `pyproject.toml` → Python
|
|
- `go.mod` → Go
|
|
- `Cargo.toml` → Rust
|
|
|
|
Auto-detect framework, ORM, and UI library. Save to `docs/tech-stack.md` if not exists.
|
|
|
|
### Step 2: Extract API Routes → API_SPEC.md
|
|
|
|
Scan for route definitions across frameworks (Express, NestJS, FastAPI, etc.).
|
|
|
|
### Step 3: Extract DB Schema → DB_DESIGN.md
|
|
|
|
Scan for schema definitions (Drizzle, Prisma, raw SQL, etc.).
|
|
|
|
### Step 4: Extract UI Screens → UI_SPEC.md
|
|
|
|
Scan for page components (Next.js `app/page.tsx`, React routes, etc.).
|
|
|
|
### Step 5: Infer SRD.md
|
|
|
|
From collected data, infer:
|
|
- Entities (E-xx): From DB tables
|
|
- Features (FR-xx): From API endpoints grouped by resource
|
|
- Screens (S-xx): From UI pages
|
|
|
|
### Step 6: Auto-Validate
|
|
|
|
Run ipa-validate logic automatically.
|
|
|
|
## After Generation
|
|
|
|
```
|
|
ipa-init complete
|
|
↓
|
|
Auto-validation ran
|
|
↓
|
|
Review generated docs and validation report
|
|
↓
|
|
Enhance manually:
|
|
- Add business context to SRD
|
|
- Add CJX to UI_SPEC
|
|
- Fix any validation warnings
|
|
↓
|
|
Ready for:
|
|
- lean [new feature] to extend
|
|
- plan to create tasks
|
|
```
|
|
|
|
## Usage
|
|
|
|
```
|
|
# Initialize IPA docs
|
|
ipa-init
|
|
|
|
# Force regenerate (overwrite existing)
|
|
ipa-init --force
|
|
```
|
|
|
|
## Important Notes
|
|
|
|
1. Review generated docs — auto-inference is not perfect
|
|
2. Add business context — code doesn't capture "why"
|
|
3. Enhance CJX manually — user journeys need human input
|
|
4. SRD business rules need domain knowledge
|
|
|
|
Does not implement code — only generates documentation.
|