-
Duplicate Components:
- ✅ Removed standalone
TaskNode.tsx
file - ✅ Removed standalone
WorkflowViewer.tsx
file - ✅ Updated imports to use the directory versions
- ✅ Removed standalone
-
Inconsistent Directory Structure:
- ✅ Moved all components into dedicated directories
- ✅ Organized
TestWorkflow.tsx
into its own directory - ✅ Moved loose files in WorkflowViewer to appropriate subdirectories
-
Path Alias Confusion:
- ✅ Removed duplicate
@/
directory at the root level - ✅ Updated imports to use the correct path alias from
src/
- ✅ Removed duplicate
-
Lack of Consistent Documentation:
- ✅ Added README.md files to key component directories:
src/components/WorkflowViewer/README.md
src/components/TaskNode/README.md
src/components/ui/README.md
- ✅ Enhanced JSDoc comments in components
- ✅ Added README.md files to key component directories:
-
Nested Project:
- The Next.js project (
workflow-visualizer
) still exists within the main Vite project - Decision needed: Should we fully integrate it or maintain as separate project?
- The Next.js project (
-
Potential Hard-Coding Issues:
- Some values that should be configurable might be hard-coded
- Lack of centralized configuration for shared values
The plan is organized into several phases to systematically address these issues:
The first step is to clearly separate the Next.js project from the main Vite project:
- Move the Next.js project out of the main project directory:
- The
workflow-visualizer
directory should be moved to a separate location (e.g.,../workflow-visualizer
) - This will prevent confusion between the two projects
- Update any references or documentation accordingly
- Create a clear README in both projects explaining their relationship and purpose
- The
Before restructuring components, establish clear standards for the entire project:
-
Naming Conventions:
- Components: PascalCase (e.g.,
TaskNode.tsx
) - Hooks: camelCase with 'use' prefix (e.g.,
useTaskNode.ts
) - Utilities: camelCase (e.g.,
formatUtils.ts
) - Constants: UPPER_SNAKE_CASE for values, PascalCase for objects
- Types/Interfaces: PascalCase with descriptive names (e.g.,
TaskNodeProps
, not justProps
)
- Components: PascalCase (e.g.,
-
Documentation Standards:
- Every component must have a JSDoc comment explaining its purpose and usage
- All props/interfaces must be documented with descriptions
- Complex functions must include parameter and return value documentation
- Add examples where appropriate for complex components
-
Code Organization:
- Group related functionality in dedicated directories
- Use index files for clean exports
- Separate business logic from UI components where possible
-
Global Configuration:
- Move all configurable values to dedicated configuration files
- Create a centralized theme configuration
- Establish constants files for shared values
Create a consistent structure for all components:
-
Component Organization Pattern:
- All components will be organized in dedicated directories
- Each component gets its own directory under
src/components/
- Related files (styles, hooks, types, sub-components) go in the component's directory
- Each component directory has an
index.ts
file that exports the main component - Complex components may have a
components/
subdirectory for child components
-
Component Directory Structure:
src/components/ComponentName/ ├── index.ts # Clean exports ├── ComponentName.tsx # Main component ├── ComponentName.css # Styles (if not using CSS-in-JS) ├── useComponentName.ts # Custom hooks ├── types.ts # TypeScript interfaces/types ├── constants.ts # Component-specific constants └── components/ # Sub-components (if needed) ├── SubComponent.tsx └── ...
-
UI Components:
- Consolidate all UI components in
src/components/ui
- Remove any duplicate UI component directories
- Ensure all UI components follow the same pattern
- Create a comprehensive UI component documentation
- Consolidate all UI components in
-
TaskNode Component:
- Compare the standalone
TaskNode.tsx
with the directory version - Keep the more complete/updated version (likely the directory version)
- Remove the standalone version
- Update all imports to reference the correct version
- Ensure comprehensive documentation is added
- Extract any hard-coded values to constants
- Compare the standalone
-
WorkflowViewer Component:
- Compare the standalone
WorkflowViewer.tsx
with the directory version - Keep the more complete/updated version
- Remove the standalone version
- Update all imports to reference the correct version
- Ensure comprehensive documentation is added
- Extract any hard-coded values to constants
- Compare the standalone
-
Import Style:
- Use path aliases (
@/
) consistently for all imports from thesrc
directory - Use relative imports only for files within the same component directory
- Group imports logically (React, third-party, internal)
- Use path aliases (
-
Update Imports:
- Scan all files and update imports to follow the chosen pattern
- Ensure all components use the same import style
- Remove any unused imports
-
Organize Utility Files:
- Move all utility functions to
src/lib
- Group related utilities into dedicated files with clear naming
- Add comprehensive documentation for each utility function
- Write unit tests for critical utility functions
- Example structure:
src/lib/ ├── formatUtils.ts # String/data formatting utilities ├── fileUtils.ts # File handling utilities ├── apiUtils.ts # API-related utilities └── ...
- Move all utility functions to
-
Organize Types:
- Consolidate all shared type definitions in
src/types
- Component-specific types should remain in their component directories
- Create a clear hierarchy of types (base types, extended types)
- Document all types thoroughly
- Consolidate all shared type definitions in
-
Create Global Constants:
- Move all hard-coded values to a constants directory
- Organize constants by domain/purpose
- Example structure:
src/constants/ ├── theme.ts # Theme-related constants ├── api.ts # API-related constants ├── workflow.ts # Workflow-specific constants └── ...
-
Component Documentation:
- Add comprehensive JSDoc comments to all components
- Document props, state, and effects
- Include usage examples for complex components
-
Project Documentation:
- Update README.md with clear project structure information
- Add a CONTRIBUTING.md with coding standards and conventions
- Create a directory structure visualization
-
Code Comments:
- Add meaningful comments for complex logic
- Document any non-obvious decisions or workarounds
- Remove any outdated or misleading comments
- Create a backup of the entire project
- Move the
workflow-visualizer
directory to a parent directory:mv workflow-visualizer ../
- Create clear README files in both projects explaining their relationship and purpose
- Create a coding standards document in the project root:
touch CONTRIBUTING.md
- Document naming conventions, code organization, and documentation standards
- Set up linting rules to enforce these standards where possible
-
For each standalone component file in
src/components/
:- Create a new directory with the component name
- Move the component file into the directory and rename to match the directory
- Create an
index.ts
file that exports the component - Add proper documentation
- Extract any hard-coded values to constants
-
For UI components:
- Ensure all UI components are in
src/components/ui
- Create an
index.ts
file in the UI directory that exports all components - Add comprehensive documentation for each UI component
- Ensure all UI components are in
-
TaskNode Component:
- Compare
src/components/TaskNode.tsx
withsrc/components/TaskNode/TaskNode.tsx
- If the directory version is more complete:
- Update any imports in other files to use the directory version
- Remove the standalone file
- If the standalone version is more complete:
- Move its functionality to the directory version
- Update any imports to use the directory version
- Remove the standalone file
- Add comprehensive documentation
- Extract any hard-coded values to constants
- Compare
-
WorkflowViewer Component:
- Compare
src/components/WorkflowViewer.tsx
withsrc/components/WorkflowViewer/WorkflowViewer.tsx
- Follow the same process as with TaskNode
- Add comprehensive documentation
- Extract any hard-coded values to constants
- Compare
-
Update all imports to use path aliases consistently:
- Replace relative imports like
../lib/utils
with@/lib/utils
- Keep relative imports only for files within the same component directory
- Group imports logically (React, third-party, internal)
- Replace relative imports like
-
Update the
tsconfig.app.json
to ensure path aliases are correctly configured:"paths": { "@/*": ["src/*"] }
-
Organize utility files:
- Create a structured directory for utilities in
src/lib
- Group related utilities into dedicated files with clear naming
- Add comprehensive documentation for each utility function
- Extract any hard-coded values to constants
- Create a structured directory for utilities in
-
Organize types:
- Create a structured directory for shared types in
src/types
- Document all types thoroughly
- Ensure consistent naming conventions
- Create a structured directory for shared types in
-
Create global constants:
- Create a structured directory for constants in
src/constants
- Extract hard-coded values from components and utilities
- Group constants by domain/purpose
- Create a structured directory for constants in
-
Update the README.md with:
- Project overview
- Directory structure
- Setup instructions
- Development workflow
-
Add inline documentation to all components and functions
After each phase:
- Run the application to ensure it still works
- Fix any import errors or other issues that arise
- Run the linter to catch any missed issues
- Document any changes made
- Write or update tests for modified components
- Update the README.md with the new project structure
- Run a final test of the application
- Commit the changes with a clear message about the restructuring
- Create a pull request with detailed documentation of the changes
Before finalizing each component or utility:
-
Documentation:
- JSDoc comments for components and functions
- Props/parameters documented
- Return values documented
- Usage examples for complex components
-
Code Organization:
- Logical grouping of related functionality
- Separation of concerns (UI vs. logic)
- Consistent file structure
-
Naming:
- Clear, descriptive names
- Consistent naming conventions
- No ambiguous abbreviations
-
Configuration:
- No hard-coded values
- Constants extracted to appropriate files
- Theme values used consistently
-
Imports:
- Consistent import style
- No unused imports
- Logical grouping of imports