basePath: /
definitions:
  auth.LoginRequest:
    properties:
      email:
        type: string
      password:
        type: string
    type: object
  auth.RegisterRequest:
    properties:
      email:
        type: string
      name:
        type: string
      password:
        type: string
    type: object
  domain.Document:
    properties:
      ai_analysis_json:
        type: object
      category:
        type: string
      created_at:
        type: string
      id:
        type: string
      last_updated_at:
        type: string
      source_uri:
        type: string
      status:
        type: string
      tenant_id:
        type: string
      title:
        type: string
      user_id:
        type: string
    type: object
  domain.User:
    properties:
      avatar_url:
        type: string
      created_at:
        type: string
      deleted_at:
        format: date-time
        type: string
      email:
        type: string
      email_verified_at:
        type: string
      id:
        type: string
      is_active:
        type: boolean
      last_login_at:
        type: string
      name:
        type: string
      updated_at:
        type: string
    type: object
  handler.AuthResponse:
    properties:
      access_token:
        type: string
      message:
        type: string
      refresh_token:
        type: string
      user:
        $ref: '#/definitions/domain.User'
    type: object
  handler.CacheHealthResponse:
    properties:
      healthy:
        type: boolean
      stats:
        additionalProperties: true
        type: object
    type: object
  handler.ConfirmUploadRequest:
    properties:
      category:
        type: string
      object_key:
        type: string
      title:
        type: string
    required:
    - category
    - object_key
    - title
    type: object
  handler.DatabaseHealthResponse:
    properties:
      healthy:
        type: boolean
      stats:
        additionalProperties: true
        type: object
    type: object
  handler.DocumentListResponse:
    properties:
      data:
        items:
          $ref: '#/definitions/domain.Document'
        type: array
      meta:
        $ref: '#/definitions/handler.Meta'
    type: object
  handler.ErrorResponse:
    properties:
      details:
        items:
          type: string
        type: array
      error:
        type: string
    type: object
  handler.HealthResponse:
    properties:
      cache:
        $ref: '#/definitions/handler.CacheHealthResponse'
      database:
        $ref: '#/definitions/handler.DatabaseHealthResponse'
      environment:
        type: string
      status:
        type: string
      timestamp:
        type: integer
    type: object
  handler.LogoutRequest:
    properties:
      refresh_token:
        type: string
    type: object
  handler.Meta:
    properties:
      limit:
        type: integer
      offset:
        type: integer
      total:
        type: integer
    type: object
  handler.PingResponse:
    properties:
      message:
        type: string
    type: object
  handler.RefreshTokenRequest:
    properties:
      refresh_token:
        type: string
    required:
    - refresh_token
    type: object
  handler.SuccessResponse:
    properties:
      message:
        type: string
    type: object
  handler.UpdateUserRequest:
    properties:
      avatar_url:
        type: string
      name:
        maxLength: 100
        minLength: 2
        type: string
    type: object
  handler.UpdateUserResponse:
    properties:
      message:
        type: string
      user:
        $ref: '#/definitions/handler.UserResponse'
    type: object
  handler.UserListResponse:
    properties:
      data:
        items:
          $ref: '#/definitions/domain.User'
        type: array
      meta:
        $ref: '#/definitions/handler.Meta'
    type: object
  handler.UserResponse:
    properties:
      avatar_url:
        type: string
      created_at:
        type: string
      email:
        type: string
      id:
        type: string
      is_active:
        type: boolean
      name:
        type: string
    type: object
host: localhost:7777
info:
  contact:
    email: support@swagger.io
    name: API Support
    url: http://www.swagger.io/support
  description: Elysian Backend API provides user authentication, management, and health
    check endpoints. Built with Go and Gin framework.
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  termsOfService: http://swagger.io/terms/
  title: Elysian Backend API
  version: 1.0.0
paths:
  /api/v1/auth/login:
    post:
      consumes:
      - application/json
      description: Login with email and password
      parameters:
      - description: Login Request
        in: body
        name: request
        required: true
        schema:
          $ref: '#/definitions/auth.LoginRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.AuthResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "401":
          description: Unauthorized
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      summary: Login
      tags:
      - auth
  /api/v1/auth/logout:
    post:
      consumes:
      - application/json
      description: Logout user
      parameters:
      - description: Logout Request
        in: body
        name: request
        schema:
          $ref: '#/definitions/handler.LogoutRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.SuccessResponse'
      summary: Logout
      tags:
      - auth
  /api/v1/auth/refresh:
    post:
      consumes:
      - application/json
      description: Refresh access token using refresh token
      parameters:
      - description: Refresh Token Request
        in: body
        name: request
        schema:
          $ref: '#/definitions/handler.RefreshTokenRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.AuthResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "401":
          description: Unauthorized
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      summary: Refresh Access Token
      tags:
      - auth
  /api/v1/auth/register:
    post:
      consumes:
      - application/json
      description: Register a new user with email and password
      parameters:
      - description: Register Request
        in: body
        name: request
        required: true
        schema:
          $ref: '#/definitions/auth.RegisterRequest'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/handler.AuthResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "409":
          description: Conflict
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      summary: Register a new user
      tags:
      - auth
  /api/v1/ping:
    get:
      description: Simple ping endpoint
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.PingResponse'
      summary: Ping
      tags:
      - health
  /api/v1/documents:
    get:
      description: List documents for tenant
      parameters:
      - description: Tenant ID (Strict UUID)
        in: header
        name: X-Tenant-ID
        required: true
        type: string
      - description: Limit (max 100, default 20)
        in: query
        name: limit
        type: integer
      - description: Offset (default 0)
        in: query
        name: offset
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.DocumentListResponse'
        "400":
          description: Bad Request (Invalid X-Tenant-ID UUID format)
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "500":
          description: Internal Server Error (Sanitized, anti Information Disclosure)
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: List documents
      tags:
      - documents
  /api/v1/documents/confirm:
    post:
      consumes:
      - application/json
      description: Confirm S3 upload and trigger Asynq vectorization worker
      parameters:
      - description: Tenant ID (Strict UUID)
        in: header
        name: X-Tenant-ID
        required: true
        type: string
      - description: Confirm Upload Request
        in: body
        name: request
        required: true
        schema:
          $ref: '#/definitions/handler.ConfirmUploadRequest'
      produces:
      - application/json
      responses:
        "202":
          description: Accepted
          schema:
            properties:
              document_id:
                type: string
              message:
                type: string
              status:
                type: string
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "500":
          description: Internal Server Error (Sanitized)
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: Confirm upload
      tags:
      - documents
  /api/v1/documents/presign:
    get:
      description: Get a 15-minute presigned S3 URL for direct file upload
      parameters:
      - description: Tenant ID (Strict UUID)
        in: header
        name: X-Tenant-ID
        required: true
        type: string
      - description: Original filename
        in: query
        name: filename
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            properties:
              expires_in:
                type: string
              object_key:
                type: string
              presigned_url:
                type: string
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "500":
          description: Internal Server Error (Sanitized)
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: Get presigned URL
      tags:
      - documents
  /api/v1/documents/{id}:
    delete:
      description: Deletes a document record from the database
      parameters:
      - description: Tenant ID (Strict UUID)
        in: header
        name: X-Tenant-ID
        required: true
        type: string
      - description: Document ID
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            properties:
              message:
                type: string
              status:
                type: string
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "500":
          description: Internal Server Error (Sanitized)
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: Delete document
      tags:
      - documents
  /api/v1/documents/{id}/approve:
    post:
      description: Transition status from pending_qa to processing and trigger chunk embedding
      parameters:
      - description: Tenant ID (Strict UUID)
        in: header
        name: X-Tenant-ID
        required: true
        type: string
      - description: Document ID
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "202":
          description: Accepted
          schema:
            properties:
              document_id:
                type: string
              message:
                type: string
              status:
                type: string
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "500":
          description: Internal Server Error (Sanitized)
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: Approve document
      tags:
      - documents
  /api/v1/documents/{id}/raw:
    get:
      description: Returns the full raw text and its SHA-256 hash from MongoDB staging area
      parameters:
      - description: Tenant ID (Strict UUID)
        in: header
        name: X-Tenant-ID
        required: true
        type: string
      - description: Document ID (UUID or Draft Name)
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            properties:
              hash:
                type: string
              id:
                type: string
              raw_text:
                type: string
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "500":
          description: Internal Server Error (Sanitized)
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: Get raw document text
      tags:
      - documents
  /api/v1/documents/{id}/text:
    patch:
      consumes:
      - application/json
      description: Updates the extracted plain text inside document's ai_analysis_json
      parameters:
      - description: Tenant ID (Strict UUID)
        in: header
        name: X-Tenant-ID
        required: true
        type: string
      - description: Document ID (UUID or Draft Name)
        in: path
        name: id
        required: true
        type: string
      - description: Update text request body
        in: body
        name: request
        required: true
        schema:
          properties:
            extracted_text:
              type: string
            status:
              type: string
            title:
              type: string
          type: object
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            properties:
              message:
                type: string
              status:
                type: string
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "500":
          description: Internal Server Error (Sanitized)
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: Update document text
      tags:
      - documents
  /api/v1/users:
    get:
      description: Get list of users
      parameters:
      - description: Limit
        in: query
        name: limit
        type: integer
      - description: Offset
        in: query
        name: offset
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.UserListResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      summary: List users
      tags:
      - users
  /api/v1/users/{id}:
    get:
      description: Get user details by ID
      parameters:
      - description: User ID
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/domain.User'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      summary: Get user by ID
      tags:
      - users
  /api/v1/users/email/{email}:
    get:
      description: Get user details by email
      parameters:
      - description: User Email
        in: path
        name: email
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/domain.User'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      summary: Get user by email
      tags:
      - users
  /api/v1/users/me:
    delete:
      description: Delete currently logged in user account
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.SuccessResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: Delete current user
      tags:
      - users
    get:
      description: Get details of currently logged in user
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.UserResponse'
      security:
      - BearerAuth: []
      summary: Get current user
      tags:
      - users
    put:
      consumes:
      - application/json
      description: Update details of currently logged in user
      parameters:
      - description: Update Request
        in: body
        name: request
        required: true
        schema:
          $ref: '#/definitions/handler.UpdateUserRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.UpdateUserResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/handler.ErrorResponse'
      security:
      - BearerAuth: []
      summary: Update current user
      tags:
      - users
  /health:
    get:
      description: Check the health of the application (database and cache)
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/handler.HealthResponse'
        "503":
          description: Service Unavailable
          schema:
            $ref: '#/definitions/handler.HealthResponse'
      summary: Health Check
      tags:
      - health
schemes:
- http
- https
securityDefinitions:
  BearerAuth:
    in: header
    name: Authorization
    type: apiKey
swagger: "2.0"
