{
  "openapi": "3.1.0",
  "info": {
    "title": "SmartMakers AI & IoT Platform API",
    "version": "1.0.0",
    "description": "Machine-readable API specification for SmartMakers (https://smartmakers.net). Provides endpoints for interactive AI PM consultation, project inquiry analysis, and automated architecture scoping for AI First Product and IoT developments.",
    "contact": {
      "name": "SmartMakers Support",
      "url": "https://smartmakers.net/estimate",
      "email": "contact@smartmakers.net"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://smartmakers.net/privacy"
    }
  },
  "servers": [
    {
      "url": "https://smartmakers.net",
      "description": "Production Server"
    },
    {
      "url": "https://www.smartmakers.net",
      "description": "Production Server (Alternative Domain)"
    }
  ],
  "paths": {
    "/api/chat-gemini": {
      "post": {
        "summary": "Interactive AI PM Consultant Analysis",
        "description": "Analyzes a natural language service idea from the perspective of an experienced IT PM and returns structured SW, HW, and Admin architecture proposals.",
        "operationId": "chatGemini",
        "security": [
          {
            "OAuth2": [
              "ai:chat"
            ]
          },
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "message"
                ],
                "properties": {
                  "message": {
                    "type": "string",
                    "minLength": 5,
                    "description": "User service idea or requirements description.",
                    "example": "아파트 커뮤니티용 공유 세탁기 서비스 및 원격 제어 앱"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured AI consultation and proposal result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "string",
                      "description": "Overview insight and summary analysis",
                      "example": "제안해주신 아이디어를 분석했습니다. 성공적인 런칭을 위해 3가지 핵심 요소가 필요합니다."
                    },
                    "proposal": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "sw": {
                          "type": "object",
                          "properties": {
                            "title": {
                              "type": "string",
                              "example": "1. 서비스 앱 (S/W)"
                            },
                            "desc": {
                              "type": "string",
                              "example": "예약, 결제 시스템 및 푸시 알림 기능."
                            }
                          }
                        },
                        "hw": {
                          "type": "object",
                          "properties": {
                            "title": {
                              "type": "string",
                              "example": "2. IoT 모듈 (H/W)"
                            },
                            "desc": {
                              "type": "string",
                              "example": "진동 센서, 전력 제어 장치, ESP32 기반 텔레메트리."
                            }
                          }
                        },
                        "admin": {
                          "type": "object",
                          "properties": {
                            "title": {
                              "type": "string",
                              "example": "3. 관리자 대시보드"
                            },
                            "desc": {
                              "type": "string",
                              "example": "실시간 기기 상태 모니터링 및 매출 분석."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Message parameter missing or empty",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Message is required"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Method Not Allowed - Only POST supported"
          },
          "500": {
            "description": "Internal Server Error or AI Service failure",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "AI Service Failure"
                    },
                    "details": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/analyze-inquiry": {
      "post": {
        "summary": "Analyze Stored Project Inquiry",
        "description": "Analyzes a submitted client inquiry stored in Supabase KV and creates an automated ISMP project specification.",
        "operationId": "analyzeInquiry",
        "security": [
          {
            "OAuth2": [
              "ai:analyze"
            ]
          },
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "description": "Unique inquiry identifier stored in KV",
            "schema": {
              "type": "string",
              "example": "inq_123456789"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inquiry analysis successfully generated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "description": "Generated project plan data"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Inquiry not found in KV database",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Inquiry not found"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Method Not Allowed - Only POST supported"
          },
          "500": {
            "description": "Configuration or AI generation error"
          }
        }
      }
    },
    "/.well-known/oauth-protected-resource": {
      "get": {
        "summary": "RFC 9728 OAuth 2.0 Protected Resource Metadata",
        "description": "Machine-readable metadata declaring OAuth 2.0 scopes supported by this resource server.",
        "operationId": "getProtectedResourceMetadata",
        "responses": {
          "200": {
            "description": "OAuth 2.0 Protected Resource Metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "resource",
                    "scopes_supported"
                  ],
                  "properties": {
                    "resource": {
                      "type": "string",
                      "example": "https://smartmakers.net"
                    },
                    "authorization_servers": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "scopes_supported": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "bearer_methods_supported": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "resource_documentation": {
                      "type": "string",
                      "example": "https://smartmakers.net/openapi.json"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "description": "OAuth 2.0 authorization with scoped machine and user permissions.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://sfvbasiuqljkknqpdykw.supabase.co/auth/v1/authorize",
            "tokenUrl": "https://sfvbasiuqljkknqpdykw.supabase.co/auth/v1/token",
            "scopes": {
              "ai:chat": "Execute AI PM consultation and generate product architecture proposals",
              "ai:analyze": "Analyze customer project inquiry and generate ISMP analysis",
              "inquiries:read": "Read submitted client project inquiries and estimates",
              "inquiries:write": "Create or submit new project consultation inquiries",
              "estimates:create": "Submit cost and timeline estimate requests",
              "admin:all": "Full administrative access to SmartMakers platform management"
            }
          },
          "clientCredentials": {
            "tokenUrl": "https://sfvbasiuqljkknqpdykw.supabase.co/auth/v1/token",
            "scopes": {
              "ai:chat": "Execute AI PM consultation and generate product architecture proposals",
              "ai:analyze": "Analyze customer project inquiry and generate ISMP analysis",
              "inquiries:read": "Read submitted client project inquiries and estimates",
              "inquiries:write": "Create or submit new project consultation inquiries",
              "estimates:create": "Submit cost and timeline estimate requests",
              "admin:all": "Full administrative access to SmartMakers platform management"
            }
          }
        }
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "JWT Bearer token provided in Authorization header."
      },
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "API key or token authentication header."
      }
    }
  }
}