Modules & Components
In this document we outline the best practices for organizing modules and components across the codebase. Clear separation of concerns between modules (which encompass business logic and domain-specific functionality) and components (reusable UI elements and building blocks) promotes clarity, scalability, and maintainability.
Introduction
Our codebase follows a modular architecture with two primary organizational units:
- UI Components: Reusable components in the
modules/ui/components
directory - Feature Modules: Domain-specific functionality organized by feature in the
modules
directory
Module Organization
Core Module Structure
Modules are organized by feature and can be found in the modules
directory. Each module typically includes:
Enterprise Edition (EE) Modules
Enterprise features are organized in a dedicated modules/ee
directory:
Component Organization
UI Component Structure
UI components are centralized in modules/ui/components
and follow a consistent structure:
Component Types
-
Base Components: Fundamental UI elements like Button, Input, Modal
-
Composite Components: More complex components that combine base components
-
Feature-Specific Components: Components tied to specific features
Feature Module Example
A feature module with its components and business logic:
Best Practices
-
Component Organization
- Keep components focused and single-purpose
- Use proper TypeScript interfaces for props
- Implement Storybook stories for UI components
-
Module Structure
- Organize by feature domain
- Separate business logic from UI components
- Use proper type definitions
-
Code Sharing
- Share common utilities through the ui/lib directory
- Maintain clear boundaries between modules
- Use proper imports with aliases (@/modules/…)
Was this page helpful?