Backend API Overview
Relevant source files
The following files were used as context for generating this wiki page:
The Ever® Gauzy™ Backend API is the central nervous system of the platform, providing a comprehensive, headless interface for all business management functionalities. Built on a modern technology stack, it serves as the data and logic layer for various clients, including the main web application (@gauzy/gauzy), desktop applications, and external integrations. Its modular, plugin-based architecture allows for high extensibility, enabling developers to add or modify features without altering the core system.
The API is designed as a robust backend for ERP, CRM, and HRM functionalities, offering a wide range of features from time tracking and project management to invoicing and sales pipelines. It is managed within an Nx monorepo, which facilitates a structured development, build, and deployment process. The API exposes its endpoints via REST and is documented using Swagger and Scalar for clear and interactive developer access.
Sources: README.md, apps/gauzy/README.md, apps/api/project.json
Architecture and Technology Stack
The backend is built with TypeScript and leverages the NestJS framework, providing a scalable and maintainable structure. It uses TypeORM for database interaction, allowing support for multiple database systems like PostgreSQL, MySQL, and SQLite. The architecture is designed to be database-agnostic with minimal changes.
Sources: README.md
This diagram illustrates the key technologies that form the foundation of the Gauzy Backend API.
Sources: README.md
The main components of the technology stack are summarized below:
| Component | Description |
|---|---|
| TypeScript | The primary programming language, providing static typing for robust code. |
| Node.js | The JavaScript runtime environment for executing the server-side code. |
| NestJS | A progressive Node.js framework for building efficient and scalable server-side applications. |
| TypeORM / MikroORM | Object-Relational Mappers (ORMs) for database interaction, supporting multiple database systems. |
| PostgreSQL | The recommended database for production environments. |
| Nx | A smart, extensible build framework for managing the monorepo. |
| Docker / Kubernetes | Recommended technologies for containerization and orchestration in production. |
| Redis | Used for in-memory caching to improve performance. |
| OpenSearch | Powers the search functionality within the platform. |
Sources: README.md, packages/common/package.json
Project Structure and Build Process
The API is defined as an application named api within the Nx workspace. Its configuration is located in apps/api/project.json. This file defines various targets for building, serving, and testing the application.
The build process uses @nx/webpack:webpack to compile the TypeScript source code into a single distributable bundle. The configuration supports different environments, such as development and production, with specific optimizations for each.
Sources: apps/api/project.json
Build Targets
The project.json file specifies several build targets, allowing the API to be packaged for different deployment scenarios, such as a standard web server, a desktop application backend, or a standalone server.
| Target | Output Path | Description |
|---|---|---|
build | dist/apps/api | Standard production build for the API. |
desktop-api | dist/apps/desktop/api | A build variant packaged for the Gauzy Desktop App. |
server-api | dist/apps/gauzy-api-server/api | A build variant for an older server packaging format. |
gauzy-server-api | dist/apps/gauzy-server/api | A build variant for the Gauzy Server application. |
Sources: apps/api/project.json:10-178
The following diagram shows the flow of the build process for the main API target.
Sources: apps/api/project.json:17-54
Modular and Plugin-Based System
The API's functionality is organized into modules, with a central @gauzy/core package providing the foundational components. The system is extended through a rich ecosystem of plugins, which are separate packages that can be dynamically loaded. This design promotes separation of concerns and makes the platform highly customizable.
Plugins are included as dependencies in the apps/api/package.json file. Each plugin typically encapsulates a specific feature, such as an integration with a third-party service or a distinct business domain.
Sources: apps/api/package.json:30-51
This diagram illustrates the relationship between the core application and its plugins.
Sources: apps/api/package.json:30-51
Key Plugins
The following table lists some of the key plugins that extend the API's capabilities:
| Plugin Package | Description |
|---|---|
@gauzy/plugin-integration-github | Integrates with GitHub APIs for repository and issue tracking. |
@gauzy/plugin-integration-upwork | Integrates with Upwork for freelance management. |
@gauzy/plugin-integration-ai | Provides AI capabilities and integrations. |
@gauzy/plugin-job-proposal | Manages job proposals and the recruitment pipeline. |
@gauzy/plugin-knowledge-base | Adds a knowledge base or help center feature. |
@gauzy/plugin-changelog | Manages changelogs for different versions. |
@gauzy/plugin-integration-zapier | Allows connecting Gauzy with thousands of other apps via Zapier. |
Sources: apps/api/package.json, packages/plugins/integration-github/package.json, packages/plugins/job-proposal/package.json, packages/plugins/knowledge-base/package.json, packages/plugins/integration-upwork/package.json, packages/plugins/integration-ai/package.json, packages/plugins/changelog/package.json, packages/plugins/integration-zapier/package.json
API Documentation
The API includes built-in documentation powered by Swagger and Scalar. This is configured in the @gauzy/core package and initialized during the application bootstrap process. The documentation is available at the /swg (Swagger UI) and /docs (Scalar UI) endpoints by default.
The setup function setupSwagger configures the API title, description, version, and security definitions. It supports multiple authentication schemes to ensure developers can test protected endpoints directly from the documentation interface.
Sources: packages/core/src/lib/bootstrap/swagger.ts
Supported Authentication Schemes
| Scheme | Type | in | Description |
|---|---|---|---|
| Bearer Auth | http | header | For JWT-based authentication. |
| API Key | apiKey | header | For authenticating with a static API key (X-API-Key). |
| OAuth2 | oauth2 | N/A | Supports the authorization code flow. |
Sources: packages/core/src/lib/bootstrap/swagger.ts:88-121
Documentation Endpoints
The documentation provides an interactive way to explore the API. The following sequence diagram shows how a developer might use the Scalar UI to make an API call.
Model Context Protocol (MCP) Server
The Gauzy API also serves as the backend for the Model Context Protocol (MCP) Server. The @gauzy/mcp-server package provides a toolset for AI assistants (like Claude, ChatGPT) to interact with Gauzy's functionalities through a structured protocol. This server consumes the main Gauzy API to perform actions such as managing tasks, tracking time, and fetching employee data, demonstrating the headless capability and versatility of the API.
Sources: packages/mcp-server/README.md
Conclusion
The Gauzy Backend API is a powerful, flexible, and well-structured system that forms the core of the Ever Gauzy platform. Its reliance on modern technologies like NestJS and TypeScript, combined with a modular plugin architecture, ensures it is both scalable for enterprise use and adaptable for future feature development. The comprehensive, auto-generated API documentation further enhances its usability, making it accessible to developers building client applications or third-party integrations.