Developer guide for VEIL.
This guide covers local setup, project structure, extension points, API contract rules, and testing.
- Requirements
- Setup
- Project Structure
- Running Locally
- Adding an API Endpoint
- Adding a JavaScript Module
- Adding a CSS Component
- Code Style
- Testing
| Dependency | Version | Purpose |
|---|---|---|
| Python | 3.10+ | Backend runtime |
| Poetry | 1.7+ | Dependency management |
| Browser | Current Chrome/Firefox/Edge | Local UI |
# Clone the repository
git clone https://github.com/Lotargo/ComfyUI-Meta-Viewer.git
cd ComfyUI-Meta-Viewer
# Install dependencies
poetry install --no-root
# Run the application
poetry run python -m app.mainComfyUI-Meta-Viewer/
├── app/ # Python backend + frontend static assets
│ ├── __init__.py
│ ├── main.py # Core Flask routes and startup wiring
│ ├── database.py # SQLite operations
│ ├── library.py # Albums, favorites, tags, filters
│ ├── extractor.py # Metadata parsing
│ ├── cutout.py # Background removal
│ ├── schemas.py # Pydantic models
│ ├── source_monitor.py # Watchers, debounce, reconnect, reconciliation
│ ├── ai/ # AI prompt compiler, provider adapters, durable jobs
│ │ └── routes.py # Public AI REST routes
│ ├── comfyui/ # ComfyUI runtime, Create and shared execution
│ │ ├── routes.py # Public ComfyUI runtime routes
│ │ └── simple_routes.py # Public Create routes
│ ├── integrations/social/ # Social status/auth/publishing contract
│ ├── static/
│ │ ├── css/ # Modular CSS
│ │ └── js/ # ES modules
│ └── templates/ # Jinja2 HTML templates
├── cache/ # Generated thumbnails, previews, and cutouts
├── dev_docs/ # Internal specifications and sprint roadmaps
├── docs/ # Technical documentation
├── site/ # Public landing page and Scalar API portal
│ └── api/openapi.json # Machine-readable public OpenAPI 3.1 contract
├── tests/
│ └── test_openapi_contract.py # Public Flask route/OpenAPI drift gate
├── pyproject.toml # Poetry project configuration
├── benchmark.bat # Windows benchmark launcher
├── benchmark.sh # Linux/macOS benchmark launcher
├── start.bat # Windows launcher
└── start.sh # Linux/macOS launcher
# Default development launch
poetry run python -m app.main
# Custom port
MEDIASTUDIO_PORT=8080 poetry run python -m app.main
# Do not auto-open the browser
poetry run python -m app.main --no-browser
# Exercise physical index recreation without starting Flask
poetry run python -m app.main --reset-indexDefault URL: http://localhost:7860.
VEIL treats site/api/openapi.json as the public machine-readable API contract. The detailed human reference lives in docs/core/api.md. Supported public routes and OpenAPI are checked for drift by tests/test_openapi_contract.py on every normal pytest/CI run.
The supported public route modules are:
app/main.py- core media, folders, library, uploads, cutouts, diagnostics, and reset routes;app/ai/routes.py- AI providers, prompt operations, jobs, resources, and ratings;app/comfyui/routes.py- ComfyUI runtime lifecycle and configuration;app/comfyui/simple_routes.py- Simple Mode model setup, generation, and run tracking;app/integrations/social/routes.py- social capability/authentication/publishing contract.
The pre-Simple-Mode workflow editor and its /api/editor/* routes were removed on 2026-10-14. Shared inventory, SQLite drafts/runs, output import, and error normalization remain because Create uses them.
Choose the module that owns the capability instead of putting every endpoint into app/main.py.
@simple_blueprint.route("/api/simple/my-endpoint", methods=["POST"])
def my_endpoint():
data = request.get_json(silent=True) or {}
return jsonify({"result": "ok", "input": data})Keep route handlers small and move reusable behavior into services/modules.
Use Pydantic models for structured payloads or contracts with non-trivial validation.
class MyRequest(BaseModel):
field: str
class MyResponse(BaseModel):
result: strEvery new supported non-legacy /api/* method must be added to site/api/openapi.json with:
- the exact normalized path (
<int:id>in Flask becomes{id}in OpenAPI); - the HTTP method;
- a useful
summary; - at least one tag;
- a unique
operationId; - all path parameters declared with
in: pathandrequired: true; - request and important response schemas where they materially help API consumers.
The Scalar portal at site/api/index.html reads this file directly.
Document behavior, edge cases, important response codes, and examples in docs/core/api.md.
Keep the distinction clear:
site/api/openapi.json- supported public machine contract;docs/core/api.md- detailed human reference and implementation notes;/api/editor/*- removed; add new Create capabilities to/api/simple/*.
If the browser UI calls the new endpoint, add or update the appropriate wrapper in app/static/js/api.js or the owning frontend module.
export async function myEndpoint(data) {
const res = await fetch("/api/simple/my-endpoint", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
});
if (!res.ok) return null;
return res.json();
}An endpoint used only by external/local integrations does not need a frontend wrapper merely to satisfy the API contract.
// app/static/js/features/my-feature.js
import { state } from "../state.js";
export function initMyFeature() {
// Setup
}
export function destroyMyFeature() {
// Cleanup
}import { initMyFeature } from "./features/my-feature.js";
// During app initialization:
initMyFeature();The current frontend is plain ES modules. If TypeScript declarations are added later, keep them close to the module they describe or document the convention in this file.
- UI components ->
app/static/css/components/ - Feature-specific styles ->
app/static/css/features/ - Layout styles ->
app/static/css/layout/ - Base styles ->
app/static/css/base/
/* app/static/css/components/my-component.css */
.my-component {
background: var(--color-bg);
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
padding: var(--spacing-md);
}Add the file to app/templates/index.html or to the appropriate CSS import path used by the current layout.
The product has two kinds of names, kept apart on purpose:
- Brand (
VEIL): what users see: window title, header wordmark, installer, README, docs. It is defined inbrand.jsonand can be changed at any time. - Codename (
mediastudio): what the code uses internally:MEDIASTUDIO_*environment variables,mediastudio_*browser-storage keys, themediastudio://protocol,%APPDATA%\MediaStudio,.mediastudio_data, the app idorg.lotargo.mediastudio. It never changes with the brand, so a rename can not orphan user data.
Rename the product with one command (commit your work first; --dry-run lists the files without writing):
python scripts/rebrand.py LACE --subtitle "New subtitle" --tagline "New tagline."
python scripts/rebrand.py LACE --replace ComfyUI-Meta-Viewer=lace # also rename the GitHub repo in linksIt rewrites the name (and the lowercase slug in package.json, pyproject.toml and the docs), updates
brand.json, and regenerates the text README banner (--no-assets skips that). The logo artwork lives in
desktop/assets/logo.svg (on its dark stage) and logo-mark.svg (transparent); the desktop splash inlines the
mark, the web header uses its copy app/static/brand/logo-mark.svg (a test keeps the two identical), and node scripts/render_icon.mjs renders icon.png/icon.ico from the logo after the artwork changes. History
(CHANGELOG.md) and LLM prompt text under app/ai/prompting/content/ are never rewritten.
New code and docs must not introduce the old product names (CMV, COMFY_META_*, Comfy Meta Viewer); use the
codename for identifiers and the brand for user-facing text.
- Use type hints for public functions and core helpers.
- Use Pydantic models for request/response validation where helpful.
- Keep route handlers small and move reusable logic into modules.
- Prefer clear error responses with useful HTTP status codes.
- Target a readable line length of roughly 100 characters.
- Use ES modules (
import/export). - Keep the frontend framework-free unless the project direction changes.
- Use
camelCasefor variables/functions andPascalCasefor classes. - Keep DOM querying and event binding localized to feature modules.
- Use modular files grouped by responsibility.
- Prefer CSS custom properties for repeated values.
- Keep selectors predictable and BEM-like when possible.
- Avoid
!importantunless there is a strong reason.
poetry run python -m pytest tests -q
npm run test:preferences
npm run lintThe Python suite covers Flask/database/image-processing behavior and the public API contract. tests/test_openapi_contract.py statically reads route decorators from the supported public route modules and compares their normalized method/path pairs with site/api/openapi.json. It also checks Scalar navigation metadata, unique operation IDs, exact path-parameter declarations, and malformed component references.
This makes API drift a CI failure: a new supported Flask route cannot silently appear without its OpenAPI entry, and a removed/renamed route cannot remain advertised in the public contract.
The Node test suite uses the built-in test runner for the versioned preference schema and state-persistence boundary. ESLint checks all frontend modules.
GitHub Actions runs the same checks on Windows, Ubuntu, and macOS. The path suite also verifies stable service directories, native directory scanning and watcher events, burst coalescing, reconnect behavior, Unicode and spaces, Windows/POSIX upload filenames, and that scanning does not write into a source folder.
- Start the server.
- Open
http://localhost:7860. - Verify the main flows:
- Folder scan.
- Drag-and-drop upload.
- Metadata summary rendering.
- Workflow graph rendering.
- Thumbnail loading.
- Original image loading.
- Cutout generation/deletion.
- Fuzzy search.
- Keyboard shortcuts.
- Reset flow.
- Responsive layout.
- Open the Scalar API portal and spot-check any endpoint changed in the same patch.