Skip to main content
Boss Battles are CodeJam’s ultimate coding challenges. Fight epic debugging scenarios in real ephemeral Linux sandboxes where you diagnose memory leaks, fix infinite loops, and debug production incidents.
Boss Battles require completing prerequisite campaign nodes. You’ll need boss keys earned from challenges to unlock these encounters.

What Are Boss Battles?

Boss Battles transform debugging into an esports experience. Instead of toy problems, you face realistic “Live Incidents” - production-style bugs running in actual Linux environments.

Real Sandboxes

Powered by Daytona, each battle runs in an ephemeral Linux container with full language runtime support.

Live Incidents

Debug memory leaks, race conditions, and performance bottlenecks like a production engineer.

Multi-Language

Supports Python, TypeScript, and JavaScript scenarios with full execution environments.

Session Persistence

Your work is saved. Resume boss battles across sessions.

Powered by Daytona

CodeJam uses the Daytona SDK to provision ephemeral Linux sandboxes on-demand. Each Boss Battle spins up a fresh environment with:
  • Full language runtime (Python, JavaScript, TypeScript)
  • File system access
  • Code execution engine
  • Real-time process management

Creating a Sandbox

When you start a Boss Battle, the platform creates a Daytona sandbox:
// From convex/daytona.ts:13-34
export const create = action({
  args: { language: v.string() },
  handler: async (ctx, args) => {
    const userId = await getAuthUserId(ctx);
    if (!userId) throw new Error("Unauthorized");
    
    const daytona = getDaytona();

    // Supported languages: python, typescript, javascript
    const supportedLanguages = ['python', 'typescript', 'javascript'];
    const lang = args.language.toLowerCase();
    
    if (!supportedLanguages.includes(lang)) {
        throw new Error(`Unsupported language: ${args.language}`);
    }

    const sandbox = await daytona.create({ language: lang });
    
    return { sandboxId: sandbox.id };
  },
});
Each sandbox is isolated and ephemeral. When you complete or exit a boss battle, the environment is automatically destroyed.

Running Code

Once your sandbox is provisioned, you can execute code in real-time:
// From convex/daytona.ts:36-65
export const run = action({
  args: { sandboxId: v.string(), code: v.string() },
  handler: async (ctx, args) => {
    const userId = await getAuthUserId(ctx);
    if (!userId) throw new Error("Unauthorized");

    const daytona = getDaytona();
    let sandbox = await daytona.get(args.sandboxId);

    // Ensure sandbox is started and ready
    await sandbox.start();
    await sandbox.waitUntilStarted();

    const response = await sandbox.process.codeRun(args.code);
    return response.result;
  },
});

Session Management

Boss Battle sessions are tracked in the database, allowing you to resume your progress:
// From convex/schema.ts:102-108
boss_sessions: defineTable({
  userId: v.id("users"),
  sandboxId: v.string(),
  language: v.string(),
  status: v.union(v.literal("active"), v.literal("closed")),
  createdAt: v.number(),
}).index("by_user_status", ["userId", "status"])

Creating a Session

When you enter a Boss Battle:
// From convex/boss.ts:5-32
export const createSessionRecord = mutation({
  args: {
    sandboxId: v.string(),
    language: v.string(),
  },
  handler: async (ctx, args) => {
    const userId = await getAuthUserId(ctx);
    if (!userId) throw new Error("Unauthorized");
    
    // Close existing active sessions for this user
    const existing = await ctx.db
        .query("boss_sessions")
        .withIndex("by_user_status", q => 
          q.eq("userId", userId).eq("status", "active")
        )
        .collect();
        
    for (const session of existing) {
        await ctx.db.patch(session._id, { status: "closed" });
    }

    return await ctx.db.insert("boss_sessions", {
      userId,
      sandboxId: args.sandboxId,
      language: args.language,
      status: "active",
      createdAt: Date.now(),
    });
  },
});
Only one active session is allowed per user. Starting a new Boss Battle automatically closes your previous session.

Retrieving Active Sessions

// From convex/boss.ts:34-47
export const getActiveSession = query({
  args: {},
  handler: async (ctx) => {
    const userId = await getAuthUserId(ctx);
    if (!userId) return null;

    return await ctx.db
      .query("boss_sessions")
      .withIndex("by_user_status", (q) => 
        q.eq("userId", userId).eq("status", "active")
      )
      .first();
  },
});

Live Incidents

Each Boss Battle presents a “Live Incident” - a production-style debugging scenario:
Scenario: Your web app is consuming unbounded memory.Challenge: Identify the leaking closure or event listener and patch it.Languages: JavaScript, TypeScriptDifficulty: Advanced
Scenario: A background job is stuck in an infinite loop, blocking the main thread.Challenge: Identify the loop condition and fix the termination logic.Languages: Python, JavaScriptDifficulty: Intermediate
Scenario: Asynchronous operations are producing inconsistent results.Challenge: Debug the race condition using proper synchronization.Languages: Python (asyncio), JavaScript (Promises)Difficulty: Expert
Scenario: API responses are taking 10+ seconds.Challenge: Profile the code and optimize the O(n²) algorithm.Languages: Python, TypeScriptDifficulty: Advanced

Campaign Integration

Boss Battles are integrated into the campaign system as “boss” type nodes:
// From convex/campaign.ts:203-212
{
  slug: "node-4-boss-html",
  title: "BOSS: DOM Destroyer",
  type: "boss",
  tier: "html",
  requires: ["node-3-css-intro"],
  position: { x: 700, y: 300 },
  data: {
    description: "Fix the memory leak in the layout engine.",
    bossScenario: "memory-leak" 
  }
}
Boss nodes require completing all prerequisite challenges. The campaign system automatically unlocks boss battles when you finish the required nodes.

Architecture

1

User Starts Boss Battle

Client requests a new sandbox from convex/daytona.ts:create()
2

Daytona Provisions Sandbox

Ephemeral Linux environment is created with the selected language runtime
3

Session Record Created

convex/boss.ts:createSessionRecord() stores the session with status: "active"
4

User Debugs Code

Client executes code via convex/daytona.ts:run(), receiving real-time results
5

Battle Completion

Session is marked status: "closed" and XP is awarded via convex/activity.ts

Configuration

Boss Battles require the DAYTONA_API_KEY environment variable to be configured on your Convex backend.
// From convex/daytona.ts:7-11
const getDaytona = () => {
  const apiKey = process.env.DAYTONA_API_KEY;
  if (!apiKey) throw new Error("DAYTONA_API_KEY not configured");
  return new Daytona({ apiKey });
};

Required Environment Variables

DAYTONA_API_KEY=your_daytona_api_key_here
Get your API key from the Daytona Dashboard.

Rewards

Completing Boss Battles unlocks:
  • Boss Keys - Used to access higher tiers in the campaign
  • Massive XP - Boss completions award 500+ XP
  • Campaign Progression - Unlocks new learning tracks
  • Badges - Epic achievement badges for your profile

Next Challenge

Ready to face a boss? Complete the prerequisite challenges in your campaign track, then look for nodes marked with the dragon icon.

Campaign System

Learn how boss battles fit into the campaign

Game Modes

Master challenges before facing bosses

Build docs developers (and LLMs) love