A full-stack, open-source online judge platform designed to elevate college programming education.
Go to file
cfngc4594 5af9d88db7
Some checks failed
Build & Push Judge4c Docker Image / build-and-push-judge4c-docker-image (., Dockerfile, judge4c) (push) Failing after 17s
feat: update main branch (#45)
* chore(deps): add pino and pino-pretty packages

* feat(log): add pino logging support

* chore(tailwind): update config with features path and animate import

* chore(deps): add react-icons package

* refactor(auth)!: replace credentials with OAuth providers and add logging

BREAKING CHANGE:
- Removed credentials-based authentication
- Added Google OAuth provider
- Implemented detailed logging for auth events
- Removed custom JWT/session handling
- Added sign-in page configuration
- Marked as server-only

* refactor(auth)!: remove components and rewrite sign-in page

* feat(user-avatar): refactor avatar component into user-avatar with improved structure

* style(dockview): reduce tabs container height and center align items

- Changed --dv-tabs-and-actions-container-height from 44px to 36px
- Added align-items: center to .dv-tabs-container
- Improved CSS formatting for better readability

* refactor(stores): split dockview store into problem-specific store

- Remove generic dockview store (`src/stores/dockview.tsx`)
- Add problem-specific dockview store (`src/stores/problem-dockview.tsx`)
- Remove submission-related state as it's no longer needed

* feat(dockview): refactor dockview component and add problem-specific implementation

- Refactor Dockview component into more modular structure:
  - Extract layout persistence logic to custom hook
  - Extract component conversion logic to custom hook
  - Make storageKey optional
  - Improve type safety with PanelParams interface
  - Add better error handling and duplicate panel detection
- Add new ProblemDockview wrapper component:
  - Integrates with problem-dockview store
  - Adds locale awareness
  - Provides standardized storage key
- Update related type definitions and imports

* refactor(problems): migrate description and solution to feature-based structure

- Remove old parallel route implementations (@Description and @Solutions)
- Add new feature-based components for problem description and solution
  - Create content and panel components for both features
  - Implement skeleton loading states
  - Use cached data fetching
- Update MDX rendering and scroll area implementations

* chore(problems): move problem-dockview to components directory

* refactor(layouts): overhaul problem and problemset page structures

- Simplify ProblemLayout to use children prop and remove ProblemStoreProvider
- Replace PlaygroundHeader with dedicated ProblemHeader component
- Streamline ProblemsetLayout with new ProblemsetHeader
- Remove deprecated BackButton in favor of NavigateBackButton
- Delete unused ProblemStoreProvider and related dependencies

* feat(prisma): add server-only caching for problems queries

- Add 'server-only' import to enforce server-side usage
- Implement cached problem queries with logging:
  - Add getProblems/getCachedProblems for all problems
  - Add getProblem/getCachedProblem for single problem by ID
- Use React cache and Next.js unstable_cache with tags
- Add detailed logging with timing metrics

* refactor(mdx-renderer): simplify component implementation

- Remove Suspense and Skeleton loading state
- Convert to arrow function syntax
- Reorganize import statements
- Simplify export syntax

* feat(components): add TooltipButton component

- A reusable button with tooltip functionality
- Supports customizable delay, tooltip content, and className
- Uses shadcn/ui Tooltip and Button components

* refactor(editor): consolidate editor toolbar actions into unified structure

- Moved all editor action buttons (copy, format, undo, redo, reset) from `src/components/features/playground/workspace/editor/components/` to new location `src/features/problems/code/components/toolbar/actions/`
- Introduced shared `TooltipButton` component to reduce duplication
- Created centralized `useProblemEditorActions` hook for common editor operations
- Updated imports and exports through new index file
- Maintained all existing functionality while improving code organization

* refactor(structure): reorganize page and component exports

- Move root page from /(app) to / directory
- Convert default exports to named exports in components
- Rename MainView component to HeroSection for better semantics

* refactor(route): rename [id] to [problemId] in problems route

* chore(components): remove unused problem-related components

- Delete footer.tsx from problem/description
- Delete solution.tsx from problem/description
- Delete header.tsx from problem/workspace/editor/components

* fix(page): add missing return statement in RootPage component

* feat(prisma/schema): add multilingual support for problem descriptions and solutions

BREAKING CHANGE:
- Removed `description` and `solution` fields from Problem model
- Added new models `ProblemDescription` and `ProblemSolution` with language support (EN/ZH)
- Updated seed data structure to support multilingual content
- Requires database migration and data migration from old structure

* chore(prisma/migrations): add migration for multilingual problem support

* fix(styles): adjust tabs overflow container height in abyss theme

Changed height property from 'unset !important' to '100%' for .dv-tabs-overflow-container and .dv-tabs-overflow-dropdown-default in the abyss-spaced theme to fix layout issues.

* refactor(loading): change to named export and arrow function

- Switch from default export to named export
- Convert component to arrow function
- Remove unused props parameter

* chore(shiki): convert function to arrow function

* chore(scripts): remove --turbopack flag from dev script

* refactor(prisma): simplify schema and remove zod-prisma-types

- Reorganized Prisma schema structure with simplified models and relations
- Removed zod-prisma-types generator as it's no longer needed
- Consolidated problem content types into a single ProblemLocalization model
- Simplified testcase and template structures
- Removed unused prisma types file

* refactor(prisma): simplify schema and remove zod-prisma-types

- Reorganized Prisma schema structure with simplified models and relations
- Removed zod-prisma-types generator as it's no longer needed
- Consolidated problem content types into a single ProblemLocalization model
- Simplified testcase and template structures
- Removed unused prisma types file

* refactor(i18n): migrate locale configuration to generated types

- Replace hardcoded locale strings with generated Locale enum from client
- Update cookie key name to be more specific (LOCALE_COOKIE_NAME -> JUDGE4C_LOCALE_KEY)
- Rename defaultLocale to DEFAULT_LOCALE for consistency
- Add 'server-only' imports to ensure server-side usage
- Simplify locale validation using Object.values(Locale)
- Clean up accept-language header parsing logic

* refactor(hooks): remove theme config and simplify theme hook

- Delete src/config/monaco-theme.ts and src/types/monaco-theme.ts
- Simplify useMonacoTheme hook to directly return theme strings
- Format use-mobile.ts with consistent semicolons and quotes

* refactor(i18n): replace language-settings with locale-switcher

- Replace react-world-flags with next/image for better optimization
- Simplify locale handling logic and remove unused getUserLocale
- Rename component to be more descriptive (language-settings -> locale-switcher)
- Update all references to use the new component
- Add proper SVG flag assets for supported locales
- Remove react-world-flags dependency from package.json

* refactor(shiki): migrate to shiki/core with lazy initialization

- Replace shiki with shiki/core for better tree-shaking
- Change highlighter initialization to explicit theme/lang imports
- Export getHighlighter function instead of direct highlighter instance
- Add error handling for uninitialized highlighter access

* refactor(language-selector): migrate to new location and implementation

- Remove old language selector from `src/components/features/playground/workspace/editor/components`
- Add new implementation in `src/features/problems/code/components/toolbar/controls`
- Update toolbar exports to include the new selector

* feat(problems): add localization support for problem descriptions and solutions

- Replace cached problem data with direct Prisma queries for localized content
- Implement locale-based content selection for both descriptions and solutions
- Refactor skeleton loading components structure
- Change all exports from named to default exports

* refactor(code-toolbar): standardize component exports and simplify reset logic

- Changed all toolbar action components from named exports with curly braces to default exports
- Simplified ResetButton by moving template logic to useProblemEditorActions hook
- Updated useProblemEditorActions to handle template selection internally using store data
- Renamed problem-editor-store import to problem-editor for consistency

* refactor(prisma): simplify prisma client initialization and remove caching

Removed all caching and logging functionality from prisma.ts, keeping only
the basic Prisma client initialization logic. This includes:
- Removal of getProblems, getCachedProblems, getProblem, getCachedProblem functions
- Removal of related logger and cache imports
- Simplified the global prisma client instantiation

* feat(config): add LANGUAGES constant for language enum values

* refactor(problemset): move components to separate files and improve structure

- Move ProblemsetHeader component from 'problemset-header' to 'header'
- Extract problemset table logic into dedicated ProblemsetTable component
- Add Suspense and skeleton loading for better UX
- Update layout and page structure

* feat(dockview): export Dockview component and create ProblemDockview wrapper

- Export Dockview component from src/components/dockview.tsx to make it reusable
- Create new ProblemDockview component in src/features/problems/components/dockview.tsx that:
  - Integrates with next-intl for locale handling
  - Connects to problem-dockview store
  - Wraps Dockview with problem-specific configuration
  - Adds locale-based key for proper re-rendering
- Maintain existing Dockview functionality including:
  - Layout persistence
  - Panel management
  - API handling

* refactor(problems): update ProblemHeader import path to new location

* refactor(mdx-render): simplify theme configuration and change export style

- Remove custom Monaco theme imports
- Use github default themes for rehypePrettyCode
- Change component export from default to named export

* feat(store): add problem editor state management

- Create problem-editor store with Zustand
- Manage editor state including problem, language, value and path
- Implement localStorage persistence for editor content
- Provide utility functions for language and value retrieval

* chore(utils): remove unused utility functions

- Remove getPath function (moved to problem-editor store)
- Remove getDifficultyColorClass function (unused)
- Keep only core cn utility function

* feat(code-panel): add code editor panel components

- Add CodePanel component as container for editor interface
- Add CodeContent component with Prisma data fetching
- Include CodeContentSkeleton for loading state
- Implement ProblemEditor integration with templates

* refactor(back-button): relocate and rename back button component

- Move from features/problems/components to shared components directory
- Rename NavigateBackButton to simpler BackButton
- Update component interface naming to BackButtonProps
- Keep all existing functionality intact

* feat(problemset): enhance header component with back button and className prop

- Replace problem-header.tsx with new header.tsx implementation
- Add BackButton functionality to navigate to home page
- Make className prop configurable using cn utility
- Maintain existing user avatar functionality

* refactor(config): migrate editor options to standalone editor config

- Rename `editor-language.ts` to `editor.ts`
- Update interface from `IEditorConstructionOptions` to `IStandaloneEditorConstructionOptions`
- Keep all existing editor options unchanged

* refactor(components): simplify BackButton by using TooltipButton

* refactor(problems): consolidate judge status toast

- Migrate status toast from shared hooks to problems feature
- Remove deprecated show-status-toast.tsx and status.ts
- Implement self-contained JudgeToast component with built-in status mapping

* refactor(judge-button): migrate run code button to standalone component

- Replace RunCodeButton with new JudgeButton component
- Use problem-specific stores instead of playground stores
- Implement new judge toast notification system
- Simplify authentication check logic
- Utilize new TooltipButton component

* refactor(api): extract OpenAI client to shared module

* fix(prisma): make TestcaseResult.output field optional

* chore(prisma): make TestcaseResult.output nullable in migration

* feat: replace dockview with flexlayout-react
2025-06-21 06:09:57 +00:00
.github/workflows chore(workflow): update workflow for judge4c docker image 2025-03-25 21:51:22 +08:00
.vscode fix(vscode): remove src/i18n from i18n-ally.localesPaths and set keystyle to nested 2025-04-19 12:59:42 +08:00
docker/lsp/clangd feat(docker): update optimized Dockerfile and compose for CN environment 2025-03-25 21:43:45 +08:00
messages feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
prisma feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
public feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
src feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
.dockerignore chore(docker): update .dockerignore to exclude additional files and directories 2025-04-08 14:02:24 +08:00
.env.example chore(env): update .env.example with PostgreSQL host/port and Docker remote access configuration 2025-04-08 14:04:06 +08:00
.gitignore chore(gitignore): add generated folder to ignore list 2025-04-01 01:59:41 +08:00
bun.lock feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
components.json chore: initialize shadcn/ui 2025-02-19 09:07:30 +08:00
compose.cn.yml chore(docker): add compose.cn.yml file 2025-04-15 13:27:08 +08:00
compose.local.cn.yml chore(docker): rename compose files to local variants 2025-04-08 16:06:22 +08:00
compose.local.yml chore(docker): rename compose files to local variants 2025-04-08 16:06:22 +08:00
compose.yml chore(docker): switch to pre-built docker images from remote registry 2025-04-08 16:07:54 +08:00
demo.png chore(images): replace demo image with new version 2025-03-26 14:47:17 +08:00
Dockerfile fix(docker): include generated files in builder stage 2025-04-06 18:42:05 +08:00
Dockerfile.cn feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
eslint.config.mjs chore(eslint): ignore generated files in linting 2025-04-01 12:51:30 +08:00
LICENSE chore: add MIT License file to the repository 2025-02-19 18:38:49 +08:00
next.config.ts feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
package.json feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
postcss.config.mjs chore(postcss): support GitHub Markdown theme switching 2025-03-06 21:19:48 +08:00
README.md docs(readme): improve WSL network config and add TLS troubleshooting guide 2025-04-09 11:43:39 +08:00
tailwind.config.ts feat: update main branch (#45) 2025-06-21 06:09:57 +00:00
tsconfig.json chore(tsconfig): enable strictNullChecks in tsconfig.json 2025-04-01 01:56:15 +08:00

Judge4c

A full-stack, open-source online judge platform designed to elevate college programming education.

demo

⚠️ Network Configuration & Troubleshooting

🐧 For WSL Users: Mirrored Network Mode Requirement

When using Windows Subsystem for Linux (WSL), you must configure your network mode as Mirrored to ensure proper LSP server connectivity. Standard WSL network configurations may create IPv6 conflicts that block Monaco-LSP communication.

🔧 Mirror Mode Setup:

  1. Open WSL settings ⚙️
  2. Navigate to Network section 🌐
  3. Select Mirrored mode 🔄
  4. Restart WSL instance 💻

Complete these steps before launching the editor for seamless LSP integration! 🎉

🚨 Troubleshooting: TLS Connection Error Due to Network Proxy

If you encounter the following error:

[Error: Client network socket disconnected before secure TLS connection was established]

Please check if a network proxy (e.g., VPN, HTTP/SOCKS proxy, etc.) is enabled on your system and disable it. The active proxy may interfere with the establishment of a secure TLS connection.

🚀 Getting Started

Quickly deploy the project using Docker with these steps:

# Clone the repository
git clone https://github.com/massbug/judge4c

# Navigate to project directory
cd judge4c

# Set up environment configuration
cp .env.example .env
# Edit the .env file with your configuration

# Build and start containers in detached mode
docker compose up -d

🛠️ Local Development Setup

For local development, follow these steps:

Step 1: Clone the Repository

git clone https://github.com/massbug/judge4c
cd judge4c

Step 2: Install Dependencies

This project uses bun as the default package manager, but you can also use other package managers like npm, yarn, or pnpm if you prefer.

If you choose to use a package manager other than bun, you should delete the bun.lock file from your project directory.

The Dockerfile is designed to dynamically detect and adapt to the package manager you are using, ensuring compatibility with your preferred tool.

bun install

Step 3: Configure Environment Variables

  1. Copy the example environment file:

    cp .env.example .env
    
  2. Open the .env file and set the following variables:

    • PostgreSQL Credentials:

      POSTGRES_USER="your_postgres_user"
      POSTGRES_PASSWORD="your_postgres_password"
      POSTGRES_DB="your_postgres_db"
      # POSTGRES_HOST and DATABASE_URL are used for local development.
      # Note: In compose.yml, POSTGRES_HOST is hardcoded as "postgres" and POSTGRES_PORT as "5432".
      # If you need to change them, update the corresponding values in the environment section of compose.yml.
      POSTGRES_HOST="your_postgres_host"
      POSTGRES_PORT="your_postgres_port"
      DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?schema=public"
      
    • Authentication Secret: Generate a secure secret key using:

      bunx auth secret
      

      Then, set the AUTH_SECRET variable:

      AUTH_SECRET="your_auth_secret"
      
    • GitHub OAuth (Optional): If you need GitHub OAuth, replace the following variables with your GitHub OAuth credentials:

      AUTH_GITHUB_ID="your_github_client_id"
      AUTH_GITHUB_SECRET="your_github_client_secret"
      
    • Authentication Callback URL: Set the base URL for authentication callbacks (typically your app's domain):

      AUTH_URL="http://localhost:3000"  # Replace with your production URL if deployed
      
    • OpenAI API Configuration (Optional): If you use OpenAI-based features, provide your API key and custom endpoint (if applicable):

      OPENAI_API_KEY="your_openai_api_key"              # Required for AI features
      OPENAI_BASE_URL="your_openai_base_url_if_custom"  # Optional, for self-hosted proxies
      
    • Docker Remote Access Configuration (Optional): If you require remote access to Docker, update the following settings:

      # Docker Remote Access Configuration
      DOCKER_HOST_MODE="remote_or_blank"
      DOCKER_REMOTE_PROTOCOL="http_or_https_or_ssh"
      DOCKER_REMOTE_HOST="your_docker_remote_host"
      DOCKER_REMOTE_PORT="your_docker_remote_port"
      # Docker TLS/SSL Certificate Paths (only required when DOCKER_HOST_MODE is set to "remote" **with TLS** enabled)
      DOCKER_REMOTE_CERTS_PATH="your_certs_path"
      DOCKER_REMOTE_CA_PATH="your_ca_path" # Default: /certs/ca.pem
      DOCKER_REMOTE_CERT_PATH="your_cert_path" # Default: /certs/cert.pem
      DOCKER_REMOTE_KEY_PATH="your_remote_key_path" # Default: /certs/key.pem
      

Step 4: Start the Application

Once the environment variables are configured, start the application using Docker Compose:

docker compose -f compose.local.yml up -d --build

For Chinese users:

docker compose -f compose.local.cn.yml up -d --build

Step 5: Access the Application

The application should now be running. You can access it at:

  • Web Interface: http://localhost:3000
  • LSP Service (C Language): ws://localhost:4594/clangd
  • LSP Service (C++ Language): ws://localhost:4595/clangd

📁 .env.example File

For reference, you can see the content of the .env.example file.

⚙️ Technical Configuration

LSP Server Mapping

Language LSP Server Port
C clangd 4594
C++ clangd 4595

📦 Dependency Management

🔒 Version Lock Requirements

Critical Pairing:

Package Max Version Reference
monaco-editor ≤0.36.1 Compatibility Matrix
monaco-languageclient ≤5.0.1

Version Lock Rationale:

  1. API Stability

    • Newer monaco-editor (≥0.40.0) breaks monaco-languageclient integration
    • v0.36.1 matches @codingame/monaco-vscode-api@1.76.9 requirements
  2. LSP Feature Breakdown

    • Version mismatches disable:
      • Auto textDocument/didOpen events
      • textDocument/inlayHint resolution
      • textDocument/documentLink functionality
  3. Version Conflict

    • @codingame package versioning (e.g., 11.1.2) ≠ monaco-editor versions (e.g., 0.36.1)
    • @monaco-editor/react depends on monaco-editor versioning scheme

Failure Indicators:

  • ✔️ WebSocket connection established
  • Missing syntax highlighting
  • No autocomplete suggestions
  • Silent LSP initialization failures