# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: LOJ
spec:
    description: LOJ - LeLe Online Judge, modern competitive programming platform
    coverImage: https://opengraph.githubassets.com/1/aiwandiannaodelele/LOJ
    icon: https://raw.githubusercontent.com/aiwandiannaodelele/LOJ/main/public/logo.svg
    tags:
        - Web
        - Database
    readme: |-
        # LOJ — LeLe Online Judge

        **LOJ** is a modern online judge platform built with Next.js 16. It supports programming problem solving, contests, training tracks, an AI teaching assistant, and multi-engine code execution evaluation.

        ## Features

        - **Problem System** — Create and manage programming problems with multiple test cases, self-test samples, and BlockNote rich text editing
        - **Contest System** — ACM / OI scoring modes, real-time rankings, independent problem copies
        - **Training Tracks** — Themed problem sets for progressive learning paths
        - **AI Assistant** — Integrated AI chat with problem-context-aware programming guidance
        - **Multi-Engine Judging** — Pluggable evaluation engines: OneCompiler (default), Judge0, Runoob
        - **Code Editor** — Monaco Editor (VS Code engine) with multi-language syntax highlighting
        - **User System** — NextAuth authentication, JWT sessions, role-based access control
        - **Admin Panel** — Full management for users, problems, contests, training, settings, storage
        - **Storage Backends** — Local filesystem / S3-compatible object storage
        - **Security Hardening** — Built-in rate limiting, permission validation, IP spoofing protection, SSRF protection

        ## Services

        This template deploys two services:

        1. **postgresql** — PostgreSQL 18 database for persistent storage
        2. **loj-web** — The LOJ application server built as a Docker image from [ghcr.io/aiwandiannaodelele/loj](https://github.com/aiwandiannaodelele/LOJ/pkgs/container/loj)

        ## Tech Stack

        | Technology | Purpose |
        |------------|---------|
        | **Next.js 16** | React framework (App Router) |
        | **Tailwind CSS v4** | Styling |
        | **shadcn/ui** | UI component library |
        | **Prisma 7** | ORM / Database |
        | **PostgreSQL 18** | Database |
        | **NextAuth v5** | Authentication (credentials + JWT) |
        | **Monaco Editor** | Code editor |
        | **BlockNote** | Rich text editor |
        | **OneCompiler / Judge0** | Judging engines |

        ## Environment Variables

        The following variables are pre-configured for you:

        - `DB_PROVIDER` — Set to `postgresql`
        - `DATABASE_URL` — Automatically linked to the PostgreSQL service via `${POSTGRES_CONNECTION_STRING}`
        - `NEXTAUTH_SECRET` — JWT signing secret (auto-generated)

        ## Getting Started

        After deployment, visit your service URL. The first run will automatically initialize the database schema.

        To set up OAuth login (GitHub/Google), add the following environment variables in the service settings:

        - `AUTH_GITHUB_ID`
        - `AUTH_GITHUB_SECRET`
        - `AUTH_GOOGLE_ID`
        - `AUTH_GOOGLE_SECRET`

        ## Source Code

        - GitHub: [github.com/aiwandiannaodelele/LOJ](https://github.com/aiwandiannaodelele/LOJ)
        - License: GNU AGPL v3.0

        ## Updates

        This template uses the `latest` image tag from ghcr.io. To update, rebuild the Docker image via GitHub Actions and trigger a redeploy in the Zeabur Dashboard.
    services:
        - name: postgresql
          icon: https://cdn.zeabur.com/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            id: postgresql
            source:
                image: postgres:17.4-alpine
            ports:
                - id: database
                  port: 5432
                  type: TCP
            volumes:
                - id: data
                  dir: /var/lib/postgresql/data
            instructions:
                - title: Connection String
                  content: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}
                - title: PostgreSQL Connect Command
                  content: psql "postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}"
                - title: PostgreSQL username
                  content: ${POSTGRES_USERNAME}
                - title: PostgresSQL password
                  content: ${POSTGRES_PASSWORD}
                - title: PostgreSQL host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: PostgreSQL port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                POSTGRES_CONNECTION_STRING:
                    default: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}
                    expose: true
                POSTGRES_DATABASE:
                    default: ${POSTGRES_DB}
                    expose: true
                POSTGRES_DB:
                    default: zeabur
                POSTGRES_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                POSTGRES_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                POSTGRES_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                POSTGRES_USER:
                    default: root
                POSTGRES_USERNAME:
                    default: ${POSTGRES_USER}
                    expose: true
        - name: loj-web
          icon: https://cdn.jsdelivr.net/gh/devicons/devicon/icons/nextjs/nextjs-original.svg
          template: PREBUILT
          spec:
            id: loj-web
            source:
                image: ghcr.milu.moe/aiwandiannaodelele/loj:latest
            ports:
                - id: web
                  port: 3000
                  type: HTTP
            instructions:
                - title: Visit LOJ
                  content: https://${ZEABUR_WEB_URL}
            env:
                DATABASE_URL:
                    default: ${POSTGRES_CONNECTION_STRING}
                DB_PROVIDER:
                    default: postgresql
                NEXTAUTH_SECRET:
                    default: BiPt0IoRLLZEDfhB52lcM+tmaLmWfbDX6VuhA/aGmYM=
                NEXTAUTH_URL:
                    default: ${ZEABUR_WEB_URL}
localization:
    es-ES:
        description: LOJ - LeLe Online Judge, plataforma moderna de programación competitiva
        readme: |-
            # LOJ — LeLe Online Judge

            **LOJ** es una plataforma moderna de evaluación de programación construida con Next.js 16. Admite resolución de problemas, concursos, rutas de entrenamiento, asistente de IA y evaluación con múltiples motores.

            ## Características

            - **Sistema de Problemas** — Crea y gestiona problemas con múltiples casos de prueba
            - **Sistema de Concursos** — Modos ACM / OI, clasificaciones en tiempo real
            - **Rutas de Entrenamiento** — Conjuntos de problemas temáticos
            - **Asistente IA** — Chat integrado con guía de programación contextual
            - **Evaluación Multi-Motor** — OneCompiler, Judge0, Runoob
            - **Editor de Código** — Monaco Editor con resaltado de sintaxis
            - **Panel de Administración** — Gestión completa de usuarios, problemas, concursos
    ja-JP:
        description: LOJ - LeLe Online Judge、現代的なオンラインジャッジプラットフォーム
        readme: |-
            # LOJ — LeLe Online Judge

            **LOJ** は Next.js 16 で構築されたモダンなオンラインジャッジシステムです。プログラミング問題の解決、コンテスト、トレーニング、AI アシスタント、マルチエンジンコード評価をサポートします。

            ## 機能

            - **問題システム** — 複数のテストケース、セルフテストサンプル、BlockNote リッチテキスト編集を備えた問題の作成と管理
            - **コンテストシステム** — ACM / OI スコアリングモード、リアルタイムランキング
            - **トレーニング** — 段階的学習パスのためのテーマ別問題セット
            - **AI アシスタント** — 問題コンテキストを考慮したプログラミングガイダンス
            - **マルチエンジンジャッジ** — OneCompiler、Judge0、Runoob
    zh-CN:
        description: LOJ - LeLe Online Judge，现代化在线评测平台
        readme: |-
            # LOJ — LeLe Online Judge

            **LOJ** (LeLe Online Judge) 是一个现代化的在线评测平台，使用 Next.js 16 构建。支持编程题目练习、比赛、训练题单、AI 智能助教以及多引擎代码执行评测。

            ## 特性

            - **题目系统** — 创建和管理编程题目，支持多测试用例、自测样例、BlockNote 富文本编辑
            - **比赛系统** — 支持 ACM / OI 赛制，实时排名，独立题目副本
            - **训练题单** — 按主题组织题目，循序渐进的学习路径
            - **AI 智能助教** — 集成 AI 对话，题目上下文感知的编程辅导
            - **多引擎判题** — 可插拔评测引擎：OneCompiler（默认）、Judge0、Runoob
            - **代码编辑器** — Monaco Editor（VS Code 内核）支持多语言语法高亮
            - **用户系统** — NextAuth 认证，JWT Session，角色权限管理
            - **管理后台** — 用户、题目、比赛、训练、设置、存储全管理
            - **多存储支持** — 本地文件系统 / S3 兼容对象存储
            - **安全加固** — 内置速率限制、权限校验、IP 伪造防护、SSRF 防护

            ## 服务

            此模板部署两个服务：

            1. **postgresql** — PostgreSQL 18 数据库用于持久化存储
            2. **loj-web** — LOJ 应用服务器，Docker 镜像来自 [ghcr.io/aiwandiannaodelele/loj](https://github.com/aiwandiannaodelele/LOJ/pkgs/container/loj)

            ## 技术栈

            | 技术 | 用途 |
            |------|------|
            | **Next.js 16** | React 框架（App Router） |
            | **Tailwind CSS v4** | 样式 |
            | **shadcn/ui** | UI 组件库 |
            | **Prisma 7** | ORM / 数据库 |
            | **PostgreSQL 18** | 数据库 |
            | **NextAuth v5** | 认证（凭证 + JWT） |
            | **Monaco Editor** | 代码编辑器 |
            | **BlockNote** | 富文本编辑器 |
            | **OneCompiler / Judge0** | 评测引擎 |

            ## 环境变量

            以下变量已为你预配置：

            - `DB_PROVIDER` — 设置为 `postgresql`
            - `DATABASE_URL` — 通过 `${POSTGRES_CONNECTION_STRING}` 自动链接 PostgreSQL 服务
            - `NEXTAUTH_SECRET` — JWT 签名密钥（自动生成）

            ## 开始使用

            部署完成后，访问你的服务 URL。首次运行会自动初始化数据库结构。

            如需设置 OAuth 登录（GitHub/Google），在服务设置中添加以下变量：

            - `AUTH_GITHUB_ID`
            - `AUTH_GITHUB_SECRET`
            - `AUTH_GOOGLE_ID`
            - `AUTH_GOOGLE_SECRET`

            ## 源代码

            - GitHub: [github.com/aiwandiannaodelele/LOJ](https://github.com/aiwandiannaodelele/LOJ)
            - 许可证: GNU AGPL v3.0

            ## 更新

            本模板使用 ghcr.io 的 `latest` 镜像标签。如需更新，通过 GitHub Actions 重新构建 Docker 镜像，然后在 Zeabur Dashboard 中触发热部署。
    zh-TW:
        description: LOJ - LeLe Online Judge，現代化線上評測平台
        readme: |-
            # LOJ — LeLe Online Judge

            **LOJ** (LeLe Online Judge) 是一個現代化的在線評測平台，使用 Next.js 16 構建。支持編程題目練習、比賽、訓練題單、AI 智能助教以及多引擎代碼執行評測。

            ## 特性

            - **題目系統** — 創建和管理編程題目，支持多測試用例、自測樣例、BlockNote 富文本編輯
            - **比賽系統** — 支持 ACM / OI 賽制，實時排名，獨立題目副本
            - **訓練題單** — 按主題組織題目，循序漸進的學習路徑
            - **AI 智能助教** — 集成 AI 對話，題目上下文感知的編程輔導
            - **多引擎判題** — 可插拔評測引擎：OneCompiler（默認）、Judge0、Runoob
            - **代碼編輯器** — Monaco Editor（VS Code 內核）支持多語言語法高亮
            - **用戶系統** — NextAuth 認證，JWT Session，角色權限管理
            - **管理後臺** — 用戶、題目、比賽、訓練、設置、存儲全管理
            - **多存儲支持** — 本地文件系統 / S3 兼容對象存儲
            - **安全加固** — 內置速率限制、權限校驗、IP 偽造防護、SSRF 防護
