Shared Packages Overview
Relevant source files
The following files were used as context for generating this wiki page:
The ever-teams project is a monorepo managed with turbo and lerna, containing multiple applications (web, mobile, extensions, etc.) and a set of shared packages. These packages are located in the packages/ directory and are designed to encapsulate reusable code, promoting consistency, reducing duplication, and improving maintainability across the platform. The shared packages cover UI components, business logic hooks, API services, and common type definitions.
This structure allows different applications within the monorepo, such as @ever-teams/web and @ever-teams/playground, to share a common foundation for UI, logic, and data structures. The build system uses turbo to efficiently build these dependencies.
Sources: package.json:134-143, README.md:195-201
Monorepo Dependency Architecture
The project's architecture is designed around a clear separation of concerns, with applications consuming shared libraries. This promotes code reuse and modularity.
The following diagram illustrates the high-level dependency relationships between the applications and the shared packages.
Build Scripts
The root package.json defines several scripts for building these shared packages individually using turbo. This allows for optimized, partial builds within the monorepo.
| Script | Description |
|---|---|
build:services | Builds the @ever-teams/services package. |
build:types | Builds the @ever-teams/types package. |
build:constants | Builds the @ever-teams/constants package. |
build:ui | Builds the @ever-teams/ui package. |
build:hooks | Builds the @ever-teams/hooks package. |
build:utils | Builds the @ever-teams/utils package. |
Sources: package.json:28-34
Core Shared Packages
The packages/ directory contains several key libraries that form the backbone of the frontend applications.
packages/ui
This package contains "dumb," pure UI primitives that are shared across applications. These are foundational visual elements like buttons, inputs, and cards, which are not tied to specific business logic. This package is distinct from the "smart" components found in apps/web/core/components/, which are stateful and business-aware.
Key Responsibilities:
- Provide a consistent set of reusable, styled UI components.
- Abstract styling and basic component behavior.
- Depend on
@ever-teams/hooksand@ever-teams/utilsfor some internal functionality.
Key Dependencies:
The UI package is built upon a modern stack of UI libraries and tools.
| Dependency | Role |
|---|---|
react / react-dom | Core UI library. |
tailwindcss | Utility-first CSS framework for styling. |
@radix-ui/* | A collection of unstyled, accessible UI primitives. |
lucide-react | Icon library. |
shadcn/ui (implied) | The structure heavily relies on Radix, clsx, tailwind-merge, which are hallmarks of shadcn/ui. |
class-variance-authority | For creating variant-driven component styles. |
tailwind-merge | For intelligently merging Tailwind CSS classes. |
Sources: packages/ui/package.json:49-93, apps/web/core/components/README.md:19-25, 80-84
packages/hooks
This package is intended to house reusable React hooks that contain business logic. These hooks can be used by any application in the monorepo to interact with state, services, and other core functionalities without duplicating code.
An example of the pattern this package follows can be seen in use-github-integration.ts. This hook encapsulates all logic for GitHub integration, including:
- Managing state with Jotai (
integrationGithubMetadataState). - Performing asynchronous operations and caching with TanStack Query (
useQuery,useMutation). - Calling API services (
githubService). - Using shared types (
IOrganizationProjectRepository).
Sources: apps/web/core/hooks/integrations/use-github-integration.ts:1-15, packages/ui/package.json:52
packages/services
The services layer is responsible for all communication with external APIs, primarily the Ever Gauzy backend. It abstracts away the details of HTTP requests, authentication, and data transformation.
Hooks from the @ever-teams/hooks package would typically call functions from this service layer to fetch or mutate data. For example, useGitHubIntegration uses githubService to make API calls related to GitHub integration.
Sources: apps/web/core/hooks/integrations/use-github-integration.ts:6, 28, package.json:28
packages/types
This package centralizes all shared TypeScript types and interfaces for the entire project. By having a single source of truth for data structures, it ensures type safety and consistency between the frontend applications and the data they consume from the API.
For instance, use-github-integration.ts imports several interfaces like IGithubMetadata and IOrganizationProjectRepository from the core types directory, demonstrating how this package is consumed.
Sources: apps/web/core/hooks/integrations/use-github-integration.ts:9-11, package.json:29
Data Flow Example
The following sequence diagram illustrates a typical interaction flow, showing how the different shared packages work together when a user performs an action.
This diagram is a conceptual representation based on the code structure in apps/web/core/hooks/integrations/use-github-integration.ts.
State Management (Jotai)
The project uses Jotai for global state management. State atoms are organized by feature domain (e.g., auth, projects, tasks) within the apps/web/core/stores/ directory.
There is a documented intention to eventually move these stores into a dedicated packages/stores workspace. This would allow state to be shared across different applications (e.g., web, mobile, extensions), further enhancing code reuse.
Store Structure and Naming
The state management follows strict conventions for structure and naming to ensure clarity and scalability.
This diagram shows the domain-based folder structure for Jotai stores.
Sources: apps/web/core/stores/README.md:14-26
Atoms are named with specific suffixes to indicate their purpose:
| Type | Suffix | Example |
|---|---|---|
| Primitive Atom | ...Atom | userAtom |
| Derived Atom | ...Derived | activeProjectDerived |
| Filter/Selector Atom | ...FilterAtom | taskFilterAtom |
Sources: apps/web/core/stores/README.md:32-39