Project Structure
Relevant source files
The following files were used as context for generating this wiki page:
The Ever Gauzy platform is a large-scale monorepo built using a modern technology stack that includes TypeScript, Node.js/NestJS for the backend, and Angular for the frontend. The project's structure is organized and managed using a combination of Nx, Lerna, and Yarn Workspaces to handle the complexities of multiple applications, shared libraries, and plugins. This architecture facilitates code sharing, streamlined builds, and efficient dependency management across the entire platform.
The structure is logically divided into apps for runnable applications and packages for shared libraries and plugins. This separation allows for clear boundaries between deployable units and reusable code modules, which is essential for a platform with features spanning ERP, CRM, and HRM.
Monorepo Management
The project leverages a powerful combination of tools to manage its monorepo architecture. Each tool serves a specific purpose in orchestrating the development, build, and dependency management processes.
Nx Workspace
Nx is the primary tool for managing the monorepo. It provides intelligent build, test, and linting capabilities by understanding the project's dependency graph.
Sources: nx.json
The nx.json file is the central configuration for Nx. It defines how different targets (like build, serve, test) behave across the workspace. The targetDefaults configuration, for example, specifies default executors and options for common tasks.
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"cache": true
},
"lint": {
"cache": true
}
}
Sources: nx.json:11-20
This configuration indicates that a build task depends on the build of its dependencies (^build) and that both build and lint results are cacheable, which significantly speeds up CI/CD pipelines. Nx's affected:dep-graph command can be used to visualize these dependencies.
This diagram illustrates the core concept of the Nx dependency graph, where applications depend on libraries, enabling Nx to intelligently rebuild only what has been affected by a code change.
Sources: package.json:104-105, nx.json
Lerna
Lerna is used in conjunction with Nx, primarily for managing package versioning and publishing. The lerna.json file configures Lerna's behavior.
{
"packages": ["packages/*", "packages/plugins/*"],
"version": "0.1.0",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"publish": {
"conventionalCommits": true
}
}
}
Sources: lerna.json:2-11
This configuration tells Lerna where to find the packages, sets the current version, specifies yarn as the client, and enables the use of Yarn workspaces.
Yarn Workspaces
Yarn Workspaces is used for dependency management within the monorepo. It hoists dependencies to the root node_modules directory, reducing duplication and ensuring consistent versions across all packages. The workspace packages are defined in the root package.json.
"workspaces": {
"packages": [
"apps/*",
"tools",
"packages/*",
"packages/plugins/*"
],
"nohoist": [
"**/@types/jasmine",
"**/@types/jasminewd2",
"**/@angular*/**",
"**/@ngtools/**"
]
}
Sources: package.json:521-535
Workspace Layout
The repository is organized into several key directories, each with a distinct purpose. This structure separates applications from reusable libraries and tooling.
The following diagram shows the high-level directory structure of the Gauzy monorepo.
Sources: package.json:521-526, README.md:200-202
| Directory | Description |
|---|---|
apps/ | Contains runnable applications, such as the main API server, the web frontend, desktop apps, and end-to-end tests. |
packages/ | Contains shared libraries, core logic, UI components, and the plugin ecosystem. These are not standalone applications but are consumed by the projects in the apps/ directory. |
tools/ | Contains utility scripts and configurations for managing the workspace, such as post-install scripts. |
Sources: package.json:523-525
Applications (apps/)
The apps directory contains the deployable units of the Gauzy platform.
| Application | Description | Technology | Configuration |
|---|---|---|---|
api | The main backend server built with NestJS. It exposes the REST and GraphQL APIs for the platform. | NestJS | apps/api/project.json |
gauzy | The primary Angular-based web frontend application. | Angular | angular.json |
desktop | An Electron-based desktop application that bundles the frontend and backend. | Electron, Angular | package.json |
desktop-timer | A lightweight Electron app for time and activity tracking. | Electron, Angular | package.json |
server | A standalone server application that includes the API and serves the frontend. | Electron, NestJS | package.json |
server-mcp | An Electron desktop application for managing the MCP (Model Context Protocol) server. | Electron, Angular | packages/mcp-server/README.md:16-19 |
gauzy-e2e | End-to-end tests for the platform, written using Cypress. | Cypress | apps/gauzy-e2e/ |
The configuration for each application is defined in its project.json (for Nx projects) or angular.json (for Angular projects). For example, apps/api/project.json defines multiple build targets for the API, allowing it to be bundled for different environments like production, desktop, and a standalone server.
Sources: apps/api/project.json:1-179, README.md:144-169
Packages & Plugins (packages/)
The packages directory is the heart of Gauzy's shared code and extensibility.
Core Libraries
This includes foundational libraries that are used across multiple applications:
@gauzy/core: Core backend functionalities, services, and entities.@gauzy/ui-core: Core frontend components, services, and styles.@gauzy/contracts: Shared data structures, enums, and interfaces (DTOs) used for communication between the frontend and backend.@gauzy/config: Environment and application configuration management.@gauzy/mcp-server: A shared package providing the core MCP (Model Context Protocol) server implementation for AI assistant integration.
Sources: package.json:300-360, packages/mcp-server/README.md:3-5
Plugin Architecture
Gauzy features a robust plugin system, with plugins located in packages/plugins/. Each plugin is its own package and can extend both backend and frontend functionality.
- Backend Plugins: Reside in a directory like
packages/plugins/knowledge-base/and are typically NestJS modules. They add new entities, services, and API endpoints. - UI Plugins: Reside in a directory like
packages/plugins/job-proposal-ui/and are Angular libraries that provide new pages, components, and routes to the frontend.
Example of a backend plugin's dependencies:
"dependencies": {
"@gauzy/contracts": "^0.1.0",
"@gauzy/core": "^0.1.0",
"@gauzy/plugin": "^0.1.0",
"@nestjs/common": "^11.1.0",
"typeorm": "^0.3.27"
}
Sources: packages/plugins/knowledge-base/package.json:16-30
This structure allows for modular development, where new features can be built and integrated as self-contained plugins.
Build and Tooling
The root package.json contains a comprehensive set of scripts for managing the workspace.
Key Scripts
| Script | Description |
|---|---|
yarn bootstrap | Installs all dependencies for the monorepo using Yarn Workspaces. |
yarn start | Concurrently starts the api and gauzy applications for local development. |
yarn build | Builds both the api and gauzy applications. |
yarn build:package:all | Builds all packages and libraries in the correct dependency order. |
yarn test | Runs tests for all affected projects. |
yarn lint | Lints all affected projects. |
yarn build:desktop | Builds the full Electron-based desktop application. |
yarn seed | Seeds the database with initial data for development. |
Sources: package.json:28-200
Build Process
The build process is orchestrated by Nx and Yarn scripts. A typical build flow involves:
- Installing Dependencies:
yarn bootstrapinstalls all necessary packages. - Building Packages:
yarn build:package:allcompiles all shared libraries and plugins inpackages/. Nx ensures this happens in the correct order based on the dependency graph. - Building Applications:
yarn build(or more specific targets likeyarn build:api:prod) compiles the main applications fromapps/, which consume the previously built packages.
This flow is visualized below.
Sources: package.json:191, package.json:43-44
Conclusion
The Ever Gauzy project is structured as a sophisticated monorepo that effectively leverages Nx, Lerna, and Yarn Workspaces. This architecture promotes code reuse through a rich ecosystem of shared packages and plugins, while maintaining a clear separation between deployable applications. The use of intelligent build tools like Nx allows for efficient development and CI/CD workflows, which is critical for managing a project of this scale and complexity. The clear division between apps and packages provides a scalable foundation for future growth and feature development.