openapi: 3.0.3
info:
  title: SUMMIT PRD Agent API
  description: |
    Free, public API for generating structured Product Requirements Documents (PRDs) from unstructured brain-dump transcripts.
    No authentication required. Rate limited to 10 requests per hour per IP.
    
    Built by SUMMIT Business Automation — the implementation arm of AI Company USA.
  version: 1.0.0
  contact:
    name: SUMMIT Business Automation
    url: https://www.summitbusinessautomation.xyz
  license:
    name: Proprietary
    url: https://www.summitbusinessautomation.xyz/contact

servers:
  - url: https://www.summitbusinessautomation.xyz
    description: Production

paths:
  /api/prd/generate:
    post:
      operationId: generatePRD
      summary: Generate a PRD from a transcript
      description: |
        Accepts a natural-language brain-dump transcript about a product idea and returns
        a structured Product Requirements Document as JSON with 7 top-level fields: meta, one_liner, problem, solution, user_flow, success_metrics, tech_stack.
        
        Accepts both application/json and text/plain content types.
        
        For long transcripts, may return 202 Accepted with a polling URL.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - transcript
              properties:
                transcript:
                  type: string
                  description: The brain-dump transcript to analyze
                  minLength: 20
                  example: "I want to build an app that helps freelancers track their invoices. The main pain point is..."
          text/plain:
            schema:
              type: string
              description: The brain-dump transcript as plain text
              example: "I want to build an app that helps freelancers track their invoices..."
      responses:
        '200':
          description: PRD generated successfully
          headers:
            X-Powered-By:
              schema:
                type: string
                example: SUMMIT-PRD-v1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PRD'
        '202':
          description: Processing — poll the job URL for results
          headers:
            Location:
              schema:
                type: string
                example: /api/prd/jobs/abc123
            X-Powered-By:
              schema:
                type: string
                example: SUMMIT-PRD-v1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JobStatus'
        '400':
          description: Missing or invalid transcript
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (10 requests/hour)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /api/prd/generate/schema:
    get:
      operationId: getPRDSchema
      summary: Get the PRD JSON schema
      description: Returns the JSON schema describing all PRD fields, their types, and descriptions.
      responses:
        '200':
          description: PRD schema
          content:
            application/json:
              schema:
                type: object

  /api/prd/jobs/{jobId}:
    get:
      operationId: getPRDJobStatus
      summary: Check async PRD generation status
      description: Poll this endpoint for the result of a long-running PRD generation.
      parameters:
        - name: jobId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Job status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JobResult'
        '404':
          description: Job not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /api/blueprints:
    get:
      operationId: listBlueprints
      summary: List all published blueprints
      description: Returns the SUMMIT Blueprint Catalog — business-ready product specifications.
      parameters:
        - name: category
          in: query
          required: false
          schema:
            type: string
          description: Filter by category
      responses:
        '200':
          description: List of blueprints
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Blueprint'

  /api/blueprints/{id}:
    get:
      operationId: getBlueprint
      summary: Get a single blueprint
      description: Accepts a numeric ID or SKU string (e.g., "SBA-001").
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Blueprint details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Blueprint'
        '404':
          description: Blueprint not found

components:
  schemas:
    PRD:
      type: object
      properties:
        meta:
          type: object
          properties:
            project_name:
              type: string
            app_type:
              type: string
        one_liner:
          type: object
          properties:
            who:
              type: string
            verb:
              type: string
            what:
              type: string
            bridge:
              type: string
            outcome:
              type: string
        problem:
          type: object
          properties:
            statement:
              type: string
            who_feels_pain:
              type: string
            current_workaround:
              type: string
            pain_intensity:
              type: string
              enum: [Critical, High, Medium, Low, Aspirational]
            market_type:
              type: string
              enum: [B2C, B2B, B2B2C, Marketplace, Personal, Internal tool]
        solution:
          type: object
          properties:
            mvp_features:
              type: array
              items:
                type: string
            phase2_features:
              type: array
              items:
                type: string
            not_doing:
              type: string
        user_flow:
          type: object
          properties:
            steps:
              type: array
              items:
                type: string
            main_screen_ui:
              type: string
            data_flow:
              type: string
        success_metrics:
          type: object
          properties:
            personal:
              type: object
              properties:
                action:
                  type: string
                duration:
                  type: string
            commercial:
              type: object
              properties:
                count:
                  type: string
                action:
                  type: string
            launch_criteria:
              type: string
            target_timeline:
              type: string
        tech_stack:
          type: object
          properties:
            frontend:
              type: string
            backend:
              type: string
            hosting:
              type: string
            auth:
              type: string
            ai_automation:
              type: string
            payments:
              type: string
            other:
              type: string

    JobStatus:
      type: object
      properties:
        status:
          type: string
          enum: [processing]
        jobId:
          type: string
        poll:
          type: string

    JobResult:
      type: object
      properties:
        status:
          type: string
          enum: [processing, complete, error]
        jobId:
          type: string
        result:
          $ref: '#/components/schemas/PRD'
        error:
          type: string

    Blueprint:
      type: object
      properties:
        id:
          type: string
        sku:
          type: string
        name:
          type: string
        description:
          type: string
        category:
          type: string
        difficulty:
          type: string
        tags:
          type: array
          items:
            type: string

    Error:
      type: object
      properties:
        message:
          type: string
