Alchemy RecipeAdvancedworkflow

Technical specification document generation from business requirements

Published

Generating technical specification documents from business requirements is one of those tasks that sounds simple until you try it. A product manager writes up some requirements in a document, an engineer needs to turn that into technical specs, and somewhere in the middle, critical details get lost, assumptions go unstated, and inconsistencies creep in. The usual result is back-and-forth email threads and meetings to clarify what should have been obvious.

What if that entire process could run automatically? You'd feed in your business requirements, and out would come a properly formatted technical specification document with architecture diagrams, API endpoints, database schemas, and implementation notes, all without anyone manually translating between the two documents. For more on this, see Architecture design document creation from code repositories. For more on this, see Technical architecture diagram generation from codebase d.... For more on this, see Code migration documentation and technical debt assessment.

This workflow combines three specialised AI tools to make that happen. Bhava-AI extracts structured data from unstructured requirements; Windsurf generates the technical architecture and code artefacts; Mintlify formats everything into professional documentation. By wiring these together with an orchestration platform, you eliminate manual handoffs and get consistent, detailed specs every time.

The Automated Workflow

Why This Combination Works

Bhava-AI is purpose-built for understanding business context and extracting entities, relationships, and requirements from natural language. Windsurf excels at generating technical implementations and architectural thinking. Mintlify specialises in turning technical content into formatted, navigable documentation. Alone, each tool produces partial output. Together, they cover the full pipeline from business language to professional technical docs.

For orchestration, n8n is the strongest choice here because it handles complex branching logic and has good support for streaming responses from AI models. We'll also show how to adapt this to Zapier or Make if you prefer those platforms.

Step 1: Capture and Structure Requirements with Bhava-AI

Start with your business requirements document in any format: a Confluence page, Google Doc, email thread, or plain text. Bhava-AI's primary strength is parsing narrative context and extracting structured information.

The workflow begins with a webhook trigger that accepts a POST request containing your requirements document:

{
  "project_name": "Payment Processing API",
  "requirements_document": "The system must handle...",
  "stakeholders": ["product", "engineering", "compliance"],
  "deadline": "2025-06-01"
}

In n8n, set up an HTTP Node to receive this webhook. Then pass it to Bhava-AI using their API:


POST https://api.bhava.ai/v1/extract
Authorization: Bearer YOUR_BHAVA_API_KEY
Content-Type: application/json

{
  "document_content": {{$json.requirements_document}},
  "extraction_type": "technical_requirements",
  "output_format": "structured_json"
}
```......

Bhava-AI returns a structured object with extracted requirements:

```json
{
  "core_features": [
    {
      "feature_id": "f001",
      "name": "Payment Processing",
      "description": "Process credit card transactions...",
      "acceptance_criteria": [
        "Support Visa, Mastercard, Amex",
        "Transactions complete in < 2 seconds",
        "PCI-DSS compliant"
      ],
      "dependencies": ["authentication_service", "logging_service"],
      "priority": "critical"
    }
  ],
  "non_functional_requirements": {
    "performance": "Process 10,000 transactions/minute",
    "availability": "99.95% uptime",
    "security": "End-to-end encryption, PCI-DSS Level 1"
  },
  "constraints": ["Must use existing database", "No external payment gateways"],
  "stakeholder_concerns": ["Compliance team: regulatory audit trail"]
}

This structured extraction is the key step. Everything downstream depends on having clear, machine-readable requirements.

Step 2: Generate Technical Architecture with Windsurf

Once you have structured requirements, pass them to Windsurf to generate technical specifications. Windsurf is designed to take high-level requirements and produce detailed technical designs, code patterns, and architectural decisions.

In n8n, add a second API call to Windsurf:


POST https://api.windsurf.io/v1/generate-spec
Authorization: Bearer YOUR_WINDSURF_API_KEY
Content-Type: application/json

{
  "project_name": {{$json.project_name}},
  "requirements": {{$json.extract_result}},
  "specification_type": "detailed_technical_spec",
  "include_sections": [
    "system_architecture",
    "data_models",
    "api_endpoints",
    "error_handling",
    "security_considerations",
    "deployment_strategy"
  ],
  "output_format": "markdown"
}

Windsurf generates comprehensive markdown output that includes actual technical details:

## System Architecture

### Overview
The Payment Processing API follows a microservices architecture with the following components:

- API Gateway: Handles rate limiting and request routing
- Payment Service: Core transaction logic
- Vault Service: Secure card data storage
- Audit Service: Compliance logging

### Component [Diagram](/tools/diagram)
[ASCII or SVG diagram]

## API Endpoints

### POST /api/v1/payments/process
Processes a single payment transaction.

Request:

{ "card_token": "tok_123456", "amount": 9999, "currency": "GBP", "metadata": {} }


Response:

{ "transaction_id": "txn_789", "status": "succeeded", "processed_at": "2025-01-15T10:30:00Z" }


### Error Handling
- 400 Bad Request: Invalid card token or amount
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: Processing failure (retry with exponential backoff)

## Database Schema

```sql
CREATE TABLE transactions (
  id UUID PRIMARY KEY,
  card_token_id UUID NOT NULL REFERENCES card_tokens(id),
  amount DECIMAL(19,4) NOT NULL,
  status ENUM('pending', 'processing', 'succeeded', 'failed'),
  created_at TIMESTAMP DEFAULT NOW(),
  INDEX idx_status_created (status, created_at)
);

Security Considerations

  • All card data is tokenised and stored in a separate encrypted vault
  • API requests require mTLS certificates
  • All transactions are logged for audit compliance
  • Sensitive values are never logged; use tokenisation

This is [a real](/tools/a-real) technical specification. Windsurf doesn't just generate placeholder text; it produces actionable design documents that engineers can actually use.

**Step 3: Format into Professional Documentation with Mintlify**

The markdown from Windsurf is good, but Mintlify can transform it into searchable, navigable API documentation with syntax highlighting, auto-generated sidebars, and professional styling.

Add a third step in n8n to call Mintlify's API:

POST https://api.mintlify.com/v1/docs/generate Authorization: Bearer YOUR_MINTLIFY_API_KEY Content-Type: application/json

{ "project_name": {{$json.project_name}}, "markdown_content": {{$json.windsurf_output}}, "documentation_style": "api_spec", "features": { "auto_sidebar": true, "code_syntax_highlighting": true, "search_enabled": true, "dark_mode": true }, "branding": { "logo_url": "https://yourcompany.com/logo.png", "primary_colour": "#003366" } }


Mintlify returns a URL to your generated documentation site and optionally uploads it to a CDN or Git repository:

```json
{
  "documentation_url": "https://docs-payment-api-2025.mintlify.app",
  "git_commit_sha": "a3f8c2d1e",
  "uploaded_at": "2025-01-15T10:45:00Z",
  "sections": [
    {
      "title": "System Architecture",
      "url": "https://docs-payment-api-2025.mintlify.app/architecture"
    },
    {
      "title": "API Endpoints",
      "url": "https://docs-payment-api-2025.mintlify.app/endpoints"
    }
  ]
}

Now you have a fully professional, searchable documentation site generated entirely from your original business requirements.

Putting It Together in n8n

Here's the complete n8n workflow structure:

  1. HTTP Webhook Trigger Node: Listens for POST requests with requirements documents.

  2. Bhava-AI Extraction Node: Calls Bhava-AI to extract structured requirements from the document.

  3. Set Variables Node: Stores the extracted requirements for use in the next step.

  4. Windsurf Generation Node: Passes the structured requirements to Windsurf to generate technical specs.

  5. Mintlify Formatting Node: Takes the Windsurf output and formats it into professional documentation.

  6. Send Email Notification Node: Emails the product manager, tech lead, and relevant stakeholders with the documentation URL.

  7. Database Insert Node (optional): Stores the generated spec in your internal knowledge base for future reference.

The key to reliability is adding error handling between each step. If Bhava-AI fails to extract requirements (perhaps the document is too ambiguous), the workflow should pause and notify an engineer rather than passing bad data downstream.

In n8n, add a conditional node after Bhava-AI:

{
  "node_type": "If",
  "conditions": [
    {
      "condition": "core_features length > 0",
      "action": "continue_to_next_step"
    },
    {
      "condition": "core_features length = 0",
      "action": "send_alert_and_halt"
    }
  ]
}

Similarly, if Windsurf or Mintlify time out, retry with exponential backoff before failing.

The Manual Alternative

If you prefer not to automate this end-to-end, you can run the steps manually and still save time. For example:

  1. Paste your requirements into Bhava-AI's web interface and export the structured JSON.

  2. Copy that JSON into Windsurf's prompt box along with specific instructions about your tech stack.

  3. Take Windsurf's markdown output and upload it to Mintlify through their web dashboard.

This takes about 30-45 minutes per specification document and requires human oversight at each stage, but it avoids the complexity of setting up webhooks and orchestration. If you generate specs infrequently, this may be more practical than maintaining the automated workflow.......

However, once you have multiple projects or need to generate specs regularly, automation pays for itself quickly.

Pro Tips

Validate Extracted Requirements Early

Bhava-AI's extraction quality depends on the clarity of your input document. If your requirements are vague, scattered across multiple documents, or written in jargon unfamiliar to the model, extraction will fail silently. Always add a manual review step early in development, even if the workflow runs automatically later. Have a senior engineer review the Bhava-AI output for a few cycles and provide feedback to Bhava-AI's support team if extraction is consistently missing important details.

Handle Rate Limits and Timeouts

All three tools have rate limits. Bhava-AI typically allows 100 requests per minute on their standard plan; Windsurf allows 50; Mintlify allows 30. If you're processing multiple requirements documents in parallel, you'll hit these limits. In n8n, use the built-in Rate Limit node to queue requests at safe intervals. Set it to process no more than 5 specs per minute to stay well below all three limits.

Also, Windsurf sometimes takes 60 seconds or more to generate complex specs. Set your HTTP request timeout to at least 90 seconds and configure retry logic for 504 Gateway Timeout responses.

Store Generated Specs Alongside Source Requirements

After Mintlify uploads your documentation, store both the original requirements document and the generated spec URL in a structured database. Use a table like this:

CREATE TABLE specification_documents (
  id UUID PRIMARY KEY,
  project_name VARCHAR(255),
  requirements_document_path VARCHAR(500),
  requirements_extracted_at TIMESTAMP,
  specification_url VARCHAR(500),
  specification_generated_at TIMESTAMP,
  specification_version INT DEFAULT 1,
  created_by VARCHAR(255),
  created_at TIMESTAMP DEFAULT NOW()
);

This lets you track which specs are out of date (if the requirements document changes, you can regenerate automatically by checking modification timestamps) and provides an audit trail for compliance-sensitive projects.

Customise Windsurf's Output for Your Stack

Windsurf generates reasonable defaults for most tech stacks, but you'll get better results if you include technology constraints in your initial requirements. For example, if your requirement is "Build a payment API," Windsurf might suggest Golang and PostgreSQL. If your constraint is "Must run on .NET Core with SQL Server," that changes the generated spec significantly.

Modify the Windsurf API call to include technology preferences:

{
  "project_name": "Payment API",
  "requirements": {{$json.requirements}},
  "technical_constraints": {
    "primary_language": "Python",
    "framework": "FastAPI",
    "database": "PostgreSQL",
    "deployment_target": "Kubernetes"
  },
  "specification_type": "detailed_technical_spec"
}

Monitor Spec Generation Costs

Each tool call costs money, and a complex spec might require multiple API calls if Windsurf needs to regenerate sections or if Mintlify needs to re-upload. Set up cost tracking in n8n by logging API call counts and response times. Over a month, you'll build a model of average cost per spec. For most organizations, the cost is negligible (typically £2-5 per spec), but large enterprises running hundreds of specs monthly should monitor this.

One cost-saving tactic: cache Windsurf outputs. If the same core requirements (e.g., "Payment Processing API") are requested multiple times, store the Windsurf output in Redis with a 30-day TTL. This avoids re-generating the same spec for slightly different requirements variations.

Cost Breakdown

ToolPlan NeededMonthly CostNotes
Bhava-AIStandard£501000 extractions/month; £0.05 per additional extraction
WindsurfProfessional£120200 spec generations/month; £0.60 per additional
MintlifyTeam£150Unlimited documentation sites; includes CDN hosting
n8nSelf-Hosted or Cloud Pro£0–£200Self-hosted is free; Cloud Pro at £200/month includes 100k executions
Total (typical usage)£320–£520For 50 specs/month on Cloud n8n; cheaper if self-hosted

For teams generating 10 or fewer specs per month, the monthly cost is roughly £320 (assuming self-hosted n8n). For teams generating 100+ specs monthly, per-spec cost drops below £5 when spread across the team.

If you self-host n8n on a £5-10/month VPS, your total cost bottoms out at around £320 regardless of volume, making this economical even for small organizations.

More Recipes