Generate tutorial documentation from codebases using LLMs and Restate workflows.
This application uses Restate for durable execution:
- cb2utorial service (port 9082) - Your service that runs the tutorial generation logic
- Restate server (typically port 9070) - The Restate runtime that manages durable execution
- CLI client - Invokes workflows through the Restate server
Make sure the Restate server is running:
restate-serverThe server should start on port 9070 (default).
./cb2utorialThis starts your service on port 9082 and binds all tutorial generation services.
Register your service deployment with the Restate server:
# If you have Restate CLI:
restate deployments register http://localhost:9082
# OR using curl:
curl -X POST http://localhost:9070/deployments \\
-H "Content-Type: application/json" \\
-d '{"uri": "http://localhost:9082"}'Or using the Restate UI:
http://localhost:9070/ui/overview
This tells the Restate server about your service and its handlers.
Now you can invoke the workflow through the Restate server ingress (port 9070), not directly:
# Using the CLI (after updating it):
cd cmd/cli
go run main.go --repo /path/to/repo --output ./tutorial
# OR using curl directly through Restate ingress:
curl -X POST http://localhost:9070/TutorialWorkflow/Run \\
-H "Content-Type: application/json" \\
-d '{
"localRepoPath": "/path/to/repo",
"outputDir": "./tutorial",
"maxFiles": 100
}'Create a .env file:
OPENROUTER_API_KEY=your_api_key_here
LLM_MODEL=your_llm_model_here (e.g. z-ai/glm-4.5-air:free)
MAX_FILE_SIZE=1048576
MAX_FILES=100
INCLUDE_PATTERNS=*.go,*.py,*.js,*.ts,*.md
EXCLUDE_PATTERNS=*_test.go,vendor/*,node_modules/*,.git/*
OUTPUT_DIR=./tutorial
- FileReaderService - Reads and indexes files from the repository
- AbstractionAnalyzerService - Identifies key code abstractions using LLM
- RelationshipAnalyzerService - Analyzes how abstractions relate
- ChapterOrdererService - Determines pedagogical chapter order
- ChapterWriterService - Generates tutorial chapters
- FileWriterService - Writes markdown files to disk
- TutorialWorkflow - Orchestrates the entire process durably
- Make sure Restate server is running
- Ensure service is registered with Restate
- Use Restate ingress port (9070), not service port (9082) for invocations
- Check that
Bind()uses method chaining (returns*Restate, not error) - Verify all services have proper method signatures