Backend platform and business services
The Gauzy backend is a Nest-based business platform for tenant workspaces. It serves business data and actions through REST and GraphQL, runs slow work in worker processes, and shares domain rules and contracts across web, desktop, integrations, and plug-ins. The platform keeps access, business state, durable work, and cross-cutting effects consistent across Gauzy products.
Platform boundary
Gauzy business platform
The platform turns client requests into tenant-scoped business actions and views. Its domain services cover identity, organizations, employees, work management, time tracking, finance, files, integrations, commerce, AI-assisted features, notifications, and collaboration. Applications and plug-ins use this shared business boundary instead of defining separate meanings for the same records.
The backend is more than an endpoint set. It is the place where tenant scope, access rules, business transitions, durable work, shared data contracts, and product extensions meet.
References: packages/…/package.json• L1-8 packages/…/index.ts• L1-177 packages/…/core.module.ts• L16-76 apps/…/package.json• L43-120
Tenant workspace model
A tenant is the main customer boundary. An organization is a work area inside that tenant. Backend services use the active request context to keep records and actions inside the selected tenant and organization.
Employee-owned records add a second scope. A caller normally sees and writes only the current employee's records unless a permission or a checked manager relationship allows access to another employee. Projects and teams also have an archive scope: normal lists hide archived rows while direct history views can retain them. See Identity and access control for the rules that establish this scope.
References: packages/…/tenant-aware-crud.service.ts• L63-135 packages/…/request-context.ts• L159-207 packages/…/archived-scope.ts• L4-25 packages/…/managed-employee.service.ts• L309-349
Backend runtime roles
The backend uses separate runtimes for request work, asynchronous work, local desktop support, and a packaged self-hosted installation. Each runtime owns a different part of the platform while sharing the core domain and contract boundaries.
| Runtime | Main role | Typical boundary |
|---|---|---|
| API application | Serves the Gauzy product over HTTP and GraphQL. | Requests, identity, business actions, and data reads. |
| Worker application | Runs scheduled work and consumes selected plug-in queues. | Long-running or repeated jobs outside request handling. |
| Desktop API | Provides local APIs for desktop features that need local data or integrations. | Local desktop data and desktop-only services. |
| Gauzy Server | Hosts a packaged local API and bundled Gauzy web UI. | Installation settings, local or LAN access, and process control. |
The API and worker are separate Nest processes. The desktop API has a smaller local scope than the main API. Gauzy Server is an Electron host that starts the API beside the bundled UI. The API application lifecycle page explains the main API. The Background jobs and scheduling page explains the worker.
References: apps/…/package.json• L30-69 apps/…/package.json• L20-54 apps/…/main.ts• L5-31 apps/…/main.ts• L12-52 apps/…/index.ts• L372-438
Embedded desktop server
Gauzy Server provides a packaged installation boundary for the business platform. The Electron host stores installation settings, selects the database and API address, starts the API, and starts a bundled UI server. Its LAN setting controls whether the UI and API serve only the local computer or every network interface.
The UI server serves only the bundled web application and returns controlled errors for unsafe paths. This gives a self-hosted installation the same business API with local process control and a protected UI delivery path.
References: apps/…/index.ts• L72-154 apps/…/index.ts• L372-438 apps/…/ui-server.ts• L3-12 apps/…/static-file-server.ts• L21-45
Business request flow
This flow shows how a client request crosses the platform boundary and becomes a scoped domain result.
flowchart LR
C[Web or desktop client] --> A[API application]
A --> I[Identity and request scope]
I --> D[Core domain service]
D --> P[Database or external integration]
P --> D
D --> A
A --> C
W[Worker application] --> D
The API and worker enter the same domain layer from different process roles. Authentication establishes who may act. Domain services apply business rules. Persistence or an integration records or delivers the result.
References: packages/…/index.ts• L79-101 packages/…/core.module.ts• L16-76 packages/…/request-context.middleware.ts• L32-100
Shared business foundation
Domain services
The core package groups business behavior into Nest modules and services. A domain service sits between an application entry point and a data or integration boundary. It applies scope and business rules before it changes or returns a record, and it can publish related activity, notification, subscription, or integration events.
The public core surface lets applications and plug-ins use the same capabilities without copying them. See Domain services and contracts for the domain boundaries and shared library roles.
References: packages/…/index.ts• L1-15 packages/…/index.ts• L73-177 packages/…/tenant-aware-crud.service.ts• L63-135
API query contract
REST and GraphQL expose the same business capabilities through different request shapes. Shared list rules define filters, sort order, page limits, totals, and cursors. A GraphQL connection is the GraphQL form of that contract, so a client can move between API surfaces without changing the meaning of a query or page.
The shared read boundary also protects fields that must not influence caller-supplied filters, sort order, or selections. Credential fields are refused for all callers. Pay-rate fields are available only to the employee or to a caller with the rate-edit permission. Domain resolvers and REST routes use the same service rules and expose only fields and arguments that the underlying read or write can honor.
References: packages/…/graphql-connection.ts• L7-27 packages/…/graphql-connection.ts• L120-145 packages/…/crud.service.ts• L153-211 packages/…/caller-restricted-columns.config.ts• L4-41 packages/…/caller-restricted-columns.helper.ts• L39-89 packages/…/organization.resolver.ts• L133-176 packages/…/time-log.resolver.ts• L300-360
Organization management
An organization is the platform's main work area and settings scope. Its business services provide identity membership, public profile settings, time and tracking policy, financial defaults, commerce defaults, and the links that other domains use to locate their organization.
Creating an organization also prepares the surrounding platform state. The flow adds the right tenant administrators, creates optional contact details, seeds commerce defaults, and starts task and report defaults. Updates preserve omitted settings and apply location-sensitive controls before the organization is changed.
New organizations keep screen capture off unless the request enables it. Enabling capture for an organization in the EEA or UK requires all required acknowledgement statements. The server records who acknowledged the change and when; clients cannot provide that record as ordinary organization data.
References: packages/…/organization.create.handler.ts• L60-75 packages/…/organization.create.handler.ts• L103-216 packages/…/organization.update.handler.ts• L59-193 packages/…/screenshot-capture-acknowledgement.ts• L19-83 packages/…/organization-location.ts• L134-215
Customer and contact records
Organization contacts represent customers, clients, leads, and other parties that business records can reference. The contact service supports REST and GraphQL reads, employee assignment, lifecycle actions, project links, budgets, and comments while keeping the contact inside the caller's tenant and organization scope.
Creating a contact with create permission but without edit permission is limited to new data. It can link only unassigned projects from the caller's organization. The platform claims those projects with the contact in one transaction so a concurrent claim fails without creating a partial contact. Contact comments use the contact's own view and edit permissions and the same scoped contact lookup.
References: packages/…/organization-contact.service.ts• L30-84 packages/…/organization-contact-create.handler.ts• L34-124 packages/…/organization-contact-create-only.ts• L20-84 packages/…/organization-contact-comment-access.policy.ts• L6-33 packages/…/organization-contact.resolver.ts• L169-209
Workforce operations
The platform connects time, leave, pay, and employee records into shared business services. Payroll records organize a pay period into earnings and deductions. Leave policies define entitlement and accrual rules. Timesheet changes provide a controlled way to correct project assignment.
Pay rates are treated as salary data rather than ordinary employee profile data. Employees can read their own rate, authorized rate editors can read or change rates, and an employee without the right to change their own rate can ask an authorized employee to review it. These capabilities remain tenant and organization scoped, and their workflows keep important business state behind explicit transitions.
References: packages/…/app.module.ts• L459-479 packages/…/payroll-run.service.ts• L35-55 packages/…/time-off-policy.service.ts• L102-137 packages/…/timesheet-project-change-request.service.ts• L23-43 packages/…/employee.service.ts• L1194-1255 packages/…/rate-change-request.service.ts• L20-69 packages/…/employee.entity.ts• L180-204
Work management
Work management links tasks to projects, teams, and organization project modules. Teams carry member and manager context. Tasks and task statuses give clients a shared way to organize work.
Projects and teams can be archived without losing their tasks, members, or history. Normal lists and counts hide archived rows. Relation edits preserve archived links that are not present in normal pickers. Team reads and changes are limited to a caller's employee scope or a checked manager role. Team comments are assigned through the comment service rather than by a general team update.
The shared task contract also carries task views, bounded bulk changes with undo data, durable project references, trash queries, and per-task integration sync scope. A task without a sync scope remains available to all integration audiences, while a restricted or unknown scope fails closed for unsupported integrations.
References: packages/…/organization-team.entity.ts• L57-67 packages/…/organization-team.service.ts• L136-188 packages/…/organization-team.service.ts• L384-479 packages/…/organization-team.service.ts• L793-961 packages/…/organization-team.service.assigned-comments.spec.ts• L8-45 packages/…/task.model.ts• L24-59 packages/…/task.model.ts• L117-142 packages/…/task.model.ts• L199-305
Time tracking platform
Time tracking turns timer activity and manual entries into durable work records and reports. The flow connects running timers, time logs, time slots, screenshots, activity, timesheets, and aggregate statistics so desktop trackers and management views use the same work history.
The service applies tenant, organization, employee, and manager scope to reads and writes. A caller without an employee identity cannot fall back to tenant-wide time data. Manual time stays in the employee's organization, and moving a log within that organization keeps its related timesheet and time-slot history aligned. Reports use the same scope and return daily, weekly, owed-amount, time-limit, and project or client budget views. Durations are seconds, while money uses exact decimal values and the rate's currency precision.
The time-log GraphQL surface mirrors the REST list, conflict read, reports, budget views, and manual-time writes. It keeps tracked-data visibility and organization policy checks on the same fields as the REST routes. TypeORM and MikroORM paths preserve the same report and budget meaning.
References: packages/…/time-log.service.ts• L77-109 packages/…/time-log.service.ts• L210-353 packages/…/time-log.service.ts• L1240-1339 packages/…/time-log.service.ts• L1348-1489 packages/…/time-log.resolver.ts• L300-360 packages/…/time-log.service.reports.dual-orm.spec.ts• L1-120
Platform kernel capabilities
The platform kernel provides services that many business areas need. These services cover document numbering, retry protection, event delivery, durable multi-step work, webhooks, rule evaluation, tax and money ledgers, global search, sales channels, commercial regions, scheduled-run records, stored payment references, and shared API and concurrency conventions.
The event outbox makes a business change durable before consumers, search projections, webhooks, notifications, or real-time channels process it. It keeps event order per business record, retries failed delivery, and retains dead letters for operator action. A commit signal can wake a queue-backed or inline dispatcher after the transaction commits, while the scheduled pass remains the recovery path. In-process events can carry a small change hint, such as a comment change, while consumers fetch the protected record again through its normal access rules.
These capabilities stay in the shared platform because several domains use the same business fact. An order and an invoice need the same numbering rules. A state change and its event need one durable boundary. A saved payment method must support both one-time charges and subscription renewals. Plug-ins use the same public kernel surface as built-in domains instead of creating parallel rules.
References: packages/…/index.ts• L283-450 packages/…/event-outbox.service.ts• L120-164 packages/…/event-outbox-commit.signal.ts• L5-25 packages/…/event-outbox-dispatch.worker.ts• L120-137 packages/…/event-outbox-inline-dispatch.ts• L8-35 packages/…/comment.event.ts• L17-30 packages/…/1791000000000-CreateSequenceTable.ts• L5-10 packages/…/1791000000020-CreateEventOutboxTables.ts• L5-11 packages/…/1791000000030-CreateOperationTables.ts• L5-12 packages/…/1791000000125-CreatePaymentInstrumentTables.ts• L5-20
Shared contracts
The contracts package defines the shared vocabulary for records and actions. It gives applications, workers, and plug-ins common shapes for users, tenants, organizations, tasks, time, integrations, permissions, payroll, leave, commerce, real-time collaboration, and other business data.
Base contracts carry common record facts and tenant or organization links. Domain contracts add states and input shapes that clients and services exchange. Changelog entries can identify the product they belong to. Real-time contracts distinguish durable change hints from ephemeral presence and typing signals. Task contracts define integration sync scope, former references, bulk updates, and built-in task views. These values cross process boundaries and are not private types for one application.
References: packages/…/package.json• L1-31 packages/…/index.ts• L118-164 packages/…/base-entity.model.ts• L15-87 packages/…/changelog.model.ts• L12-60 packages/…/realtime.model.ts• L7-15 packages/…/realtime.model.ts• L184-270 packages/…/task.model.ts• L24-59 packages/…/task.model.ts• L186-292 packages/…/daily-plan.model.ts• L12-49
Shared support libraries
Configuration, common types, constants, and utilities give the domain layer one view of runtime settings and shared rules. Configuration combines defaults with application and plug-in settings. Tenant settings combine global defaults with tenant overrides and attach the result to requests through a short-lived cache.
The same business layer can run in a hosted API, a worker, or a desktop process without each process inventing its own configuration or query rules. API builds select the environment for the packaged configuration used by that API artifact and omit UI-only packages, so the business process gets only the product surface it can run.
References: packages/…/config.module.ts• L1-21 packages/…/config-loader.ts• L1-35 apps/…/webpack-package-copy-patterns.js• L108-199 apps/…/webpack-package-copy-patterns.js• L217-275 packages/…/index.ts• L1-9 packages/…/index.ts• L1-9 packages/…/index.ts• L1-43 packages/…/tenant-settings.middleware.ts• L8-18
Database boundary
The database boundary gives the shared domain layer one persistence contract across PostgreSQL, MySQL, and SQLite profiles. Configuration selects the active database and migration work keeps its schema ready. The application can use more than one ORM view of the same business model.
Shared helpers normalize database differences. Startup and command-line migration paths use common locking and transaction rules. Embedded SQLite work is serialized so separate requests do not share one transaction by accident.
References: packages/…/database.module.ts• L13-25 packages/…/database.module.ts• L40-97 packages/…/database.helper.ts• L14-38 packages/…/embedded-transaction-queue.ts• L40-77
Entity and persistence boundary
Core entities represent business records that the platform can persist. The entity registry brings those records into the shared database boundary. Domain modules then expose the services that act on them.
The kernel also persists durable operations, event outbox records, webhook delivery state, search projections, channel and region context, scheduler history, payment references, and user-owned API token records. A feature becomes part of the platform when its contracts, domain behavior, persistence model, and schema lifecycle agree.
References: packages/…/index.ts• L80-189 packages/…/internal.ts• L161-217 packages/…/1791000000020-CreateEventOutboxTables.ts• L69-131 packages/…/1791000000096-CreateSchedulerJobTables.ts• L5-27 packages/…/1791000003900-CreateUserApiTokenTable.ts• L45-53
Response safety boundary
The backend applies a final response pass after a controller or resolver returns. It removes user credential fields and employee pay-rate fields from serialized response objects, while the dedicated pay-rate response can expose only the rate fields that its access check allows.
The same boundary also turns unexpected failures into safe HTTP errors. This matters because ORM serialization can produce plain objects that do not carry entity metadata, and because generic reads can load nested records through relations. Caller-supplied reads are checked before the database is reached, so sensitive columns cannot be used as hidden filters, sort keys, or selections.
References: packages/…/transform.interceptor.ts• L24-49 packages/…/user-credential-scrub.ts• L81-121 packages/…/employee-pay-rate-scrub.ts• L4-45 packages/…/caller-restricted-columns.helper.ts• L39-89 packages/…/caller-restricted-columns.service-built-reads.spec.ts• L18-21
Product extension model
Server plug-ins
A server plug-in is an optional product or integration unit that can add Nest modules, data resources, configuration, lifecycle actions, and seed behavior to a host process. The API builds its product surface by registering core business extensions, commerce domains, AI providers, authentication providers, collaboration features, email providers, and external integrations.
Plug-ins declare prerequisites. The API resolves those prerequisites before it builds the Nest module graph and refuses a missing prerequisite at startup. Optional settings can keep a feature out of the process entirely, including its routes, tables, timers, and outbound work. See Plugin architecture for server and UI plug-in relationships.
References: packages/…/plugin.interface.ts• L7-78 packages/…/plugin.module.ts• L19-97 apps/…/plugins.ts• L95-174 apps/…/plugins.ts• L210-313 apps/…/package.json• L43-120 apps/…/plugin.config.ts• L121-130
Capability composition
Capability composition is the installation-level link between independent plug-ins. A package declares a small capability port. The installation binds that port to an existing service when both sides are present.
This lets packages remain usable on their own while allowing a full installation to connect catalog, pricing, tax, inventory, orders, payments, subscriptions, purchasing, returns, and fulfillment. An unbound optional capability stays unavailable instead of silently using a service with a different meaning.
References: apps/…/plugin-composition.ts• L48-79 apps/…/plugin-composition.ts• L81-115 apps/…/plugin-composition.ts• L116-200
Provisioning integration state
Some integrations use core persistence to coordinate a business flow that starts outside Gauzy. The Ever connection flow records a signed provisioning intent and an idempotent workspace-creation result, so confirmation, retries, ownership, and completion reports remain durable even when the plug-in is optional.
The tables are part of the shared schema because plug-in migrations do not own this lifecycle. They stay empty unless the integration is enabled. See Plugin architecture for the plug-in boundary and Background jobs and scheduling for retry work.
References: packages/…/1791000003950-EverConnectProvision.ts• L46-49 packages/…/1791000003950-EverConnectProvision.ts• L111-126
Process-specific ownership
The API and worker do not use the same plug-in list for the same purpose. The API loads product and integration capabilities for requests. The worker loads plug-ins that own queues or long-running work for that process.
This split keeps heavy work out of request handling. Adding a plug-in to the API does not by itself make the worker process its queues.
References: apps/…/plugins.ts• L172-210 apps/…/plugins.ts• L3-25 apps/…/app.module.ts• L8-50
Server and UI pairing
Server and UI plug-ins meet through the shared API and contract boundaries. A server plug-in supplies business behavior and API capability. Its UI partner supplies the user-facing routes and controls that call that capability.
The two sides can have different process ownership. A feature can expose API behavior in the server, send heavy work to the worker, and leave the browser plug-in responsible for the user experience.
References: packages/…/docs.plugin.ts• L30-107 packages/…/docs-ui.plugin.ts• L24-57 packages/…/docs-ui.plugin.ts• L91-190
Identity and access boundary
Authentication and authorization
Authentication proves the identity behind a request. Authorization decides whether that identity may use an action or record. The API validates access tokens, tenant membership, organization membership, roles, and named permissions before protected domain work runs.
Business resources can use separate grants for viewing, creating, editing, deleting, or restoring. Contact creation and deletion now have grants that can be held without contact edit access. Actions that can create a lasting credential or change account identity also require a first-party user session. Third-party OAuth sessions and sessions created from personal API tokens cannot approve applications, create accounts, change account credentials, create tenant credentials, or delete users.
See Identity and access control for sign-in, token, tenant, and permission flows.
References: packages/…/auth.module.ts• L39-101 packages/…/jwt.strategy.ts• L54-159 packages/…/permission.guard.ts• L29-91 packages/…/oauth-app-first-party.ts• L5-33 packages/…/email-reset.service.ts• L115-180 packages/…/user.service.ts• L1506-1559
Application credentials
The backend supports separate credential types for third-party applications, individual users, and tenant-level integrations. Each type has its own owner and lifetime, but all three enter the same access and tenant rules before business work runs.
| Credential | Owner and purpose | Session or use boundary |
|---|---|---|
| OAuth application | A registered application uses a tenant-scoped or global client with approved redirect addresses and scopes. | The authorization-code exchange issues an access token limited to the approved application scopes. |
| Personal API token | A user creates a named token for an agent or script. | It is exchanged for a short-lived ordinary access token. It is not accepted directly on business routes and cannot mint another lasting credential. |
| Tenant API key pair | A tenant administrator creates a credential for a tenant integration. | The pair is shown at creation, then the secret is represented only by a digest. The tenant can rename or revoke it. |
OAuth client secrets and personal API token secrets are shown only at creation. Personal API tokens can be disabled for the server, expire, or be revoked. A token exchange checks that the user and the selected organization are still active, so account or membership changes affect later exchanges.
References: packages/…/oauth-client.service.ts• L75-155 packages/…/auth.service.ts• L313-412 packages/…/user-api-token.controller.ts• L30-116 packages/…/user-api-token.service.ts• L130-231 packages/…/tenant-api-key.service.ts• L34-87
Request context
The request context is the server's shared view of the current user, tenant, organization, role, token, and correlation identifier. Middleware creates it for a request. Authentication and tenant guards fill or check it. Domain services use it when they apply scope.
This makes access control a platform rule rather than a list of checks repeated in every controller. Background work has a different entry path and must carry or establish the scope needed by its domain operation.
References: packages/…/request-context.middleware.ts• L19-30 packages/…/request-context.middleware.ts• L50-100 packages/…/request-context.ts• L159-207 packages/…/tenant-aware-crud.service.ts• L91-115
Role permission model
Roles group named permissions that control access to business areas. Default role grants provide a starting policy for new tenants. Permission repair can add missing grants without replacing tenant customizations.
This model separates preparing data from approving a business result. Payroll, leave, timesheet, commerce, integration, contact, and organization actions can therefore use distinct access rules.
References: packages/…/role-permission.model.ts• L39-118 packages/…/default-role-permissions.ts• L3-21 packages/…/utils.ts• L20-79
Runtime operations
API lifecycle
The API turns environment settings and the registered plug-in set into a running HTTP and GraphQL service. Its shared bootstrap prepares configuration, database resources, security boundaries, observability, assets, migrations, and initial data before the service reports readiness.
The core application module assembles identity, organization, work, time tracking, leave, payroll, billing, integration, commerce, credential, collaboration, AI, and other domain modules. It also mounts global response, organization-membership, idempotency, and readable-comment boundaries so REST and GraphQL requests use the same safety and retry rules. The build packages the selected compiled business extensions with environment-specific configuration for the API artifact. When queueing is unavailable, the API can run event-outbox, webhook, invoice, and reminder work in process rather than leaving durable effects undelivered. Read API application lifecycle for the ordered startup flow.
References: apps/…/main.ts• L1-33 apps/…/plugin.config.ts• L64-131 apps/…/webpack-package-copy-patterns.js• L114-199 packages/…/index.ts• L65-85 packages/…/app.module.ts• L438-462 packages/…/app.module.ts• L463-553 packages/…/app.module.ts• L662-795
Background processing
The worker provides a separate runtime for repeated and slow work. The scheduler can run a job in place or place its payload on a named queue. A queue worker then hands the job to a domain or plug-in handler.
The API can provide a producer-only queue root when Redis queueing is enabled. The worker remains the owner of scheduled execution. Without a queue root, selected event-outbox, webhook, invoice, and reminder workers can run through short in-process sweeps. Timer, meeting, task-due, invoice, and invoice-schedule reminders follow the same process split when enabled. The platform records scheduled attempts and exhausted failures in shared job history and dead-letter records. See Background jobs and scheduling.
References: apps/…/main.ts• L5-31 apps/…/app.module.ts• L19-50 packages/…/scheduler.module.ts• L17-67 packages/…/app.module.ts• L662-749 packages/…/event-outbox-inline-dispatch.ts• L38-98 packages/…/webhook-inline-retry.ts• L11-17 packages/…/1791000000096-CreateSchedulerJobTables.ts• L5-27
Data readiness
Database migrations move the schema between known versions. Seed workflows add the initial records that make a new environment usable. The API uses the same core and plug-in model for database resources and seed behavior.
Migration work supports the platform's three database profiles and can run during startup or through dedicated commands. Migration helpers guard replayable changes and prevent concurrent startup processes from applying the same change at once. Empty databases receive default seed data only when no users exist; existing databases are not silently re-seeded, and non-demo installs are warned when published seed passwords remain active.
References: apps/…/migration.ts• L1-65 packages/…/index.ts• L689-749 packages/…/app.service.ts• L19-35 packages/…/app.service.ts• L37-79 packages/…/migration-executor.ts• L22-64 packages/…/migration-executor.ts• L212-248
Operational visibility
The backend exposes health and global statistics as platform-level operational views. Health checks cover the active database, storage, cache, and optional Redis service. API call logging is a separate diagnostic record for selected requests and can be disabled without removing business routes.
References: packages/…/health.service.ts• L19-131 packages/…/stats.service.ts• L44-95 packages/…/api-call-log-middleware.ts• L29-146
File and media boundary
The file boundary connects tenant storage providers to business records such as image assets and screenshots. Uploads are checked by content as well as client-supplied type. Accepted images receive a display thumbnail.
The boundary refuses unsafe markup, removes rejected objects, and keeps public file serving inside the intended storage area. Organization, project, team, and contact records use the same placeholder and image rules.
References: packages/…/image-thumbnail.ts• L10-20 packages/…/image-thumbnail.ts• L131-164 packages/…/image-asset.controller.ts• L63-155 packages/…/organization-contact.subscriber.ts• L47-112
Backend topic map
The backend child pages split the platform into the main engineer entry points:
- API application lifecycle — API configuration, startup, security, assets, migrations, seeds, and readiness.
- Domain services and contracts — core business services and the shared contract, configuration, constant, and utility libraries.
- Identity and access control — authentication, tenant scope, roles, permissions, tokens, and client session boundaries.
- Account deletion — account removal requests, confirmation, cleanup, persistence, and user-facing identity flows.
- Plugin architecture — server and UI plug-in discovery, registration, ownership, dependency order, and capability composition.
- Background jobs and scheduling — worker startup, schedules, queues, handlers, run history, and recovery.
- Subscription billing — subscription plans, billing state, and the services that connect account access to paid product use.
Change checklist
When these files or sections are changed, remember to consider these:
- When a core service or contract changes, check every API, worker, desktop API, and plug-in that uses its scope or state.
- When a tenant or organization relation changes, check request context creation, authentication claims, tenant-aware services, and background job scope.
- When adding a server plug-in, check its prerequisites, process ownership, capability ports, migrations, permissions, feature gates, and seed hooks.
- When changing the API plug-in list or build packaging, check the API and worker ownership split, compiled package selection, UI package exclusions, environment selection, and name-based dependency resolution.
- When changing a shared contract or enum, check serialized API responses, client state, persisted records, and queued or outbox payloads together.
- When changing task sync scope, task references, or task views, check task writes, integration filters, historical references, bulk-update results, and client queries together.
- When changing organization create or update behavior, check membership setup, contact linking, commerce defaults, task defaults, location-sensitive acknowledgements, and both REST and GraphQL inputs.
- When changing contact create permissions, check REST routes, GraphQL fields, comment access, existing-row protection, and concurrent project claims together.
- When changing a team member or manager rule, check team reads, project and task scope, daily plans, time records, invitations, and account-leave flows.
- When changing time-log scope or aggregation, check REST and GraphQL surfaces, employee and organization policy checks, time-slot links, timesheet recalculation, reports, budgets, and both ORM paths.
- When changing pay-rate fields or rate permissions, check generic selects and filters, response scrubbing, the dedicated rate read, employee updates, rate-change notifications, and time or invoice calculations.
- When changing comments, subscriptions, notifications, or real-time hints, keep the stored record scope, in-process event payload, follower eligibility, and refetch access rules aligned.
- When changing GraphQL fields, keep their service or command, argument list, result shape, feature gate, guard chain, and route permission aligned with REST.
- When changing authentication or credential issuance, check first-party restrictions, token claims, organization selection, expiry, revocation, and account status checks together.
- When changing OAuth client scope or tenant ownership, check authorization approval, redirect validation, code exchange, secret rotation, and global-client visibility together.
- When changing personal API tokens, check the disabled-server behavior, one-time secret response, exchange session lifetime, account deletion cascade, and route throttling together.
- When changing tenant API keys, check one-live-pair behavior, secret redaction, tenant scope, immediate revocation, and the permission names on all mutations.
- When changing configuration defaults, check hosted API, worker, desktop API, packaged Gauzy Server, and plug-in startup assumptions.
- When changing a database resource, check migration registration, empty-database setup, standalone migration commands, seed paths, and every supported database profile.
- When adding a durable operation or event, align its idempotency key, tenant scope, status transitions, retry behavior, ordering, and operator-visible failure record.
- When changing upload validation or thumbnail output, check public file serving, object cleanup, content type, and every upload route that uses the shared helper.
- When changing timer reminders, keep the queue-backed worker schedule, API consumer, no-queue inline sweep, and feature gate on the same path.
- When changing global modules or interceptors in
AppModule, check both REST and GraphQL mounting, interceptor order, request rejection before idempotent replay, response scrubbing, and the API and worker process split.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A domain operation bypasses the active tenant or organization scope | A caller can read or change data outside its workspace | Keep normal domain access behind request-aware or explicitly scoped services |
| A GraphQL field does not mirror the REST route's service, arguments, or permission | REST and GraphQL clients receive different business behavior or access | Treat the route and field as one capability and keep their contracts paired |
| A GraphQL operation names an organization without the membership interceptor | A caller can reach a resolver with an organization outside its membership | Apply the shared membership check before idempotency and domain execution |
| A serialized user or employee bypasses entity metadata | Credentials or salary data can reach a client in a plain response object | Run the final response scrub and keep the pay-rate exception limited to its marked response |
| A caller uses a credential or pay-rate column in a generic filter, sort, or select | A sensitive value influences which rows return or leaks through a nested relation | Apply the caller-column rules before the database read and keep pay rates on the dedicated route |
| A create-only contact request reaches an existing contact, detail row, or business relation | A caller with add access can edit or re-point existing data | Reject existing references and claim only unassigned projects in one transaction |
| A contact project is claimed between validation and save | A contact is created with a project that another request already owns | Claim all projects conditionally and roll back the whole create on a short claim |
| A screen-capture acknowledgement is accepted from the body or omitted for an EEA/UK change | The platform enables capture without a trusted record of consent | Require all statements and write the actor and time on the server |
| A personal API token is accepted as a normal business credential or can mint another lasting credential | Revocation does not contain the automation and a leaked token can extend its own access | Exchange it for a short-lived ordinary session and reject first-party-only actions for that session |
| A personal API token secret is stored or returned after creation | A database read or ordinary list response becomes a reusable credential | Store only the digest and return the secret only in the creation response |
| An OAuth client is resolved without its active, tenant, redirect, or scope boundary | A third-party app can receive a token for the wrong tenant or broader access | Validate the client registry, redirect, approved scopes, and tenant at approval and exchange |
| A tenant API key pair is generated without a first-party tenant-admin check | A scoped application credential can be created by an app token or outside the caller's tenant | Apply the first-party and permission guards and keep one live pair per tenant |
| A plug-in is loaded by the API but not by the worker that owns its queue | Heavy work stays in the API or no process consumes the queue | Keep process plug-in lists and queue ownership explicit |
| A plug-in prerequisite is missing or a compiled class name is changed during packaging | The API refuses to boot or cannot resolve the declared dependency | Resolve prerequisites at boot and preserve compiled plug-in names in API packaging |
| Two startup processes apply the same migration without a shared lock | Schema work races and readiness becomes unsafe | Use the common migration lock and replayable migration guards |
| A state change commits without its outbox event | Consumers, search projections, or webhooks never learn about the change | Write the state change and outbox record in one transaction |
| An outbox head is skipped while it is in backoff | A later event for the same record is delivered before its predecessor | Claim only the first ready event in each ordered partition |
| A scheduled failure is left only in logs | Operators cannot inspect or replay the failed work | Record each run and move exhausted work to the shared dead-letter store |
| A comment event contains the comment text or bypasses the record's access rule | A real-time subscriber can learn data it cannot read | Publish only a change hint and make the subscriber refetch through the comment API |
| Follower fan-out ignores the record's tenant, organization, or active membership | A notification names a record to an employee who cannot read it | Resolve followers in the record's scope and exclude the actor |
| A time-log report has no employee scope for a caller without an employee record | A personal read can widen to the whole organization | Fail closed when the caller has neither selected-employee permission nor an employee identity |
| A manual time write uses the body's organization instead of the employee's organization | Time, conflicts, slots, and policy checks can cross organization boundaries | Resolve the employee first and keep the write and related work in that organization |
| A time-log move ignores its existing slots or activity | Tracked evidence is attributed to the wrong employee or related totals drift | Refuse moves with tracked evidence and re-home valid moves with their timesheet and slots |
| The packaged UI server trusts a path outside its bundled UI root | A LAN client can read files from the desktop installation | Confine static serving to the UI root and return controlled errors |
| A raw payment instrument is stored in Gauzy | Sensitive payment data enters the platform database | Store only provider-owned references and safe display metadata |
| Account deletion proceeds after its plan or workspace membership changed | A newer member or workspace state is removed under an old confirmation | Hash the previewed plan and re-check it under a row lock before each deletion |
| A timer reminder uses the queue path without a queue root or runs both queue and inline paths | Reminders fail to start or are delivered more than once | Select one path from the shared queue and feature gates, with scheduled ownership in the worker |
| A task integration ignores its sync scope or treats an unknown scope as open | A task marked private can leave Gauzy through the wrong integration | Use the shared task contract and fail closed for unsupported scope values |
Key files
| File | Why to read it |
|---|---|
| apps/…/main.ts | Shows the main API entry point and handoff to shared bootstrap. |
| apps/…/plugins.ts | Shows the API plug-in surface, optional feature gates, AI and commerce extensions, and composition point. |
| apps/…/webpack-package-copy-patterns.js | Shows how compiled business packages and the API environment are selected for a build. |
| apps/…/plugin-composition.ts | Shows where independent plug-ins are joined through capability ports. |
| apps/…/index.ts | Shows how the packaged Gauzy Server owns settings, process control, and the embedded API/UI pair. |
| packages/…/index.ts | Defines the shared application preparation and readiness boundary. |
| packages/…/index.ts | Shows the public domain services and platform facilities available to applications and plug-ins. |
| packages/…/app.module.ts | Shows how the API assembles business, authentication, credential, billing, event, subscription, queue, timer-reminder, cache, throttle, and global-interceptor runtime modules. |
| packages/…/app.service.ts | Shows empty-database seeding and the warning path for published seed passwords. |
| packages/…/request-context.middleware.ts | Shows how request-local scope and correlation values enter the backend path. |
| packages/…/crud.service.ts | Shows the shared read, write, soft-delete, ORM, and caller-column boundary. |
| packages/…/caller-restricted-columns.helper.ts | Shows how caller-supplied filters, sorts, and selections are checked. |
| packages/…/transform.interceptor.ts | Shows the final response transform, sensitive-field scrub, and safe error boundary. |
| packages/…/organization.create.handler.ts | Shows the organization provisioning flow and its downstream defaults. |
| packages/…/organization.update.handler.ts | Shows organization setting changes and location-sensitive controls. |
| packages/…/organization-contact.service.ts | Shows tenant-scoped contact reads and atomic project claims. |
| packages/…/organization-team.service.ts | Shows team scope, manager checks, archive behavior, and member changes. |
| packages/…/employee.service.ts | Shows employee scope, agent provisioning, pay-rate access, and rate protection. |
| packages/…/rate-change-request.service.ts | Shows the employee-to-authorized-reviewer rate request flow. |
| packages/…/time-log.service.ts | Shows time-log scope, reports, budgets, manual time, and ORM parity. |
| packages/…/auth.service.ts | Shows how normal, OAuth, and personal API-token sessions become scoped access tokens. |
| packages/…/oauth-client.service.ts | Shows the registered application boundary, secret lifecycle, and tenant visibility. |
| packages/…/user-api-token.service.ts | Shows personal token ownership, exchange, expiry, revocation, and session limits. |
| packages/…/tenant-api-key.service.ts | Shows tenant integration credential issuance, redaction, and revocation. |
| packages/…/account-deletion.service.ts | Shows preview-based account and workspace deletion, cleanup, billing cancellation, and audit behavior. |
| packages/…/comment.service.ts | Shows comment ownership, governed-record access, mentions, and change events. |
| packages/…/follower-fan-out.service.ts | Shows how scoped followers receive comment and task-change notifications. |
| packages/…/event-outbox.service.ts | Shows durable event append, ordered dispatch, retries, delivery state, and operator replay. |
| packages/…/event-outbox-dispatch.worker.ts | Shows queue-based event dispatch and per-consumer failure handling. |
| packages/…/event-outbox-inline-dispatch.ts | Shows event dispatch for API deployments without a queue. |
| packages/…/graphql-subscription.module.ts | Shows the shared real-time subscription boundary. |
| packages/…/subscription-catalogue.ts | Shows event declaration and subscription selection rules. |
| packages/…/index.ts | Shows the cross-application business vocabulary. |
| packages/…/realtime.model.ts | Shows the durable and ephemeral real-time event contract. |
| packages/…/task.model.ts | Shows task sync scope, trash and view queries, bulk changes, references, and task views. |
| packages/…/graphql-connection.ts | Shows the shared list and pagination contract across GraphQL and REST. |
| packages/…/database.module.ts | Shows the shared persistence boundary and database profile selection. |
| packages/…/migration-executor.ts | Shows how startup and command-line migration work use one database lifecycle. |
| packages/…/1791000003950-EverConnectProvision.ts | Shows how an optional external provisioning flow gets durable intent and retry state. |
| packages/…/scheduler.module.ts | Defines the shared scheduling and queue boundary used by applications and plug-ins. |