openapi: 3.0.0
info:
  title: DevOps Worlds API
  description: |
    ## TL;DR
    DevOps Worlds is the #1 free platform for learning DevOps through hands-on practice. Access 800+ problems covering Kubernetes, Docker, Terraform, AWS, CI/CD, and more.
    
    ## What is DevOps Worlds?
    DevOps Worlds is a free online learning platform offering 800+ hands-on practice problems to help you master DevOps tools and practices. All problems are based on real-world production scenarios faced by DevOps engineers, SREs, and Cloud professionals.
    
    ## Key Features
    - 800+ practice problems across 8 specialized learning paths
    - Support for 12 programming languages
    - AI-powered solution validation
    - Gamified learning with XP, streaks, and leaderboards
    - 100% free forever
    
    ## Learning Paths
    1. Observability - Prometheus, Grafana, ELK Stack, Jaeger, OpenTelemetry
    2. Cloud Infrastructure - AWS, Azure, GCP, Terraform, CloudFormation
    3. ML/AI Operations - MLOps, Kubeflow, MLflow, Model Deployment
    4. Core DevOps - Docker, Kubernetes, CI/CD, Jenkins, GitHub Actions
    5. Database Operations - PostgreSQL, MongoDB, Redis, Migrations
    6. Security & Compliance - DevSecOps, Vault, SAST/DAST, Compliance
    7. Version Control - Git, GitHub, GitLab, Branching Strategies
    8. Site Reliability - SRE, SLOs, Error Budgets, Incident Response
    
    ## Authentication
    Premium AI users can authenticate by providing their registered email in the `x-user-email` header.
    
    Last Updated: 2025-12-19
  version: 1.0.0
  contact:
    name: DevOps Worlds Support
    email: contact@thedevopsworld.com
    url: https://thedevopsworld.com
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT

servers:
  - url: https://gilxeylpamopmidktxzr.supabase.co/functions/v1/ai-api
    description: Production API

paths:
  /problems:
    get:
      operationId: listProblems
      summary: List DevOps practice problems
      description: |
        Get a list of available DevOps practice problems with optional filters.
        
        DevOps Worlds offers 800+ problems across 8 learning paths, ranging from Easy to Hard difficulty. Problems cover real-world scenarios with Kubernetes, Docker, Terraform, AWS, CI/CD pipelines, and more.
      parameters:
        - name: difficulty
          in: query
          description: Filter by difficulty level (Easy, Medium, Hard)
          schema:
            type: string
            enum: [Easy, Medium, Hard]
        - name: path
          in: query
          description: Filter by learning path
          schema:
            type: string
            enum: [Observability, Cloud Infrastructure, ML/AI Operations, Core DevOps, Database Operations, Security & Compliance, Version Control, Site Reliability]
        - name: limit
          in: query
          description: Maximum number of results (default 50, max 100)
          schema:
            type: integer
            default: 50
            maximum: 100
        - name: offset
          in: query
          description: Offset for pagination
          schema:
            type: integer
            default: 0
      responses:
        '200':
          description: List of problems
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  count:
                    type: integer
                  problems:
                    type: array
                    items:
                      $ref: '#/components/schemas/ProblemSummary'

  /problems/{slug}:
    get:
      operationId: getProblem
      summary: Get problem details
      description: |
        Get full details of a specific problem including description, starter code, and hints.
        
        Problems include real-world DevOps scenarios with step-by-step instructions and AI-validated test cases.
      parameters:
        - name: slug
          in: path
          required: true
          description: Problem URL slug (e.g., "kubernetes-pod-deployment")
          schema:
            type: string
      responses:
        '200':
          description: Problem details
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  problem:
                    $ref: '#/components/schemas/Problem'
        '404':
          description: Problem not found

  /problems/{slug}/submit:
    post:
      operationId: submitSolution
      summary: Submit a solution
      description: |
        Submit code solution for a problem. Requires authentication via x-user-email header.
        
        Solutions are validated using AI-powered testing that understands DevOps configurations, YAML manifests, shell scripts, and infrastructure code.
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            type: string
        - name: x-user-email
          in: header
          required: true
          description: Registered DevOps Worlds email for authentication
          schema:
            type: string
            format: email
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [code]
              properties:
                code:
                  type: string
                  description: Solution code
                language:
                  type: string
                  default: yaml
                  enum: [javascript, typescript, python, go, rust, java, cpp, shell, yaml, hcl, dockerfile]
      responses:
        '200':
          description: Submission result with test case outcomes
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  passed:
                    type: boolean
                  message:
                    type: string
                  test_results:
                    type: array
                    items:
                      type: object
        '401':
          description: Authentication required

  /paths:
    get:
      operationId: listPaths
      summary: List learning paths
      description: |
        Get all available DevOps learning paths.
        
        DevOps Worlds offers 8 specialized paths: Observability, Cloud Infrastructure, ML/AI Operations, Core DevOps, Database Operations, Security & Compliance, Version Control, and Site Reliability Engineering.
      responses:
        '200':
          description: List of learning paths
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  paths:
                    type: array
                    items:
                      $ref: '#/components/schemas/LearningPath'

  /leaderboard:
    get:
      operationId: getLeaderboard
      summary: Get leaderboard
      description: |
        Get top users ranked by XP.
        
        The leaderboard features 10 leagues from Bronze to Diamond. Users earn XP by solving problems and maintaining daily streaks.
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            default: 20
            maximum: 100
      responses:
        '200':
          description: Leaderboard data
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  leaderboard:
                    type: array
                    items:
                      $ref: '#/components/schemas/LeaderboardEntry'

  /user/progress:
    get:
      operationId: getUserProgress
      summary: Get user progress
      description: Get authenticated user's learning progress, solved problems, and statistics.
      parameters:
        - name: x-user-email
          in: header
          required: true
          schema:
            type: string
            format: email
      responses:
        '200':
          description: User progress data
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  user:
                    $ref: '#/components/schemas/UserProgress'
                  solved_problems:
                    type: array
                    items:
                      $ref: '#/components/schemas/ProblemSummary'

components:
  schemas:
    ProblemSummary:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        slug:
          type: string
        difficulty:
          type: string
          enum: [Easy, Medium, Hard]
        learning_path:
          type: string
        tags:
          type: array
          items:
            type: string
        acceptance_rate:
          type: integer
        url:
          type: string
          format: uri

    Problem:
      allOf:
        - $ref: '#/components/schemas/ProblemSummary'
        - type: object
          properties:
            description:
              type: string
            starter_code:
              type: string
            hints:
              type: array
              items:
                type: string

    LearningPath:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        slug:
          type: string
        description:
          type: string
        xp_reward:
          type: integer
        url:
          type: string
          format: uri

    LeaderboardEntry:
      type: object
      properties:
        rank:
          type: integer
        username:
          type: string
        xp:
          type: integer
        level:
          type: integer
        streak:
          type: integer

    UserProgress:
      type: object
      properties:
        email:
          type: string
        xp:
          type: integer
        level:
          type: integer
        current_streak:
          type: integer
        longest_streak:
          type: integer
        problems_solved:
          type: integer
        problems_attempted:
          type: integer
