Architecture Overview
Ever Gauzy is built as a modern, full-stack TypeScript monorepo using enterprise-grade frameworks. This document provides a high-level view of the platform's architecture.
System Architectureโ
Architectural Layersโ
1. Client Layerโ
The client layer consists of multiple application types, all consuming the same API:
| Application | Technology | Package Location | Purpose |
|---|---|---|---|
| Web UI | Angular 19+, Nebular/ngx-admin | apps/gauzy | Primary web interface |
| Desktop App | Electron + Angular | apps/desktop | All-in-one desktop application |
| Desktop Timer | Electron + Angular | apps/desktop-timer | Time tracking & activity monitoring |
| Desktop Server | Electron + NestJS | apps/server | Self-hosted API server |
| API Server Desktop | Electron + NestJS | apps/api-server | API-only server deployment |
| Ever Teams | React/Next.js + React Native | External repo | Modern PM/Task interface |
2. API Layer (NestJS)โ
The backend is a NestJS application following CQRS (Command Query Responsibility Segregation) patterns:
- Controllers โ handle HTTP requests, validate inputs, route to handlers
- Commands/Queries โ encapsulate business logic via the CQRS pattern
- Services โ core business logic and data access
- Guards โ authentication and authorization (JWT, Roles, Permissions, Tenant)
- Interceptors โ request/response transformation, logging
- Pipes โ input validation and transformation (class-validator)
- Modules โ NestJS dependency injection containers
3. Data Layerโ
The platform uses a Multi-ORM architecture supporting:
- TypeORM โ primary ORM with extensive entity definitions, repositories, and migrations
- MikroORM โ alternative ORM with its own repositories and entity metadata
- Knex โ raw SQL query builder for complex queries and migrations
All three ORMs connect to the same database and share entity definitions through a shared Multi-ORM decorator system.
4. Infrastructure Layerโ
- PostgreSQL โ primary production database
- SQLite โ lightweight development/demo database
- Redis โ caching, session store, and job queue
- OpenSearch โ full-text search indexing
- MinIO/S3 โ file and image storage
- Cube โ analytics and BI semantic layer
- Zipkin/OTEL โ distributed tracing
Key Architecture Patternsโ
Multi-Tenant Architectureโ
Every entity in the system is scoped to a tenant. The TenantBaseEntity base class provides:
- Automatic
tenantIdinjection on create/update - Automatic
tenantIdfiltering on read queries - Cross-tenant access prevention at the ORM level
See Multi-Tenancy for details.
Plugin Architectureโ
The platform supports dynamic plugins for extending functionality:
@Module({})
export class PluginModule {
static forRoot(plugins: Type<any>[]): DynamicModule {
return {
module: PluginModule,
imports: plugins,
};
}
}
Plugins can add: entities, controllers, services, commands, and event handlers. See Plugin System.
CQRS Patternโ
Business logic is organized into Commands (write) and Queries (read):
Controller โ CommandBus/QueryBus โ Handler โ Service โ Repository
This pattern enables:
- Clear separation of read and write operations
- Event-driven side effects
- Easier testing through handler isolation
Event Busโ
The platform uses NestJS @nestjs/cqrs events for inter-module communication:
// Publishing an event
this.eventBus.publish(new EmployeeCreatedEvent(employee));
// Handling an event in another module
@EventHandler(EmployeeCreatedEvent)
export class EmployeeCreatedHandler {
handle(event: EmployeeCreatedEvent) {
/* ... */
}
}
Request Contextโ
A RequestContext utility provides access to the current request context throughout the application:
// Access current user, tenant, and organization
const tenantId = RequestContext.currentTenantId();
const userId = RequestContext.currentUserId();
const orgId = RequestContext.currentOrganizationId();
Data Flowโ
Typical API Request Flowโ
- Guard: Validates JWT token, checks roles/permissions, resolves tenant
- Pipe: Validates request body against DTO (Data Transfer Object) classes
- Handler: Executes business logic via CQRS command/query handler
- Service: Performs data access, integrations, and business rules
- Repository: Issues database queries through the active ORM
Guard Chainโ
Deployment Modelsโ
| Model | Components | Best For |
|---|---|---|
| SaaS | Cloud-hosted API + UI | Multi-tenant production |
| Self-Hosted | Docker or bare metal | Private infrastructure |
| Desktop Server | Electron app hosting API | Small teams, individuals |
| Desktop All-in-One | Full platform in single app | Personal use |
| Client-Server | Separate API server + clients | Teams with centralized server |
Related Pagesโ
- Monorepo Structure โ NX workspace organization
- Technology Stack โ all technologies used
- Backend Architecture โ NestJS internals
- Frontend Architecture โ Angular UI
- Multi-ORM Architecture โ TypeORM, MikroORM, Knex
- Plugin System โ extending the platform
- Multi-Tenancy โ tenant isolation
- Design Principles โ core philosophy