Skip to content

Feat: Generación rápida de combinaciones #68

Description

@IvanM9

Generation Flow (POST /api/combinations/generate-quick)

┌─────────────┐
│   Client    │
└──────┬──────┘
       │ POST { occasion: "wedding reception" }
       ▼
┌─────────────────────────────────┐
│  QuickGenerateCombinationDto    │ ← class-validator
│  - occasion: "wedding reception"│
│  - requestAlternative: false    │
└──────┬──────────────────────────┘
       │
       ▼
┌─────────────────────────────────┐
│  CombinationsService            │
│  .generateQuickCombination()    │
└──────┬──────────────────────────┘
       │
       ├─→ Check user wardrobe count (≥5 items?) → Throw error if insufficient
       │
       ├─→ Retrieve GenerationSession from cache (if requestAlternative=true)
       │
       ├─→ Query WardrobeItem (filter by userId, status=true, exclude previous IDs)
       │   └─→ Apply season pre-filtering if wardrobe > 100 items
       │
       ├─→ Call AiService.agent() with prompt + Zod schema
       │   └─→ Retry once on failure (2-second delay)
       │
       ├─→ Validate AI response (3-10 items, valid IDs)
       │
       ├─→ Fetch full item details + images from DB
       │
       ├─→ Update/create GenerationSession in cache
       │
       └─→ Return QuickGenerationResponse
           │
           ▼
       ┌─────────────────────────────────┐
       │  QuickGenerationResponse        │
       │  - outfit: [...]                │
       │  - explanation: "..."           │
       │  - occasion: "wedding reception"│
       └─────────────────────────────────┘

Save Flow (Reuses existing POST /api/combinations/save)

┌─────────────┐
│   Client    │
└──────┬──────┘
       │ POST { name: "...", items: [...], explanation: "..." }
       ▼
┌─────────────────────────────────┐
│  SaveCombinationDto (existing)  │
│  + isAIGenerated: true          │ ← New field added to DTO
│  + occasions: ["..."]           │ ← New field added to DTO
│  + aiDescription: "..."         │ ← Existing field
└──────┬──────────────────────────┘
       │
       ▼
┌─────────────────────────────────┐
│  CombinationsService.save()     │
└──────┬──────────────────────────┘
       │
       ├─→ Create Combination record (isAIGenerated=true, occasions=[...], aiDescription=...)
       │
       ├─→ Create CombinationItem records (one per outfit item)
       │
       ├─→ Delete GenerationSession from cache (FR-011b - session cleared on save)
       │
       └─→ Return saved combination with ID

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions