{
  "openapi": "3.1.0",
  "info": {
    "title": "Personal Web Platform API",
    "version": "1.0.0",
    "description": "API của **Personal Web Platform** — FastAPI + PostgreSQL + Redis/Celery, xác thực bằng Keycloak (OIDC, Bearer JWT).\n\n**Trên trang bạn đang xem (Cloudflare Pages):** chỉ `POST /api/contact` chạy thật — được xử lý bởi một\nCloudflare Pages Function và gửi email qua Resend. Các endpoint còn lại chạy khi deploy đầy đủ bằng\nDocker Compose hoặc Kubernetes (Helm).\n\n**On this site (Cloudflare Pages):** only `POST /api/contact` is live (a Pages Function that emails the owner).\nThe other endpoints run in the full Docker Compose / Kubernetes deployment.\n\nMã nguồn: [github.com/huuhai28/web-platform](https://github.com/huuhai28/web-platform)\n"
  },
  "paths": {
    "/api/health": {
      "get": {
        "summary": "Health",
        "operationId": "health_api_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object",
                  "title": "Response Health Api Health Get"
                }
              }
            }
          }
        },
        "tags": [
          "ops"
        ]
      }
    },
    "/api/health/live": {
      "get": {
        "summary": "Liveness",
        "description": "Process còn sống. Kubernetes livenessProbe: lỗi → restart pod.",
        "operationId": "liveness_api_health_live_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object",
                  "title": "Response Liveness Api Health Live Get"
                }
              }
            }
          }
        },
        "tags": [
          "ops"
        ]
      }
    },
    "/api/health/ready": {
      "get": {
        "summary": "Readiness",
        "description": "Sẵn sàng nhận traffic: DB và Redis phải trả lời. Kubernetes readinessProbe: lỗi → ngừng gửi traffic tới pod.",
        "operationId": "readiness_api_health_ready_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "tags": [
          "ops"
        ]
      }
    },
    "/api/profile": {
      "get": {
        "summary": "Read Profile",
        "operationId": "read_profile_api_profile_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfileRead"
                }
              }
            }
          }
        },
        "tags": [
          "public"
        ]
      }
    },
    "/api/projects": {
      "get": {
        "summary": "Read Projects",
        "operationId": "read_projects_api_projects_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ProjectRead"
                  },
                  "type": "array",
                  "title": "Response Read Projects Api Projects Get"
                }
              }
            }
          }
        },
        "tags": [
          "public"
        ]
      }
    },
    "/api/contact": {
      "post": {
        "summary": "Create Contact",
        "operationId": "create_contact_api_contact_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactRead"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "tags": [
          "public"
        ]
      }
    },
    "/api/me": {
      "get": {
        "summary": "Read Me",
        "operationId": "read_me_api_me_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticatedUser"
                }
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "tags": [
          "auth"
        ]
      }
    },
    "/api/admin/messages": {
      "get": {
        "summary": "Read Messages",
        "operationId": "read_messages_api_admin_messages_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ContactRead"
                  },
                  "type": "array",
                  "title": "Response Read Messages Api Admin Messages Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "tags": [
          "auth"
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AuthenticatedUser": {
        "properties": {
          "subject": {
            "type": "string",
            "title": "Subject"
          },
          "username": {
            "type": "string",
            "title": "Username"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "roles": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Roles"
          }
        },
        "type": "object",
        "required": [
          "subject",
          "username",
          "roles"
        ],
        "title": "AuthenticatedUser"
      },
      "ContactCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120,
            "minLength": 2,
            "title": "Name"
          },
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "subject": {
            "type": "string",
            "maxLength": 200,
            "minLength": 3,
            "title": "Subject"
          },
          "message": {
            "type": "string",
            "maxLength": 5000,
            "minLength": 10,
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "name",
          "email",
          "subject",
          "message"
        ],
        "title": "ContactCreate"
      },
      "ContactRead": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120,
            "minLength": 2,
            "title": "Name"
          },
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "subject": {
            "type": "string",
            "maxLength": 200,
            "minLength": 3,
            "title": "Subject"
          },
          "message": {
            "type": "string",
            "maxLength": 5000,
            "minLength": 10,
            "title": "Message"
          },
          "id": {
            "type": "integer",
            "title": "Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "name",
          "email",
          "subject",
          "message",
          "id",
          "created_at"
        ],
        "title": "ContactRead"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "ProfileRead": {
        "properties": {
          "id": {
            "type": "integer",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "role": {
            "type": "string",
            "title": "Role"
          },
          "summary": {
            "type": "string",
            "title": "Summary"
          },
          "location": {
            "type": "string",
            "title": "Location"
          },
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "availability": {
            "type": "string",
            "title": "Availability"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "role",
          "summary",
          "location",
          "email",
          "availability"
        ],
        "title": "ProfileRead"
      },
      "ProjectRead": {
        "properties": {
          "id": {
            "type": "integer",
            "title": "Id"
          },
          "title": {
            "type": "string",
            "title": "Title"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "stack": {
            "type": "string",
            "title": "Stack"
          },
          "outcome": {
            "type": "string",
            "title": "Outcome"
          },
          "featured": {
            "type": "boolean",
            "title": "Featured"
          }
        },
        "type": "object",
        "required": [
          "id",
          "title",
          "description",
          "stack",
          "outcome",
          "featured"
        ],
        "title": "ProjectRead"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "servers": [
    {
      "url": "/",
      "description": "Trang hiện tại"
    }
  ],
  "tags": [
    {
      "name": "public",
      "description": "Không cần đăng nhập"
    },
    {
      "name": "auth",
      "description": "Cần access token của Keycloak"
    },
    {
      "name": "ops",
      "description": "Health check cho Docker / Kubernetes"
    }
  ]
}
