Create Project entity and CRUD operations #23

Closed
opened 2025-12-29 23:47:12 +00:00 by cardosofelipe · 0 comments

Description

Implement the Project entity and all CRUD operations.

Requirements

Entity Fields

class Project(Base):
    id: UUID
    name: str
    slug: str  # URL-friendly identifier
    description: Optional[str]
    autonomy_level: AutonomyLevel  # FULL_CONTROL, MILESTONE, AUTONOMOUS
    status: ProjectStatus  # ACTIVE, PAUSED, COMPLETED, ARCHIVED
    settings: dict  # JSON field for project-specific settings
    owner_id: UUID  # FK to User

    # Relationships
    sprints: List[Sprint]
    agent_instances: List[AgentInstance]
    issues: List[Issue]

    # Timestamps
    created_at: datetime
    updated_at: datetime

Enums

class AutonomyLevel(str, Enum):
    FULL_CONTROL = "full_control"  # Approve every action
    MILESTONE = "milestone"        # Approve sprint boundaries
    AUTONOMOUS = "autonomous"      # Only major decisions

class ProjectStatus(str, Enum):
    ACTIVE = "active"
    PAUSED = "paused"
    COMPLETED = "completed"
    ARCHIVED = "archived"

CRUD Operations

  • create(db, obj_in: ProjectCreate) -> Project
  • get(db, id: UUID) -> Optional[Project]
  • get_by_slug(db, slug: str) -> Optional[Project]
  • get_multi_by_owner(db, owner_id: UUID) -> List[Project]
  • update(db, db_obj: Project, obj_in: ProjectUpdate) -> Project
  • delete(db, id: UUID) -> None

Tests

  • Unit tests for all CRUD operations
  • Test slug uniqueness
  • Test owner relationship
  • Test status transitions

Acceptance Criteria

  • Model defined with all fields
  • Migration created and applied
  • CRUD class with all methods
  • Pydantic schemas (Create, Update, InDB, Response)
  • Unit tests with >90% coverage
  • Async patterns (SQLAlchemy 2.0 style)

Technical Notes

  • Reference: ADR-009 (Issue synchronization architecture)
  • Follow existing CRUD patterns from PragmaStack
  • Use custom exceptions from app.core.exceptions

Assignable To

backend-engineer agent

## Description Implement the Project entity and all CRUD operations. ## Requirements ### Entity Fields ```python class Project(Base): id: UUID name: str slug: str # URL-friendly identifier description: Optional[str] autonomy_level: AutonomyLevel # FULL_CONTROL, MILESTONE, AUTONOMOUS status: ProjectStatus # ACTIVE, PAUSED, COMPLETED, ARCHIVED settings: dict # JSON field for project-specific settings owner_id: UUID # FK to User # Relationships sprints: List[Sprint] agent_instances: List[AgentInstance] issues: List[Issue] # Timestamps created_at: datetime updated_at: datetime ``` ### Enums ```python class AutonomyLevel(str, Enum): FULL_CONTROL = "full_control" # Approve every action MILESTONE = "milestone" # Approve sprint boundaries AUTONOMOUS = "autonomous" # Only major decisions class ProjectStatus(str, Enum): ACTIVE = "active" PAUSED = "paused" COMPLETED = "completed" ARCHIVED = "archived" ``` ### CRUD Operations - `create(db, obj_in: ProjectCreate) -> Project` - `get(db, id: UUID) -> Optional[Project]` - `get_by_slug(db, slug: str) -> Optional[Project]` - `get_multi_by_owner(db, owner_id: UUID) -> List[Project]` - `update(db, db_obj: Project, obj_in: ProjectUpdate) -> Project` - `delete(db, id: UUID) -> None` ### Tests - Unit tests for all CRUD operations - Test slug uniqueness - Test owner relationship - Test status transitions ## Acceptance Criteria - [ ] Model defined with all fields - [ ] Migration created and applied - [ ] CRUD class with all methods - [ ] Pydantic schemas (Create, Update, InDB, Response) - [ ] Unit tests with >90% coverage - [ ] Async patterns (SQLAlchemy 2.0 style) ## Technical Notes - Reference: ADR-009 (Issue synchronization architecture) - Follow existing CRUD patterns from PragmaStack - Use custom exceptions from `app.core.exceptions` ## Assignable To backend-engineer agent
cardosofelipe added the backenddatabasephase-1 labels 2025-12-29 23:49:58 +00:00
Sign in to join this conversation.