flc/crewboard

Crewboard - team task board (boards, lists, cards, roles, history, drag and drop, MCP, AI extras). FastAPI + DataK3 + appid + Models.

A remix template · 1 remixes · Remix flc/crewboard

app/boards/application/ports.py

"""What the use cases need from the outside world. infrastructure/ provides it; tests fake it."""
from typing import Optional, Protocol

from boards.domain.model import Board, Card


class Taken(Exception):
    """A plain INSERT lost the race for its key (SQLSTATE 23505). The caller picks another key."""


class BoardRepository(Protocol):
    def get(self, board_id: str) -> Optional[Board]: ...
    def boards_for(self, email: str) -> list: ...
    def insert_board(self, board: Board) -> None: ...          # raises Taken
    def save_board(self, board: Board) -> None: ...
    def save_members(self, board: Board, removed: tuple = ()) -> None: ...
    def get_card(self, card_id: str) -> Optional[Card]: ...
    def cards_on(self, board_id: str) -> list: ...
    def cards_on_boards(self, board_ids: list) -> list: ...
    def max_number(self, board_id: str) -> int: ...
    def insert_card(self, card: Card) -> None: ...             # raises Taken
    def update_card(self, card: Card, expected_version: int) -> bool: ...  # False if stale
    def log(self, board_id: str, card_id: Optional[str], actor: str, action: str,
            changes: Optional[dict] = None) -> None: ...
    def activity(self, board_id: str, card_id: Optional[str] = None, limit: int = 50) -> list: ...


class Assistant(Protocol):
    def checklist(self, card_title: str, description: str = "") -> list: ...
    def summary(self, facts: str) -> str: ...
    def embed(self, texts: list) -> list: ...