openapi: 3.1.0
info:
  title: Api
  version: 0.1.0
  description: SEO4BUZ Website API
servers:
  - url: /api
    description: Base API path
tags:
  - name: health
    description: Health operations
  - name: blog
    description: Blog post operations
  - name: services
    description: Services operations
  - name: testimonials
    description: Testimonials operations
  - name: contacts
    description: Contact form submissions
  - name: settings
    description: Site settings operations
  - name: admin
    description: Admin authentication

paths:
  /healthz:
    get:
      operationId: healthCheck
      tags: [health]
      summary: Health check
      description: Returns server health status
      responses:
        "200":
          description: Healthy
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HealthStatus"

  /blog:
    get:
      operationId: getBlogPosts
      tags: [blog]
      summary: Get all published blog posts
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
        - in: query
          name: limit
          schema:
            type: integer
            default: 10
      responses:
        "200":
          description: List of blog posts
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BlogPostsResponse"
    post:
      operationId: createBlogPost
      tags: [blog]
      summary: Create a new blog post (admin)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateBlogPost"
      responses:
        "201":
          description: Blog post created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BlogPost"
        "401":
          description: Unauthorized

  /blog/{slug}:
    get:
      operationId: getBlogPost
      tags: [blog]
      summary: Get a single blog post by slug
      parameters:
        - in: path
          name: slug
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Blog post detail
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BlogPost"
        "404":
          description: Not found
    put:
      operationId: updateBlogPost
      tags: [blog]
      summary: Update a blog post (admin)
      parameters:
        - in: path
          name: slug
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateBlogPost"
      responses:
        "200":
          description: Updated blog post
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BlogPost"
        "401":
          description: Unauthorized
        "404":
          description: Not found
    delete:
      operationId: deleteBlogPost
      tags: [blog]
      summary: Delete a blog post (admin)
      parameters:
        - in: path
          name: slug
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessMessage"
        "401":
          description: Unauthorized

  /services:
    get:
      operationId: getServices
      tags: [services]
      summary: Get all services
      responses:
        "200":
          description: List of services
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Service"
    post:
      operationId: createService
      tags: [services]
      summary: Create a new service (admin)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateService"
      responses:
        "201":
          description: Service created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Service"

  /services/{id}:
    put:
      operationId: updateService
      tags: [services]
      summary: Update a service (admin)
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateService"
      responses:
        "200":
          description: Updated service
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Service"
    delete:
      operationId: deleteService
      tags: [services]
      summary: Delete a service (admin)
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessMessage"

  /testimonials:
    get:
      operationId: getTestimonials
      tags: [testimonials]
      summary: Get all testimonials
      responses:
        "200":
          description: List of testimonials
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Testimonial"
    post:
      operationId: createTestimonial
      tags: [testimonials]
      summary: Create a testimonial (admin)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTestimonial"
      responses:
        "201":
          description: Testimonial created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Testimonial"

  /testimonials/{id}:
    put:
      operationId: updateTestimonial
      tags: [testimonials]
      summary: Update a testimonial (admin)
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTestimonial"
      responses:
        "200":
          description: Updated testimonial
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Testimonial"
    delete:
      operationId: deleteTestimonial
      tags: [testimonials]
      summary: Delete a testimonial (admin)
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessMessage"

  /contacts:
    post:
      operationId: submitContact
      tags: [contacts]
      summary: Submit contact form
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateContact"
      responses:
        "201":
          description: Contact submitted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessMessage"
    get:
      operationId: getContacts
      tags: [contacts]
      summary: Get all contact submissions (admin)
      responses:
        "200":
          description: List of contacts
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Contact"

  /settings:
    get:
      operationId: getSettings
      tags: [settings]
      summary: Get site settings
      responses:
        "200":
          description: Site settings
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SiteSettings"
    put:
      operationId: updateSettings
      tags: [settings]
      summary: Update site settings (admin)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SiteSettings"
      responses:
        "200":
          description: Updated settings
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SiteSettings"

  /admin/login:
    post:
      operationId: adminLogin
      tags: [admin]
      summary: Admin login
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AdminLogin"
      responses:
        "200":
          description: Login success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AdminLoginResponse"
        "401":
          description: Invalid credentials

  /admin/logout:
    post:
      operationId: adminLogout
      tags: [admin]
      summary: Admin logout
      responses:
        "200":
          description: Logged out
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SuccessMessage"

  /admin/me:
    get:
      operationId: adminMe
      tags: [admin]
      summary: Check admin session
      responses:
        "200":
          description: Admin info
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AdminInfo"
        "401":
          description: Unauthorized

components:
  schemas:
    HealthStatus:
      type: object
      properties:
        status:
          type: string
      required:
        - status

    SuccessMessage:
      type: object
      properties:
        message:
          type: string
      required:
        - message

    BlogPost:
      type: object
      properties:
        id:
          type: integer
        title:
          type: string
        slug:
          type: string
        excerpt:
          type: string
        content:
          type: string
        author:
          type: string
        category:
          type: string
        published:
          type: boolean
        createdAt:
          type: string
        updatedAt:
          type: string
      required:
        - id
        - title
        - slug
        - excerpt
        - content
        - author
        - category
        - published
        - createdAt
        - updatedAt

    BlogPostsResponse:
      type: object
      properties:
        posts:
          type: array
          items:
            $ref: "#/components/schemas/BlogPost"
        total:
          type: integer
        page:
          type: integer
        totalPages:
          type: integer
      required:
        - posts
        - total
        - page
        - totalPages

    CreateBlogPost:
      type: object
      properties:
        title:
          type: string
        slug:
          type: string
        excerpt:
          type: string
        content:
          type: string
        author:
          type: string
        category:
          type: string
        published:
          type: boolean
      required:
        - title
        - slug
        - excerpt
        - content
        - author
        - category
        - published

    Service:
      type: object
      properties:
        id:
          type: integer
        title:
          type: string
        description:
          type: string
        icon:
          type: string
        features:
          type: array
          items:
            type: string
        sortOrder:
          type: integer
      required:
        - id
        - title
        - description
        - icon
        - features
        - sortOrder

    CreateService:
      type: object
      properties:
        title:
          type: string
        description:
          type: string
        icon:
          type: string
        features:
          type: array
          items:
            type: string
        sortOrder:
          type: integer
      required:
        - title
        - description
        - icon
        - features
        - sortOrder

    Testimonial:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        role:
          type: string
        content:
          type: string
        rating:
          type: integer
        sortOrder:
          type: integer
      required:
        - id
        - name
        - role
        - content
        - rating
        - sortOrder

    CreateTestimonial:
      type: object
      properties:
        name:
          type: string
        role:
          type: string
        content:
          type: string
        rating:
          type: integer
        sortOrder:
          type: integer
      required:
        - name
        - role
        - content
        - rating
        - sortOrder

    CreateContact:
      type: object
      properties:
        name:
          type: string
        email:
          type: string
        phone:
          type: string
        subject:
          type: string
        message:
          type: string
      required:
        - name
        - email
        - subject
        - message

    Contact:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        email:
          type: string
        phone:
          type: string
        subject:
          type: string
        message:
          type: string
        createdAt:
          type: string
      required:
        - id
        - name
        - email
        - subject
        - message
        - createdAt

    SiteSettings:
      type: object
      properties:
        siteName:
          type: string
        tagline:
          type: string
        phone:
          type: string
        email:
          type: string
        address:
          type: string
        city:
          type: string
        whatsapp:
          type: string
        facebook:
          type: string
        twitter:
          type: string
        linkedin:
          type: string
        heroTitle:
          type: string
        heroSubtitle:
          type: string
        aboutTitle:
          type: string
        aboutContent:
          type: string
      required:
        - siteName
        - tagline
        - phone
        - email
        - address
        - city
        - whatsapp
        - heroTitle
        - heroSubtitle
        - aboutTitle
        - aboutContent

    AdminLogin:
      type: object
      properties:
        username:
          type: string
        password:
          type: string
      required:
        - username
        - password

    AdminLoginResponse:
      type: object
      properties:
        message:
          type: string
        username:
          type: string
      required:
        - message
        - username

    AdminInfo:
      type: object
      properties:
        username:
          type: string
      required:
        - username
