Skip to content

services

Orchestrate recipe and authentication operations.

AuthService

AuthService(
    google_verifier: GoogleTokenVerifierPort,
    jwt_token: JwtTokenPort,
    user_repository: UserRepositoryPort,
)

Service for authentication: Google login → find/create user → issue JWT.

login_with_google

login_with_google(id_token: str) -> str

Verify Google ID token, find or create the user, return a JWT.

RecipeExportService

RecipeExportService(
    repository: RecipeRepositoryPort,
    word_exporter: WordExporterPort,
    markdown_exporter: MarkdownExporterPort,
)

Service for exporting recipes to different formats.

export_recipes_to_markdown

export_recipes_to_markdown(user_id: UUID) -> bytes

Export the user's recipes as a ZIP archive containing Markdown and images.

export_recipes_to_word

export_recipes_to_word(user_id: UUID) -> bytes

Export the user's recipes as Word binary format (in-memory).

RecipeImportService

RecipeImportService(instagram_parser: InstagramParserPort)

Service for importing recipes from external sources.

parse_instagram

parse_instagram(data: InstagramResponse) -> list[ParsedRecipe]

Parse Instagram data using the injected parser adapter.

RecipeManagementService

RecipeManagementService(
    repository: RecipeRepositoryPort,
    image_storage: ImageStoragePort,
    share_repo: RecipeShareRepositoryPort | None = None,
)

Service for recipe creation, retrieval, and search operations.

add_recipe_image

add_recipe_image(recipe_id: UUID, user_id: UUID, content: bytes, filename: str) -> UUID

Add an image to a recipe. Requires owner or editor role.

create_recipe

create_recipe(data: RecipeCreate, owner_id: UUID) -> RecipeEntity

Create a new recipe with ingredients, images, and sources.

create_recipes

create_recipes(data: list[RecipeCreate], owner_id: UUID) -> list[RecipeEntity]

Create multiple recipes in a single atomic transaction.

delete_recipe_image

delete_recipe_image(image_id: UUID, user_id: UUID) -> bool

Delete an image from storage and database.

get_recipe_by_id

get_recipe_by_id(recipe_id: UUID, user_id: UUID) -> RecipeEntity | None

Retrieve a recipe by ID, scoped to the given user.

get_recipe_image

get_recipe_image(image_id: UUID, user_id: UUID) -> ImageResponse | None

Retrieve image bytes from storage by image ID, only if owned by user.

search_recipes

search_recipes(
    user_id: UUID,
    recipe_id: UUID | None = None,
    title: str | None = None,
    category: str | None = None,
    is_veggie: bool | None = None,
    season: str | None = None,
    limit: int | None = None,
    offset: int = 0,
    ownership: str | None = None,
) -> PaginatedResult

Search/filter recipes via the repository abstraction, visible to user.

RecipeShareService

RecipeShareService(
    share_repo: RecipeShareRepositoryPort,
    user_repo: UserRepositoryPort,
    recipe_repo: RecipeRepositoryPort,
)

Service for sharing recipes between users.

get_recipe_shares

get_recipe_shares(recipe_id: UUID, user_id: UUID) -> list[RecipeShareEntity]

Only the owner can view all collaborators.

leave_recipe

leave_recipe(recipe_id: UUID, user_id: UUID) -> bool

Remove yourself from a shared recipe by recipe ID.

share_recipe

share_recipe(
    recipe_id: UUID, email: str, role: ShareRole, user_id: UUID
) -> RecipeShareEntity

Share a recipe with another user. Only the owner can share.