Перейти к содержимому

Project API Design

Project API — сервис управления заказами клиентов (Customer) на фриланс-маркетплейсе CrewsForge. Первая итерация: CRUD проектов для Customer. Отклики Employee — в следующей итерации.

  • ProjectStatus: DRAFT, PUBLISHED, HIRING, IN_PROGRESS, REVIEW, COMPLETED, CANCELLED, DISPUTED
  • ProjectBudgetType: FIXED, HOURLY
  • ProjectCategoryType: WEB_DEVELOPMENT, MOBILE_DEVELOPMENT, DESIGN, MARKETING, COPYWRITING, DATA_SCIENCE, DEV_OPS, QA_TESTING, OTHER
FieldTypeNotes
idUUIDPK, auto-generated
titleStringRequired
descriptionStringRequired
categoryProjectCategoryTypeRequired
statusProjectStatusDefault: DRAFT
budgetTypeProjectBudgetTypeRequired (FIXED / HOURLY)
budgetMinDecimal(12,2)?Optional
budgetMaxDecimal(12,2)?Optional
currencyString(3)Default: “USD”
deadlineDateTime?Optional
customerIdUUIDFK -> Customer, onDelete: Cascade
createdAtDateTimeAuto
updatedAtDateTimeAuto

Indexes: customerId, status, category.

All endpoints require Customer authentication. Prefix: /api/v1/customers/projects.

MethodPathDescription
POST/api/v1/customers/projectsCreate project (DRAFT)
GET/api/v1/customers/projectsList own projects (pagination, status filter)
GET/api/v1/customers/projects/:idGet own project by ID
PATCH/api/v1/customers/projects/:idUpdate project (only DRAFT)
PATCH/api/v1/customers/projects/:id/statusChange project status (validated transitions)
DELETE/api/v1/customers/projects/:idDelete project (only DRAFT)
DRAFT -> PUBLISHED
PUBLISHED -> HIRING, CANCELLED
HIRING -> IN_PROGRESS, CANCELLED
IN_PROGRESS -> REVIEW, CANCELLED, DISPUTED
REVIEW -> COMPLETED, IN_PROGRESS
DISPUTED -> CANCELLED, IN_PROGRESS

Single ProjectModule following existing patterns (auth-api, user-api):

  • Controller -> Service -> Repository
  • DTOs with class-validator / class-transformer
  • Prisma transactions via ClsPluginTransactional
libs/apis/providers/project-api/
├── data-access/
│ └── src/lib/
│ ├── dtos/
│ │ ├── project-create.dto.ts
│ │ ├── project-update.dto.ts
│ │ ├── project-update-status.dto.ts
│ │ ├── project-list-query.dto.ts
│ │ ├── project-response.dto.ts
│ │ └── index.ts
│ ├── constants/
│ │ ├── project-status-transitions.ts
│ │ └── index.ts
│ └── index.ts
└── features/
└── project/
└── src/lib/
├── project.module.ts
├── project.controller.ts
├── project.service.ts
├── project.repository.ts
└── index.ts
  • apps/core-api/prisma/schema.prisma — add Project model + enums
  • apps/project-api/src/app/app.module.ts — import ProjectModule
  • tsconfig.base.json — add path aliases for project-api libs
  • package.json — add dev:project-api / build:project-api scripts
  • Only Customer can create, read, update, delete own projects
  • Customer can only see own projects (filtered by customerId from JWT)
  • Update/Delete restricted to DRAFT status only
  • Employee proposals/bids system
  • Employee project browsing with search/filters
  • Project attachments
  • Milestones