openapi: 3.0.3
info:
  title: MAINSTREET.CLUB API
  description: |
    Comprehensive API for accessing verified business directory data, products, and services.
    
    **Features:**
    - Verified business listings with detailed information
    - Product catalogs from local businesses  
    - Service categories and classifications
    - Multilingual support (English, French)
    - Geographic search capabilities
    - Real business contact information
    
    **Data Quality:**
    - Human-verified business information
    - Regular data updates and validation
    - Comprehensive business profiles
    - Rich product metadata including images
    
    **Use Cases:**
    - Local business discovery
    - Product search and comparison
    - Service provider lookup
    - Market research and analysis
    - AI-powered recommendations
  version: "1.0.0"
  contact:
    name: MAINSTREET.CLUB API Support
    email: ai@mainstreet.club
    url: https://mainstreet.club/contact
  license:
    name: Terms of Service
    url: https://mainstreet.club/terms
  termsOfService: https://mainstreet.club/terms

servers:
  - url: https://mainstreet.club/api/v1
    description: Production API Server

paths:
  /businesses:
    get:
      summary: Get list of businesses
      description: Retrieve a list of verified local businesses with optional filtering
      parameters:
        - name: category
          in: query
          description: Filter by business category
          schema:
            type: string
            enum: [automotive, food-dining, health-medical, home-services, professional-services, retail-shopping, beauty-wellness, education, entertainment, financial-services]
        - name: city
          in: query
          description: Filter by city
          schema:
            type: string
        - name: verified
          in: query
          description: Show only verified businesses
          schema:
            type: boolean
            default: true
        - name: limit
          in: query
          description: Maximum number of results
          schema:
            type: integer
            default: 20
            maximum: 100
      responses:
        '200':
          description: List of businesses
          content:
            application/json:
              schema:
                type: object
                properties:
                  businesses:
                    type: array
                    items:
                      $ref: '#/components/schemas/Business'
                  total:
                    type: integer
                  page:
                    type: integer

  /businesses/{id}:
    get:
      summary: Get business details
      description: Retrieve detailed information about a specific business
      parameters:
        - name: id
          in: path
          required: true
          description: Business ID
          schema:
            type: string
      responses:
        '200':
          description: Business details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BusinessDetailed'
        '404':
          description: Business not found

  /businesses/{id}/products:
    get:
      summary: Get business products/services
      description: Retrieve products and services offered by a business
      parameters:
        - name: id
          in: path
          required: true
          description: Business ID
          schema:
            type: string
      responses:
        '200':
          description: List of products/services
          content:
            application/json:
              schema:
                type: object
                properties:
                  products:
                    type: array
                    items:
                      $ref: '#/components/schemas/Product'

  /search:
    get:
      summary: Search businesses
      description: Full-text search across businesses, products, and services
      parameters:
        - name: q
          in: query
          required: true
          description: Search query
          schema:
            type: string
        - name: location
          in: query
          description: Location filter (city, postal code)
          schema:
            type: string
      responses:
        '200':
          description: Search results
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items:
                      $ref: '#/components/schemas/SearchResult'

components:
  schemas:
    Business:
      type: object
      properties:
        id:
          type: string
          description: Unique business identifier
        name:
          type: string
          description: Business name
        category:
          type: string
          description: Primary business category
        address:
          type: string
          description: Full business address
        city:
          type: string
        province:
          type: string
        postal_code:
          type: string
        phone:
          type: string
        website:
          type: string
          format: uri
        email:
          type: string
          format: email
        is_verified:
          type: boolean
          description: Whether the business is AI-verified
        verification_level:
          type: integer
          minimum: 0
          maximum: 5
          description: Verification level (0-5, higher is more verified)
        rating:
          type: number
          minimum: 0
          maximum: 5
        review_count:
          type: integer
        hours:
          type: object
          description: Business operating hours
        created_at:
          type: string
          format: date-time

    BusinessDetailed:
      allOf:
        - $ref: '#/components/schemas/Business'
        - type: object
          properties:
            description:
              type: string
              description: Detailed business description
            services:
              type: array
              items:
                type: string
              description: List of services offered
            specialties:
              type: array
              items:
                type: string
              description: Business specialties
            payment_methods:
              type: array
              items:
                type: string
              description: Accepted payment methods
            languages:
              type: array
              items:
                type: string
              description: Languages spoken
            amenities:
              type: array
              items:
                type: string
              description: Available amenities

    Product:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        category:
          type: string
        price_type:
          type: string
          enum: [see_website, fixed, range, starting, quote, free]
        price_min:
          type: number
        price_max:
          type: number
        external_url:
          type: string
          format: uri
          description: Link to product page on business website
        features:
          type: string
          description: Product features and details
        is_featured:
          type: boolean
        created_at:
          type: string
          format: date-time

    SearchResult:
      type: object
      properties:
        type:
          type: string
          enum: [business, product]
        id:
          type: string
        title:
          type: string
        description:
          type: string
        business_name:
          type: string
        category:
          type: string
        location:
          type: string
        relevance_score:
          type: number
          minimum: 0
          maximum: 1