Project API Design
Overview
Заголовок раздела «Overview»Project API — сервис управления заказами клиентов (Customer) на фриланс-маркетплейсе CrewsForge. Первая итерация: CRUD проектов для Customer. Отклики Employee — в следующей итерации.
Data Model
Заголовок раздела «Data Model»- 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
Project Model
Заголовок раздела «Project Model»| Field | Type | Notes |
|---|---|---|
| id | UUID | PK, auto-generated |
| title | String | Required |
| description | String | Required |
| category | ProjectCategoryType | Required |
| status | ProjectStatus | Default: DRAFT |
| budgetType | ProjectBudgetType | Required (FIXED / HOURLY) |
| budgetMin | Decimal(12,2)? | Optional |
| budgetMax | Decimal(12,2)? | Optional |
| currency | String(3) | Default: “USD” |
| deadline | DateTime? | Optional |
| customerId | UUID | FK -> Customer, onDelete: Cascade |
| createdAt | DateTime | Auto |
| updatedAt | DateTime | Auto |
Indexes: customerId, status, category.
API Endpoints
Заголовок раздела «API Endpoints»All endpoints require Customer authentication. Prefix: /api/v1/customers/projects.
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/customers/projects | Create project (DRAFT) |
| GET | /api/v1/customers/projects | List own projects (pagination, status filter) |
| GET | /api/v1/customers/projects/:id | Get own project by ID |
| PATCH | /api/v1/customers/projects/:id | Update project (only DRAFT) |
| PATCH | /api/v1/customers/projects/:id/status | Change project status (validated transitions) |
| DELETE | /api/v1/customers/projects/:id | Delete project (only DRAFT) |
Status Transitions
Заголовок раздела «Status Transitions»DRAFT -> PUBLISHEDPUBLISHED -> HIRING, CANCELLEDHIRING -> IN_PROGRESS, CANCELLEDIN_PROGRESS -> REVIEW, CANCELLED, DISPUTEDREVIEW -> COMPLETED, IN_PROGRESSDISPUTED -> CANCELLED, IN_PROGRESSArchitecture
Заголовок раздела «Architecture»Single ProjectModule following existing patterns (auth-api, user-api):
- Controller -> Service -> Repository
- DTOs with class-validator / class-transformer
- Prisma transactions via ClsPluginTransactional
File Structure
Заголовок раздела «File Structure»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.tsChanges to Existing Files
Заголовок раздела «Changes to Existing Files»apps/core-api/prisma/schema.prisma— add Project model + enumsapps/project-api/src/app/app.module.ts— import ProjectModuletsconfig.base.json— add path aliases for project-api libspackage.json— add dev:project-api / build:project-api scripts
Access Control
Заголовок раздела «Access Control»- 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
Future Iterations
Заголовок раздела «Future Iterations»- Employee proposals/bids system
- Employee project browsing with search/filters
- Project attachments
- Milestones