Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

venikman/Expert-Builder

Repository files navigation

Expert Builder - FP-Style C# Learning Platform

An auto-graded learning platform for modern C# with a focus on functional programming patterns. Built with React, TypeScript, and Monaco Editor.

Features

  • Interactive Lessons: 5 FP-oriented C# exercises covering:

    • Pure Functions
    • Map and Filter (LINQ)
    • Function Composition
    • Option Types (Maybe monad)
    • Reduce/Fold patterns
  • Monaco Code Editor with:

    • C# syntax highlighting
    • Custom FP-focused completions (LINQ methods, lambdas, etc.)
    • Real-time diagnostics (compile errors/warnings)
    • Keyboard shortcuts (Ctrl+Enter to Run, Ctrl+Shift+Enter to Submit)
  • Auto-Grading Pipeline:

    • Compiles and runs C# code in isolated temporary directories
    • Runs test cases against student submissions
    • Provides personalized hints on failures
    • Tracks learner progress

Tech Stack

  • Frontend: React 19.2 (client-only SPA), TypeScript, TailwindCSS v4, Rsbuild
  • Code Editor: Monaco Editor with custom C# completions
  • Backend: Hono (TypeScript)
  • Runtime: Bun + .NET 10 (Roslyn Scripting API) for C# code execution
  • Testing: Bun test

Modern React 19 Notes

This app is currently client-only (no React Server Components). The recommended React 19 patterns we follow here are:

  • Async-first UI: Prefer Suspense + TanStack Query’s suspense helpers for data loading.
  • Mutations as Actions: Use async Actions (useActionState, optional <form action>) for pending/error sequencing.
  • Effect hygiene: Use useEffectEvent to keep subscriptions/listeners stable.
  • Performance: Rely on React Compiler where supported by the bundler; otherwise memoize only when profiling shows it helps.

If we later adopt an RSC-capable framework, pin react-server-dom-* packages to patched React 19.x versions to avoid known RSC CVEs.

Prerequisites

  • Bun 1.0+
  • .NET SDK 10.0+

Installing .NET 10 SDK

The RoslynRunner targets net10.0. On Ubuntu 22.04:

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O /tmp/msprod.deb
sudo dpkg -i /tmp/msprod.deb
sudo apt update
sudo apt install -y dotnet-sdk-10.0

The repo includes a global.json that pins the SDK version to ensure CI/CLI picks the correct one.

Note: If your environment only offers an older .NET SDK, you can temporarily retarget the runner to net8.0 in roslyn-runner/RoslynRunner.csproj. Installing SDK 10 is preferred to stay aligned with the ADR.

Setup

  1. Install dependencies:

    bun install
  2. (Optional) Enable PostHog analytics:

    • Copy .env.example.env
    • Set PUBLIC_POSTHOG_KEY (and optionally PUBLIC_POSTHOG_HOST)
    • By default we disable autocapture and session recording and only send explicit product events (no user code content).
  3. Start development server:

    bun run dev:all

    Frontend: http://localhost:5173
    API: http://localhost:5050

Scripts

Command Description
bun run dev Start API server with hot reload
bun run dev:client Start frontend dev server
bun run dev:all Start API + frontend
bun run build Build for production
bun run start Run production build
bun run check Type-check TypeScript
bun test Run test suite

Project Structure

├── client/ # React frontend
│ └── src/
│ ├── components/ # React components
│ │ ├── uuuu-editor.tsx
│ │ ├── lesson-page.tsx
│ │ └── output-panel.tsx
│ └── lib/
│ └── csharp-completions.ts
├── server/ # Hono backend
│ ├── routes.ts # API endpoints
│ ├── grading.ts # C# execution and grading logic
│ ├── storage.ts # Lesson data access
│ └── tests/ # Backend tests
├── roslyn-runner/ # Persistent .NET code executor
│ └── Program.cs # Roslyn Scripting API runner
└── shared/ # Shared types
 └── schema.ts # Zod schemas and TypeScript types

API Endpoints

  • GET /api/lessons - List all lessons
  • GET /api/lessons/:id - Get specific lesson
  • POST /api/execute - Execute C# code
  • POST /api/diagnostics - Get compile-time diagnostics
  • POST /api/submit - Submit code for grading

C# Code Execution

The grading pipeline uses a persistent Roslyn Scripting API runner for fast execution (~30-150ms):

  1. Server sends code to the Roslyn runner via stdin/stdout JSON protocol
  2. Runner compiles and executes using Roslyn Scripting API (warm context)
  3. Captures console output and compiler diagnostics
  4. Returns results as JSON response

See ADR-001 for architecture details.

Running Tests

bun test

Test coverage includes:

  • Integration tests for C# code execution
  • Multi-class code execution tests
  • Security/sandboxing tests

Lessons

Each lesson includes:

  • Content: Markdown explanation of the concept
  • Starter Code: Initial code template
  • Reference Solution: Correct implementation (hidden from students)
  • Test Cases: JSON array of test definitions
  • Hints: Static hints for common mistakes

Development Notes

  • Lessons are stored as static TypeScript data
  • Hints are provided inline in grading logic
  • Diagnostics come from Roslyn compiler
  • Optional: set ROSLYN_RUNNER_PATH to a prebuilt Roslyn runner binary (e.g. ./roslyn-runner/bin/Release/net10.0/RoslynRunner)

License

MIT

Releases

No releases published

Packages

No packages published

Contributors 2

AltStyle によって変換されたページ (->オリジナル) /