Backend Architecture
The Ever Gauzy backend is built on NestJS, a progressive Node.js framework for building efficient, scalable server-side applications using TypeScript.
NestJS Foundation
NestJS provides the architectural backbone with:
- Dependency Injection (DI) — module-based inversion of control container
- Decorators — declarative metadata for routes, guards, pipes, and more
- Middleware Pipeline — composable request/response processing
- Platform Agnostic — runs on Express or Fastify (Gauzy uses Express)
Module Organization
The backend is organized into well-defined NestJS modules within packages/core/src/lib/:
Core Modules
packages/core/src/lib/
├── auth/ # Authentication (login, register, social OAuth)
├── user/ # User management
├── tenant/ # Tenant management and onboarding
├── role/ # Role definitions (SUPER_ADMIN, ADMIN, EMPLOYEE, etc.)
├── role-permission/ # Role-permission mappings
├── organization/ # Organization CRUD and settings
├── employee/ # Employee profiles, statistics, awards
├── shared/ # Shared utilities, validators, base entities
├── core/ # Core module registration
└── bootstrap/ # Application bootstrapping
Feature Modules
packages/core/src/lib/
├── time-tracking/ # Time logs, timesheets, activity tracking, screenshots
├── tasks/ # Task management with statuses, priorities, sizes
├── organization-project/ # Project management
├── organization-sprint/ # Sprint management
├── organization-project-module/ # Project modules
├── invoice/ # Invoice generation and management
├── expense/ # Expense tracking
├── payment/ # Payment processing
├── income/ # Income records
├── candidate/ # Applicant tracking
├── pipeline/ # Sales pipelines
├── contact/ # Contact/lead management
├── goal/ # Goals and objectives
├── goal-kpi/ # Key Performance Indicators
├── reports/ # Reporting and analytics
└── ... (148 modules total)
Infrastructure Modules
packages/core/src/lib/
├── database/ # Database connection and configuration
├── graphql/ # GraphQL schema and resolvers
├── health/ # Health check endpoints
├── logger/ # Logging configuration
├── i18n/ # Internationalization
├── email-send/ # Email dispatch
├── email-template/ # Email templates (Handlebars)
├── export-import/ # Data export/import
├── image-asset/ # Image/file management
├── throttler/ # Rate limiting
├── event-bus/ # Event bus integration
└── integration/ # Third-party integration base
CQRS Pattern
The backend extensively uses Command Query Responsibility Segregation (CQRS):
Commands (Write Operations)
// Command definition
export class CreateEmployeeCommand {
constructor(public readonly input: IEmployeeCreateInput) {}
}
// Command handler
@CommandHandler(CreateEmployeeCommand)
export class CreateEmployeeHandler
implements ICommandHandler<CreateEmployeeCommand>
{
constructor(private readonly employeeService: EmployeeService) {}
async execute(command: CreateEmployeeCommand): Promise<IEmployee> {
const { input } = command;
return this.employeeService.create(input);
}
}
Queries (Read Operations)
// Query definition
export class FindEmployeesQuery {
constructor(public readonly options: FindManyOptions<Employee>) {}
}
// Query handler
@QueryHandler(FindEmployeesQuery)
export class FindEmployeesHandler implements IQueryHandler<FindEmployeesQuery> {
constructor(private readonly employeeService: EmployeeService) {}
async execute(query: FindEmployeesQuery): Promise<IPagination<IEmployee>> {
return this.employeeService.findAll(query.options);
}
}