{
  "openapi": "3.1.0",
  "info": {
    "title": "Zill E Ali Public API",
    "version": "1.0.0",
    "summary": "Programmatic access to profile, services and technical articles.",
    "description": "Public REST API for zilleali.lovable.app — network engineering services, MikroTik/ISP/FTTH technical articles, and project enquiry submission. All read endpoints are open; scoped OAuth 2.1 access is available for authenticated agent use.",
    "contact": {
      "name": "Zill E Ali",
      "email": "zilleali1245@gmail.com",
      "url": "https://zilleali.lovable.app/contact"
    },
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    }
  },
  "servers": [
    {
      "url": "https://zilleali.lovable.app",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "profile",
      "description": "Owner profile and capabilities"
    },
    {
      "name": "services",
      "description": "Service catalogue"
    },
    {
      "name": "content",
      "description": "Blog articles"
    },
    {
      "name": "enquiries",
      "description": "Project enquiries"
    }
  ],
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "OAuth 2.1 authorization code flow with PKCE. Least-privilege named scopes.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://vthosizpunzgoplmijru.supabase.co/auth/v1/oauth/authorize",
            "tokenUrl": "https://vthosizpunzgoplmijru.supabase.co/auth/v1/oauth/token",
            "refreshUrl": "https://vthosizpunzgoplmijru.supabase.co/auth/v1/oauth/token",
            "scopes": {
              "openid": "Authenticate the calling user",
              "email": "Read the user's email address",
              "profile": "Read the user's basic profile",
              "profile:read": "Read the published owner profile",
              "content:read": "Read published articles and service catalogue",
              "enquiries:write": "Submit a project enquiry",
              "enquiries:read": "Read enquiries (owner only)"
            }
          }
        }
      },
      "openId": {
        "type": "openIdConnect",
        "openIdConnectUrl": "https://vthosizpunzgoplmijru.supabase.co/auth/v1/.well-known/openid-configuration"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "Service": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "Networking",
              "Infrastructure",
              "Software"
            ]
          },
          "summary": {
            "type": "string"
          },
          "deliverables": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "id",
          "name",
          "category",
          "summary"
        ]
      },
      "PostSummary": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "excerpt": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time"
          },
          "readingTime": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "slug",
          "title",
          "url"
        ]
      },
      "Post": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PostSummary"
          },
          {
            "type": "object",
            "properties": {
              "body": {
                "type": "string",
                "description": "Full article in Markdown"
              },
              "faqs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "q": {
                      "type": "string"
                    },
                    "a": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "EnquiryInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "company": {
            "type": "string",
            "maxLength": 120,
            "nullable": true
          },
          "service": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120
          },
          "budget": {
            "type": "string",
            "maxLength": 60,
            "nullable": true
          },
          "message": {
            "type": "string",
            "minLength": 10,
            "maxLength": 4000
          }
        },
        "required": [
          "name",
          "email",
          "service",
          "message"
        ]
      }
    }
  },
  "security": [
    {},
    {
      "oauth2": [
        "content:read"
      ]
    }
  ],
  "paths": {
    "/api/public/": {
      "get": {
        "tags": [
          "profile"
        ],
        "operationId": "getApiIndex",
        "summary": "API index and discovery document",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "Endpoint directory"
          }
        }
      }
    },
    "/api/public/profile": {
      "get": {
        "tags": [
          "profile"
        ],
        "operationId": "getProfile",
        "summary": "Owner profile, certifications and contact channels",
        "security": [
          {},
          {
            "oauth2": [
              "profile:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Profile document"
          }
        }
      }
    },
    "/api/public/services": {
      "get": {
        "tags": [
          "services"
        ],
        "operationId": "listServices",
        "summary": "List available services",
        "security": [
          {},
          {
            "oauth2": [
              "content:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "Networking",
                "Infrastructure",
                "Software"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Service list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Service"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/public/posts": {
      "get": {
        "tags": [
          "content"
        ],
        "operationId": "listPosts",
        "summary": "List published technical articles",
        "security": [
          {},
          {
            "oauth2": [
              "content:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Keyword search"
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Article list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PostSummary"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/public/posts/{slug}": {
      "get": {
        "tags": [
          "content"
        ],
        "operationId": "getPost",
        "summary": "Get one article with full Markdown body",
        "security": [
          {},
          {
            "oauth2": [
              "content:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Article",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Post"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/contact": {
      "post": {
        "tags": [
          "enquiries"
        ],
        "operationId": "submitEnquiry",
        "summary": "Submit a project enquiry",
        "security": [
          {},
          {
            "oauth2": [
              "enquiries:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnquiryInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Enquiry received"
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}