Illustration
AI illustration (SVG) β prompt builder + SVG security sanitization (Layer 3 Domain).
Statusβ
| Key | Value |
|---|---|
| Layer | domain |
| Tier | L1 |
| Status | wip |
| Version | 0.9.0 |
| Price | Free (free) |
| Category | Content |
Overviewβ
Overviewβ
Illustration is a Layer 3 Domain Plugin of multi-saas-kit. Provides a standard prompt builder + safety sanitizer for generating SVG illustrations via LLM, embeddable in learning content.
LLM call is delegated to AiRelay plugin; this plugin handles only the prompt composition + result validation Pure parts.
Core Componentsβ
Enumsβ
| Enum | Cases |
|---|---|
IllustrationKind | CARTOON / PHOTO / DIAGRAM / ICON |
StylePreset | FLAT / CARTOON / LINE / HAND_DRAWN |
Each has visualHint() / styleHint() for prompt construction.
PromptBuilder (Pure)β
Extracted from academy.how's IllustrationGenerator::buildPrompt. Inputs: caption + kind + style + locale. Auto-includes viewBox, localeβtitle-lang mapping, security constraints, size limits.
SvgSanitizer (Pure)β
Validates LLM-generated SVG safety + format.
- Auto-strips Markdown code fence (
```svg,```xml,```) - Validates
<svg>start +</svg>end - Blocks dangerous tags (script / foreignObject / iframe / object / embed)
- Blocks event handlers (onclick / onload / etc)
- Blocks external images (
<image href="https://...">) - Size limits (8KB / 60 lines)
Result: { ok, svg, issues, size_bytes, line_count }. Issue codes are i18n-able.
Configurationβ
return [
'enabled' => env('PLG_ILLUSTRATION_ENABLED', true),
'svg' => ['max_size_bytes' => 8192, 'max_lines' => 60, 'view_box' => '0 0 480 320'],
'forbidden' => [
'tags' => ['script', 'foreignObject', 'iframe', 'object', 'embed'],
'event_handlers' => ['onclick', 'onload', 'onmouseover', 'onerror'],
'block_external_images' => true,
],
'locale_to_title_lang' => [/* en/ja/zh/zh-TW/ko */],
];
Usageβ
$prompt = PromptBuilder::fromConfig(config('illustration'))->build(
caption: 'an apple in sunlight',
kind: IllustrationKind::CARTOON,
style: StylePreset::FLAT,
locale: app()->getLocale(),
);
$result = LlmRelayClient::fromConfig(config('ai-relay'))->complete([
'model' => 'gpt-4o-mini',
'messages' => [['role' => 'user', 'content' => $prompt]],
]);
$sanitized = SvgSanitizer::fromConfig(config('illustration'))->sanitize($result['data']['text']);
if ($sanitized['ok']) {
$documentIllustration->svg_content = $sanitized['svg'];
}
Originβ
Extracted from academy.how's IllustrationGenerator (320 LOC). LLM call / Eloquent save / AiRun tracking remain in project.
Dependenciesβ
- DocumentProcessor β embed SVG in Document
- AiRelay (optional) β LLM call adapter
- AiTracking (Phase 2) β generation history
Roadmap (Phase 3+)β
- Standard
IllustrationModel + Migration - Filament Resource
- Refine prompt (user instructions + attachment images)
- Multi-provider support
- Caption β SVG caching
Licenseβ
MIT
Dependenciesβ
Demosβ
- Platform κ΄λ¦¬μ ν¨λμμ λ©ν νμΈ π Login required
- μ¬μ© μμ (PHP)
π View on Plugin Store: store.codebase.how/plugins/illustration