Comfy-Org / Comfy-Org/ComfyUI_frontend

[RFC] Enforce layered architecture across all src/ directories — 60% of codebase is unenforced

Open
#11,091 1 comment 0 reactions 0 assignees View on GitHub
developer experience refactor
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Problem

The layer hierarchy (`base → platform → workbench → renderer`) only governs files within those 4 directories. However, 11 top-level `src/` directories sit entirely outside the hierarchy:

- `src/components/` (37 subdirs)
- `src/composables/` (45 root files + subdirs)
- `src/stores/` (41 stores)
- `src/services/` (20+ files)
- `src/utils/` (45 files)
- `src/types/` (21 files)
- `src/schemas/` (6 files)
- `src/scripts/` (legacy)
- `src/extensions/` (core extensions)
- `src/constants/`
- `src/config/`

Approximately 60% of the codebase (336+ files) bypasses the layer enforcement entirely, creating implicit circular dependencies between these directories and the layered code.

## Proposed Fix

1. Define which layer each top-level directory belongs to (e.g., `stores/` = platform, `components/` = workbench, `renderer/` = renderer)
2. Add ESLint `import-x/no-restricted-paths` rules for ALL directories, not just the 4 layered ones
3. Incrementally move files from top-level directories into their layer (related to Issues #11017, #11019, #11064, #11062)

## Migration Plan

1. First: document which layer each directory maps to
2. Second: add ESLint rules in warning mode
3. Third: fix violations and promote to error mode
4. Long-term: migrate files into layer directories (per other RFCs)

## Testing Strategy

- ESLint CI catches future violations
- `pnpm typecheck` passes throughout

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11091-RFC-Enforce-layered-architecture-across-all-src-directories-60-of-codebase-is-u-33e6d73d36508199ace2cfa0c45e9af7) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.