{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Application Configuration Schema",
  "description": "Schema for validating application configuration files",
  "type": "object",
  "required": ["app", "server"],
  "properties": {
    "app": {
      "type": "object",
      "required": ["name", "version", "environment"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+$"
        },
        "environment": {
          "type": "string",
          "enum": ["development", "staging", "production"]
        },
        "debug": {
          "type": "boolean"
        },
        "logLevel": {
          "type": "string",
          "enum": ["debug", "info", "warn", "error"]
        }
      }
    },
    "server": {
      "type": "object",
      "required": ["host", "port"],
      "properties": {
        "host": {
          "type": "string"
        },
        "port": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535
        },
        "timeout": {
          "type": "integer",
          "minimum": 0
        },
        "cors": {
          "type": "object",
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "origins": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "methods": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
              }
            }
          }
        }
      }
    },
    "database": {
      "type": "object",
      "required": ["type", "host", "port", "name"],
      "properties": {
        "type": {
          "type": "string",
          "enum": ["postgresql", "mysql", "mongodb", "sqlite"]
        },
        "host": {
          "type": "string"
        },
        "port": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535
        },
        "name": {
          "type": "string"
        },
        "user": {
          "type": "string"
        },
        "pool": {
          "type": "object",
          "properties": {
            "min": {
              "type": "integer",
              "minimum": 1
            },
            "max": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      }
    },
    "cache": {
      "type": "object",
      "required": ["enabled", "type"],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "type": {
          "type": "string",
          "enum": ["memory", "redis", "memcached"]
        },
        "host": {
          "type": "string"
        },
        "port": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535
        },
        "ttl": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "security": {
      "type": "object",
      "properties": {
        "jwt": {
          "type": "object",
          "required": ["secret", "expiresIn"],
          "properties": {
            "secret": {
              "type": "string",
              "minLength": 32
            },
            "expiresIn": {
              "type": "string",
              "pattern": "^\\d+[smhd]$"
            },
            "algorithm": {
              "type": "string",
              "enum": ["HS256", "HS384", "HS512"]
            }
          }
        },
        "rateLimit": {
          "type": "object",
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "window": {
              "type": "integer",
              "minimum": 1
            },
            "max": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      }
    },
    "features": {
      "type": "object",
      "properties": {
        "notifications": {
          "type": "boolean"
        },
        "analytics": {
          "type": "boolean"
        },
        "maintenance": {
          "type": "boolean"
        }
      }
    }
  }
} 