Skip to content

Commit dcec77d

Browse files
committed
feat: started on new workflow hub feature
1 parent 9029ffa commit dcec77d

File tree

80 files changed

+7298
-2272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+7298
-2272
lines changed

CLAUDE.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# CLAUDE.md — ComfyUI Workflow Templates Monorepo
2+
3+
## What This Repo Is
4+
5+
A monorepo managing **ComfyUI workflow templates** distributed as Python packages AND a public **Astro-based workflow hub website** at templates.comfy.org. Two distinct systems share the same template data.
6+
7+
## Repository Map
8+
9+
```
10+
workflow_templates/
11+
├── templates/ # SOURCE OF TRUTH: workflow JSONs, thumbnails, index metadata
12+
│ ├── index.json # Master template metadata (English)
13+
│ ├── index.{locale}.json # 11 locale variants (zh, ja, ko, es, fr, ru, tr, ar, pt-BR, zh-TW)
14+
│ ├── *.json # ComfyUI workflow definitions
15+
│ └── *-1.webp, *-2.webp # Template thumbnails
16+
├── blueprints/ # Reusable subgraph blueprint definitions
17+
├── bundles.json # Maps template names → Python package bundles
18+
├── blueprints_bundles.json # Maps blueprint names → package
19+
├── packages/ # Python distribution packages (Nx monorepo)
20+
│ ├── core/ # Loader + manifest
21+
│ ├── media_api/ # API-calling templates (Replicate, BFL, etc.)
22+
│ ├── media_image/ # Image generation templates
23+
│ ├── media_video/ # Video generation templates
24+
│ ├── media_other/ # Audio, 3D, utilities
25+
│ ├── meta/ # Meta package aggregating all above
26+
│ └── blueprints/ # Subgraph blueprints package
27+
├── scripts/ # Python: validation, sync, i18n
28+
├── site/ # INDEPENDENT Astro 5 project (see "Site" section below)
29+
├── docs/ # Specs, i18n guide, publishing guide
30+
├── .claude/skills/ # 6 Claude skill definitions
31+
├── .github/workflows/ # CI/CD (validation, deploy, lint, tests)
32+
├── pyproject.toml # Python project version & config
33+
├── package.json # Nx monorepo root (npm run sync, etc.)
34+
└── nx.json # Nx workspace config
35+
```
36+
37+
## Two Distinct Systems
38+
39+
### System 1: Template Packages (Python/PyPI)
40+
- Templates are grouped into 4 media bundles via `bundles.json`
41+
- `scripts/sync_bundles.py` copies templates + thumbnails into package directories
42+
- Published to PyPI as `comfyui-workflow-templates-*` packages
43+
- Version lives in root `pyproject.toml` (currently 0.8.43)
44+
45+
### System 2: Astro Website (`site/`)
46+
- **Independent project** — own `package.json`, `pnpm-lock.yaml`, tooling
47+
- Consumes templates from `../templates/` via sync scripts
48+
- AI content generation pipeline (GPT-4o) enriches template pages
49+
- Deployed to Vercel
50+
51+
## Data Flow
52+
53+
```
54+
templates/index.json + *.json + *.webp
55+
├──→ scripts/sync_bundles.py ──→ packages/media_*/
56+
└──→ site/scripts/sync-templates.ts ──→ site/src/content/templates/
57+
└──→ site/scripts/generate-ai.ts ──→ AI-enriched content
58+
└──→ astro build ──→ templates.comfy.org (Vercel)
59+
```
60+
61+
## Key Commands
62+
63+
### Root (template management)
64+
```bash
65+
npm run sync # Sync bundle manifests + assets to packages
66+
python scripts/validate_templates.py # Validate template JSON
67+
python scripts/sync_data.py --templates-dir templates # Sync i18n translations
68+
```
69+
70+
### Site (in site/ directory)
71+
```bash
72+
pnpm install # Install deps (required first)
73+
pnpm run dev # Dev server at localhost:4321
74+
pnpm run build # Full build (prebuild + astro build)
75+
pnpm run sync # Sync templates from ../templates/
76+
pnpm run sync -- --top-50 # Sync top 50 only (faster dev)
77+
pnpm run generate:ai # AI content generation (needs OPENAI_API_KEY)
78+
pnpm run generate:ai -- --skip-ai # Use placeholder content (no API key needed)
79+
pnpm run lint # ESLint
80+
pnpm run format # Prettier
81+
pnpm run test:e2e # Playwright E2E tests
82+
```
83+
84+
## Template Structure
85+
86+
### index.json Entry
87+
Each template in `templates/index.json` has:
88+
- `name` — Must match the JSON filename (snake_case, no extension)
89+
- `title`, `description` — Display metadata
90+
- `mediaType` — "image" | "video" | "audio" | "3d"
91+
- `mediaSubtype` — Usually "webp"
92+
- `thumbnailVariant` — "compareSlider" | "hoverDissolve" | "hoverZoom" | "zoomHover" | null
93+
- `tags`, `models`, `logos`, `date`, `usage`, `size`, `vram`, `searchRank`
94+
- `tutorialUrl`, `openSource`, `requiresCustomNodes`, `io`
95+
96+
### Workflow JSON Files
97+
Standard ComfyUI workflow format with embedded model metadata:
98+
- `properties.models[]` — Download URLs, SHA256 hashes, target directories
99+
- `properties.cnr_id` + `properties.ver` — Node version pinning
100+
101+
### Thumbnails
102+
- Named `{template_name}-1.webp` (primary), `{template_name}-2.webp` (comparison)
103+
- WebP format, target <1MB, 512×512 or 768×768
104+
105+
## Bundle Assignment
106+
Templates in `bundles.json` map to Python packages:
107+
| Bundle | Contents |
108+
|--------|----------|
109+
| `media-api` | Templates using external APIs |
110+
| `media-image` | Image generation/editing |
111+
| `media-video` | Video generation |
112+
| `media-other` | Audio, 3D, utilities |
113+
114+
## Internationalization
115+
116+
### 11 Supported Languages
117+
en (default), zh, zh-TW, ja, ko, es, fr, ru, tr, ar, pt-BR
118+
119+
### Template i18n
120+
- Master: `templates/index.json` (English)
121+
- Locales: `templates/index.{locale}.json`
122+
- Translation tracking: `scripts/i18n.json`
123+
- Sync: `python scripts/sync_data.py --templates-dir templates`
124+
125+
### Site i18n
126+
- Config: `site/src/i18n/config.ts`
127+
- UI strings: `site/src/i18n/ui.ts`
128+
- URL pattern: English at `/templates/`, others at `/{locale}/templates/`
129+
- SEO: Hreflang tags via `HreflangTags.astro`
130+
131+
## Site Architecture (Astro 5)
132+
133+
### Key Directories
134+
- `site/src/pages/` — Route pages ([slug].astro, [locale]/templates/)
135+
- `site/src/components/` — Astro components (TemplateCard, TemplateDetailPage, etc.)
136+
- `site/src/lib/` — Utilities (templates.ts, urls.ts, slugify.ts, model-logos.ts)
137+
- `site/src/content/` — Content collections (git-ignored, generated by sync)
138+
- `site/scripts/` — Build scripts (sync, AI generation, previews, OG images)
139+
- `site/knowledge/` — AI generation context (prompts, model docs, concepts)
140+
- `site/overrides/templates/` — Human-edited content (survives AI regeneration)
141+
142+
### AI Content Pipeline
143+
1. `sync-templates.ts` syncs metadata from `../templates/`
144+
2. `generate-ai.ts` calls GPT-4o with context from `knowledge/`
145+
3. Generates: extendedDescription, howToUse[], metaDescription, suggestedUseCases[], faqItems[]
146+
4. Content templates: tutorial (default), showcase, comparison, breakthrough
147+
5. Cached in `.content-cache/` with hash-based invalidation
148+
6. Human overrides in `site/overrides/templates/{name}.json` (set `humanEdited: true`)
149+
150+
### Critical Site Components (DO NOT remove/modify without care)
151+
- `SEOHead.astro` — Meta tags, structured data
152+
- `HreflangTags.astro` — i18n SEO
153+
- `t()` calls, `localizeUrl()` — i18n functions
154+
- `<Analytics />` — Telemetry
155+
156+
## CI/CD
157+
158+
### Template Validation (triggers on templates/ changes)
159+
- `validate-templates.yml` — JSON schema validation
160+
- `validate-blueprints.yml` — Blueprint validation
161+
- `validate-manifests.yml` — Manifest sync check
162+
- `link-checker.yml` — Model download URL validation
163+
164+
### Site (triggers on site/ changes)
165+
- `lint-site.yml` — ESLint + Prettier
166+
- `e2e-tests-site.yml` — Playwright tests
167+
- `visual-regression-site.yml` — Visual regression
168+
- `seo-audit-site.yml` — SEO audit
169+
- `lighthouse.yml` — Performance checks
170+
- `deploy-site.yml` — Manual Vercel deploy
171+
172+
## Code Style
173+
- **Python**: Ruff, line-length 100, py312, rules E/F
174+
- **TypeScript/Astro**: ESLint + Prettier (configured in site/)
175+
- **Templates**: snake_case naming, JSON format
176+
- **Commits**: Bump version in `pyproject.toml` when modifying templates
177+
178+
## Claude Skills Available
179+
- `/adding-templates` — Add new workflow templates (full workflow)
180+
- `/managing-bundles` — Move templates between bundles, reorder
181+
- `/managing-thumbnails` — Add/replace/audit thumbnails
182+
- `/managing-translations` — Sync/check translations across 11 languages
183+
- `/editing-site-content` — Edit site page content with overrides
184+
- `/regenerating-ai-content` — Regenerate AI descriptions, manage cache
185+
186+
## Important Docs
187+
- `docs/SPEC.md` — Formal template JSON schema
188+
- `docs/BLUEPRINTS.md` — Subgraph blueprint spec
189+
- `docs/I18N_GUIDE.md` — Translation management workflow
190+
- `site/docs/PRD.md` — Product requirements for the site
191+
- `site/docs/TDD.md` — Technical design document
192+
- `site/docs/design-integration-guide.md` — REQUIRED when implementing Figma designs

bundles.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"media-api": [
3+
"test_purz_template",
34
"api_bria_image_edit",
45
"api_bria_image_outpainting",
56
"api_bytedace_seedance1_5_image_to_video",

docs/CREATORS.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Creator System — Authorship & Attribution
2+
3+
## Overview
4+
5+
Every workflow template has a **creator** (who built the workflow) and optionally a **model brand** (the AI model it uses). These are independent concepts:
6+
7+
- **Creator** = the person/team who made the workflow (stored as `username`)
8+
- **Model brand** = the AI provider logo shown on thumbnails (stored in `logos[]`)
9+
10+
## Data Model
11+
12+
### `templates/creators.json`
13+
14+
The single source of truth for creator profiles. Keyed by username:
15+
16+
```json
17+
{
18+
"ComfyUI": {
19+
"displayName": "ComfyUI",
20+
"handle": "ComfyUI",
21+
"summary": "Official ComfyUI workflow templates created by the Comfy team.",
22+
"social": "x.com/comaboratory"
23+
},
24+
"hellorob": {
25+
"displayName": "RobTheMan",
26+
"handle": "hellorob",
27+
"summary": "Rob is a core member of the ComfyUI creative team...",
28+
"social": "x.com/hellorob"
29+
}
30+
}
31+
```
32+
33+
Fields:
34+
- `displayName` — Shown on cards, profile pages, spotlights
35+
- `handle` — Used in URLs and @mentions (usually matches the key)
36+
- `summary` — Bio text for profile pages and creator spotlights
37+
- `social` — Social link (without `https://` prefix)
38+
- `avatarUrl` — (optional) URL to avatar image; if absent, an initial-based avatar is generated
39+
- `coverUrl` — (optional) Profile cover image
40+
41+
### `templates/index.json` — The `username` Field
42+
43+
Every template entry has a `username` field linking it to a creator:
44+
45+
```json
46+
{
47+
"name": "flux_text_to_image",
48+
"title": "Flux Text to Image",
49+
"username": "ComfyUI",
50+
"logos": [{ "provider": "Flux" }],
51+
...
52+
}
53+
```
54+
55+
- `username` maps to a key in `creators.json`
56+
- Default is `"ComfyUI"` for official templates (322 of 333 as of Feb 2026)
57+
- Community creators get their own username (e.g. `"hellorob"`, `"PurzBeats"`)
58+
- The `logos[].provider` field is for **model branding only** (thumbnail overlay), NOT authorship
59+
60+
## Data Flow
61+
62+
```
63+
templates/index.json (username field)
64+
65+
├─→ site/scripts/sync-templates.ts
66+
│ Syncs to site/src/content/templates/*.json
67+
│ username is included via TemplateInfo spread
68+
69+
└─→ templates/creators.json (profile data)
70+
71+
├─→ Astro pages resolve displayName at build time
72+
│ index.astro: serializes creatorDisplayName for Vue island
73+
│ [username].astro: generates profile pages from creators.json keys
74+
75+
├─→ Vue components receive creatorDisplayName as prop
76+
│ HubBrowse → WorkflowGrid → HubWorkflowCard
77+
78+
├─→ CreatorsSection.astro: groups templates by username
79+
│ Looks up displayName, handle, bio from creators.json
80+
│ Excludes "ComfyUI" (too many templates to spotlight)
81+
82+
└─→ WorkflowCard.astro: imports creators.json directly
83+
Resolves author from username prop
84+
```
85+
86+
## URL Structure
87+
88+
- `/templates/` — Hub page with all templates (creator shown on each card)
89+
- `/templates/{username}/` — Creator profile page (e.g. `/templates/hellorob/`)
90+
- `/templates/{template-name}/` — Individual template detail page
91+
92+
Profile pages are statically generated from `creators.json` keys via `getStaticPaths()` in `[username].astro`.
93+
94+
## Component Architecture
95+
96+
### Serialization Boundary (Astro → Vue)
97+
98+
Vue islands can't import server-side JSON. The Astro pages pre-resolve the display name:
99+
100+
```
101+
Astro page (index.astro)
102+
→ imports creators.json
103+
→ resolves creatorDisplayName per template
104+
→ passes serialized array to Vue island
105+
106+
Vue island (HubBrowse.vue)
107+
→ receives templates with creatorDisplayName
108+
→ passes through WorkflowGrid → HubWorkflowCard
109+
```
110+
111+
### Card Components
112+
113+
| Component | Type | How it gets author |
114+
|-----------|------|--------------------|
115+
| `HubWorkflowCard.vue` | Vue | `creatorDisplayName` prop (from parent Vue component) |
116+
| `WorkflowCard.astro` | Astro | Imports `creators.json`, resolves from `username` prop |
117+
| `CreatorWorkflowCard.astro` | Astro | Receives `authorName` prop from `CreatorSpotlight` |
118+
119+
All cards show:
120+
- **Author avatar**: Green gradient circle with first initial (consistent across all cards)
121+
- **Author name**: Resolved display name from creators.json
122+
- **Logo overlay on thumbnail**: Model brand logo (separate from author — this is `logos[].provider`)
123+
124+
### CreatorsSection
125+
126+
Groups templates by `username`, excludes `"ComfyUI"`, sorts by total usage. Requires `>= 2` templates to appear. Shows top 3 creators with their top 3 workflows each.
127+
128+
## Adding a New Creator
129+
130+
1. Add entry to `templates/creators.json`:
131+
```json
132+
"newuser": {
133+
"displayName": "New User",
134+
"handle": "newuser",
135+
"summary": "Description of the creator.",
136+
"social": "x.com/newuser"
137+
}
138+
```
139+
140+
2. Set `"username": "newuser"` on their templates in `templates/index.json`
141+
142+
3. Run `pnpm run sync` in `site/` to propagate changes
143+
144+
4. A profile page at `/templates/newuser/` is automatically generated
145+
146+
## Key Files
147+
148+
| File | Purpose |
149+
|------|---------|
150+
| `templates/creators.json` | Creator profile data (source of truth) |
151+
| `templates/index.json` | Template metadata with `username` field |
152+
| `site/scripts/lib/types.ts` | `TemplateInfo.username` type definition |
153+
| `site/src/content/config.ts` | Content collection schema (includes `username`) |
154+
| `site/src/pages/templates/index.astro` | Hub page, serializes `creatorDisplayName` |
155+
| `site/src/pages/templates/[username].astro` | Creator profile page |
156+
| `site/src/components/hub/HubWorkflowCard.vue` | Vue card (receives `creatorDisplayName` prop) |
157+
| `site/src/components/hub/WorkflowCard.astro` | Astro card (imports creators.json directly) |
158+
| `site/src/components/hub/CreatorsSection.astro` | Creator spotlight section |
159+
| `site/src/components/hub/CreatorSpotlight.astro` | Individual creator row |
160+
161+
## Common Mistakes to Avoid
162+
163+
- **Don't use `logos[0].provider` as the author.** That's model branding (e.g. "Grok", "Flux"), not who made the workflow.
164+
- **Don't forget the serialization boundary.** Vue islands can't import JSON — resolve display names in Astro and pass as props.
165+
- **Don't hardcode creator data in components.** Always resolve from `creators.json` via username.
166+
- **Remember to run sync** after changing `index.json` — the content collection won't update automatically.

site/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# build output
22
dist/
3+
.vercel/
34
# generated types
45
.astro/
56

@@ -32,6 +33,7 @@ Thumbs.db
3233
.content-cache/
3334
src/content/templates/
3435
public/thumbnails/
36+
public/templates/thumbnails/
3537
public/workflows/
3638
public/logos/
3739
public/previews/

0 commit comments

Comments
 (0)