Feature: Project Management
Relevant source files
The following files were used as context for generating this wiki page:- api/src/controllers/project.controller.ts
- webapp/src/app/projects/components/project-list/project-list.component.ts
- webapp/src/app/projects/components/project-settings/project-settings.component.ts
- webapp/src/app/projects/projects.module.ts
- webapp/src/app/projects/stores/projects.state.ts
- api/src/domain/http.ts
- api/test/project.e2e-spec.ts
- webapp/src/app/projects/components/project-container/project-container.component.html
- api/test/project-plan.e2e-spec.ts
Project Management is a core feature of Traduora, providing the foundational structure for organizing translation work. A "Project" acts as a container for all related translation data, including terms, locales, translations, and team members. This feature allows users to create, view, update, and delete projects, manage their settings, and see high-level statistics.
The system is architected with a clear separation between the Angular frontend (webapp) and the NestJS backend (api). The frontend uses Ngxs for state management to handle project data, while the backend provides a RESTful API for all project-related operations. All interactions are authenticated and authorized based on user roles within a project.
Backend API
The backend exposes a set of REST endpoints for managing projects, handled by the ProjectController. All endpoints require authentication.
Sources: api/src/controllers/project.controller.ts
API Endpoints
The following table summarizes the available endpoints for project management.
| Method | Path | Operation Summary | Success Response |
|---|---|---|---|
GET | /api/v1/projects | List all projects the user is a member of. | 200 OK |
POST | /api/v1/projects | Create a new project. | 201 Created |
GET | /api/v1/projects/:id | Get a specific project by its ID. | 200 OK |
PATCH | /api/v1/projects/:id | Update a project's name or description. | 200 OK |
DELETE | /api/v1/projects/:id | Delete a project. | 204 No Content |
Sources: api/src/controllers/project.controller.ts:18-118, api/test/project.e2e-spec.ts
Data Transfer Objects (DTOs)
Communication with the project endpoints relies on specific DTOs for requests and responses.
Request DTOs
| DTO | Fields | Description |
|---|---|---|
CreateProjectRequest | name: string, description?: string | Used for POST /api/v1/projects. |
UpdateProjectRequest | name?: string, description?: string | Used for PATCH /api/v1/projects/:id. |
Sources: api/src/domain/http.ts:468-492
Response DTO
The primary response object for project-related endpoints is ProjectDTO.
| Field | Type | Description |
|---|---|---|
id | string | The unique identifier of the project. |
name | string | The name of the project. |
description | string | A short description of the project. |
localesCount | number | The number of locales in the project. |
termsCount | number | The number of terms in the project. |
role | ProjectRole | The role of the requesting user in the project. |
date | AccessDatesDTO | Creation and modification timestamps. |
Sources: api/src/domain/http.ts:90-106
The diagram below shows the structure of the main project-related DTOs.
Frontend Architecture
The frontend implementation for project management is contained within the ProjectsModule. This module defines the components, services, and state management logic for all project-related user interactions.
Sources: webapp/src/app/projects/projects.module.ts
Routing and Components
The ProjectsModule configures the routes for displaying the project list and the detailed view for a single project.
This diagram illustrates the routing structure within the ProjectsModule.
Sources: webapp/src/app/projects/projects.module.ts:39-61
Key components involved in project management include:
ProjectListComponent: Displays a list of all projects the user belongs to. It also hosts theNewProjectComponent.NewProjectComponent: A modal dialog for creating a new project.ProjectContainerComponent: A wrapper component that provides the main navigation and layout for a single project view. It displays project stats like translation progress, term count, and locale count.ProjectSettingsComponent: Allows users with appropriate permissions to update project details (name, description) and delete the project.
Sources: webapp/src/app/projects/projects.module.ts:63-95, webapp/src/app/projects/components/project-container/project-container.component.html:13-26
State Management (Ngxs)
Project data on the client side is managed by ProjectsState using the Ngxs state management library. It handles fetching, creating, updating, and deleting projects, and stores the list of projects as well as the currently selected project.
Sources: webapp/src/app/projects/stores/projects.state.ts
State Model (ProjectsStateModel)
export interface ProjectsStateModel {
projects: Project[];
currentProject: Project | undefined;
currentProjectStats: ProjectStats | undefined;
isLoading: boolean;
errorMessage: string | undefined;
}
Sources: webapp/src/app/projects/stores/projects.state.ts:64-71
Key Actions
GetProjects: Fetches the list of projects from the API.CreateProject: Sends a request to create a new project.UpdateProject: Sends a request to update an existing project's details.DeleteProject: Sends a request to delete a project.SetCurrentProject: Fetches a single project's data and sets it as the active project in the state.RefreshProjectStats: Fetches the latest statistics for the current project.
Sources: webapp/src/app/projects/stores/projects.state.ts:16-59
Core Workflows
Project Creation Flow
The following sequence diagram illustrates the process of creating a new project.
Project Deletion Flow
This diagram shows the flow for deleting a project from the settings page.
Project Limits and Plans
The system imposes limits on the number of projects a user can create and the number of strings a project can contain.
- Projects per User: A user is limited to a maximum number of created projects, defined by
config.maxProjectsPerUser(e2e tests show this as 100). An attempt to create more results in a429 Too Many Requestserror. - Strings per Project: Each project is associated with a plan that defines the maximum number of strings (
maxStrings). The default plan allows 100 strings. The current usage is calculated asterms * locales. If an action (like importing terms or adding a locale) would exceed this limit, the API returns a402 Payment Requirederror.
The user can view their current plan and usage in the Project Settings UI.
Sources: api/src/controllers/project.controller.ts:52-54, api/test/project.e2e-spec.ts:150-188, api/test/project-plan.e2e-spec.ts:15-23, 150-161, webapp/src/app/projects/components/project-settings/project-settings.component.html:48-59