This document describes the refactored, organized structure of the WebUI.
The WebUI follows a feature-based architecture with clear separation of concerns:
webui/
├── app/ # Next.js App Router (pages and layouts)
│ ├── (auth)/ # Auth-protected routes
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/ # React components
│ ├── features/ # Feature-specific components
│ │ ├── image-generation/
│ │ ├── models/
│ │ ├── queue/
│ │ └── index.ts
│ ├── forms/ # Form components
│ ├── layout/ # Layout and navigation
│ ├── ui/ # Reusable UI primitives
│ └── index.ts # Component barrel exports
├── lib/ # Core utilities and services
│ ├── hooks/ # Custom React hooks
│ ├── services/ # API and external services
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Utility functions
│ └── index.ts # Library barrel exports
├── public/ # Static assets
└── contexts/ # React context providers
Feature components are organized by domain:
features/image-generation/ - Components for image generation UIfeatures/models/ - Model management componentsfeatures/queue/ - Job queue and monitoring componentsReusable form components:
forms/prompt-textarea.tsx - Enhanced text input for promptsLayout and navigation components:
layout/app-layout.tsx - Main application layoutlayout/header.tsx - Application headerlayout/sidebar.tsx - Navigation sidebarlayout/theme-provider.tsx - Theme context providerLow-level reusable UI components (shadcn/ui style):
ui/button.tsx - Button componentui/card.tsx - Card containerui/input.tsx - Input fieldui/select.tsx - Select dropdownCustom React hooks for common functionality:
// hooks/hooks.ts
export function useLocalStorage<T>(key: string, initialValue: T)
export function useAutoSave<T>(key: string, value: T, delay?: number)
External API and business logic services:
// services/
export { apiClient } from '../api'
export { AutoModelSelector } from '../auto-model-selector'
TypeScript type definitions and interfaces:
// types/
export interface GenerationParams { ... }
export interface ModelDetails { ... }
// Good: Feature-specific imports
import { ModelStatusBar, EnhancedModelSelect } from '@/components/features';
// Good: Layout imports
import { AppLayout, Header } from '@/components/layout';
// Good: UI imports
import { Button, Card } from '@/components/ui';
// Good: Barrel imports
import { useLocalStorage, apiClient } from '@/lib';
@/ - Root of the webui directory@/components/* - All component imports@/lib/* - All library imports@/app/* - App router pagesWhen adding new components:
components/ui/components/features/{domain}/components/forms/components/layout/lib/hooks/lib/services/lib/types/lib/utils/Always export from index files:
// components/features/models/index.ts
export { ModelList } from './model-list';
export { ModelStatusBar } from './model-status-bar';
Organize by feature, not by file type. All related code for a feature should be together.
Use index.ts files to provide clean import paths and hide implementation details.
use prefixKeep related files together:
This structure provides a solid foundation for scaling the WebUI application while maintaining code quality and developer productivity.