openapi: 3.1.0
info:
  title: Api
  version: 0.1.0
  description: Adsense Seller API
servers:
  - url: /api
    description: Base API path
tags:
  - name: health
    description: Health operations
  - name: domains
    description: Domain listing operations
  - name: social
    description: Social media links operations
  - name: contacts
    description: Contact/inquiry operations
  - name: settings
    description: Admin settings
paths:
  /healthz:
    get:
      operationId: healthCheck
      tags: [health]
      summary: Health check
      responses:
        "200":
          description: Healthy
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HealthStatus"

  /domains:
    get:
      operationId: getDomains
      tags: [domains]
      summary: Get all domain listings
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum: [available, sold, featured]
        - name: category
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: number
        - name: offset
          in: query
          schema:
            type: number
      responses:
        "200":
          description: List of domains
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DomainListResponse"
    post:
      operationId: createDomain
      tags: [domains]
      summary: Create a new domain listing
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDomainRequest"
      responses:
        "201":
          description: Domain created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Domain"

  /domains/featured:
    get:
      operationId: getFeaturedDomains
      tags: [domains]
      summary: Get featured domain listings
      responses:
        "200":
          description: Featured domains
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DomainListResponse"

  /domains/stats:
    get:
      operationId: getDomainStats
      tags: [domains]
      summary: Get domain listing statistics
      responses:
        "200":
          description: Stats
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DomainStats"

  /domains/{id}:
    get:
      operationId: getDomain
      tags: [domains]
      summary: Get a single domain listing
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Domain found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Domain"
    put:
      operationId: updateDomain
      tags: [domains]
      summary: Update a domain listing
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateDomainRequest"
      responses:
        "200":
          description: Domain updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Domain"
    delete:
      operationId: deleteDomain
      tags: [domains]
      summary: Delete a domain listing
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: number
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeleteResponse"

  /social:
    get:
      operationId: getSocialLinks
      tags: [social]
      summary: Get all social media links
      responses:
        "200":
          description: Social links
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SocialLinksResponse"
    put:
      operationId: updateSocialLinks
      tags: [social]
      summary: Update social media links
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SocialLinks"
      responses:
        "200":
          description: Updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SocialLinksResponse"

  /contacts:
    get:
      operationId: getContacts
      tags: [contacts]
      summary: Get all contact inquiries
      responses:
        "200":
          description: Contact list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContactListResponse"
    post:
      operationId: createContact
      tags: [contacts]
      summary: Submit a contact inquiry
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateContactRequest"
      responses:
        "201":
          description: Contact created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Contact"

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

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

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

    Domain:
      type: object
      properties:
        id:
          type: number
        name:
          type: string
        price:
          type: number
        category:
          type: string
        status:
          type: string
          enum: [available, sold, featured]
        description:
          type: string
        pageRank:
          type: number
        monthlyTraffic:
          type: number
        adsenseApproved:
          type: boolean
        age:
          type: string
        createdAt:
          type: string
      required:
        - id
        - name
        - price
        - category
        - status
        - adsenseApproved

    DomainListResponse:
      type: object
      properties:
        domains:
          type: array
          items:
            $ref: "#/components/schemas/Domain"
        total:
          type: number
      required:
        - domains
        - total

    CreateDomainRequest:
      type: object
      properties:
        name:
          type: string
        price:
          type: number
        category:
          type: string
        status:
          type: string
          enum: [available, sold, featured]
        description:
          type: string
        pageRank:
          type: number
        monthlyTraffic:
          type: number
        adsenseApproved:
          type: boolean
        age:
          type: string
      required:
        - name
        - price
        - category
        - status
        - adsenseApproved

    UpdateDomainRequest:
      type: object
      properties:
        name:
          type: string
        price:
          type: number
        category:
          type: string
        status:
          type: string
          enum: [available, sold, featured]
        description:
          type: string
        pageRank:
          type: number
        monthlyTraffic:
          type: number
        adsenseApproved:
          type: boolean
        age:
          type: string

    DomainStats:
      type: object
      properties:
        totalDomains:
          type: number
        availableDomains:
          type: number
        soldDomains:
          type: number
        featuredDomains:
          type: number
        totalValue:
          type: number
      required:
        - totalDomains
        - availableDomains
        - soldDomains
        - featuredDomains
        - totalValue

    SocialLinks:
      type: object
      properties:
        whatsapp:
          type: string
        telegram:
          type: string
        youtube:
          type: string
        instagram:
          type: string
        telegramGroup:
          type: string
      required:
        - whatsapp
        - telegram
        - youtube
        - instagram

    SocialLinksResponse:
      type: object
      properties:
        links:
          $ref: "#/components/schemas/SocialLinks"
      required:
        - links

    Contact:
      type: object
      properties:
        id:
          type: number
        name:
          type: string
        email:
          type: string
        phone:
          type: string
        message:
          type: string
        domainInterest:
          type: string
        createdAt:
          type: string
      required:
        - id
        - name
        - email
        - message

    ContactListResponse:
      type: object
      properties:
        contacts:
          type: array
          items:
            $ref: "#/components/schemas/Contact"
        total:
          type: number
      required:
        - contacts
        - total

    CreateContactRequest:
      type: object
      properties:
        name:
          type: string
        email:
          type: string
        phone:
          type: string
        message:
          type: string
        domainInterest:
          type: string
      required:
        - name
        - email
        - message

    SiteSettings:
      type: object
      properties:
        siteName:
          type: string
        siteTagline:
          type: string
        contactEmail:
          type: string
        contactWhatsapp:
          type: string
        adminPassword:
          type: string
      required:
        - siteName
        - siteTagline

    UpdateSettingsRequest:
      type: object
      properties:
        siteName:
          type: string
        siteTagline:
          type: string
        contactEmail:
          type: string
        contactWhatsapp:
          type: string
        adminPassword:
          type: string

    AdminLoginRequest:
      type: object
      properties:
        password:
          type: string
      required:
        - password

    AdminLoginResponse:
      type: object
      properties:
        success:
          type: boolean
        token:
          type: string
      required:
        - success

    DeleteResponse:
      type: object
      properties:
        success:
          type: boolean
      required:
        - success
