Context
Users should be able to favorite projects. This requires a new database table and API endpoints.
Database
New project_favorites table:
| Column |
Type |
Description |
| user_id |
text |
FK to user (from auth provider) |
| project_id |
UUID |
FK to projects.id |
| created_at |
timestamp |
When favorited |
| PK |
(user_id, project_id) |
Composite primary key |
API endpoints
POST /api/v1/projects/{projectId}/favorite — add to favorites (idempotent)
DELETE /api/v1/projects/{projectId}/favorite — remove from favorites
GET /api/v1/projects — include is_favorited: boolean in each project response item (for authenticated users)
Sorting
When returning project lists, favorited projects should sort to the top (within the existing sort order). Consider adding a sort query parameter or always sorting favorites first for authenticated users.
Related
Context
Users should be able to favorite projects. This requires a new database table and API endpoints.
Database
New
project_favoritestable:API endpoints
POST /api/v1/projects/{projectId}/favorite— add to favorites (idempotent)DELETE /api/v1/projects/{projectId}/favorite— remove from favoritesGET /api/v1/projects— includeis_favorited: booleanin each project response item (for authenticated users)Sorting
When returning project lists, favorited projects should sort to the top (within the existing sort order). Consider adding a
sortquery parameter or always sorting favorites first for authenticated users.Related