# Floor Plan Generator

Generate floor plan visualizations from sketches.

## Description

Upload a floor plan sketch and select a view type to generate a rendered floor plan visualization.

## Authentication

**Required**: x402 payment

This endpoint requires payment via the x402 protocol. See the [Setup](./setup.md) for setup instructions.

## Request

**Endpoint**: `POST /api/floor-plan/generate`

**Content-Type**: `multipart/form-data`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| image | file | Yes | Floor plan sketch (JPG, PNG, or WebP, max 10MB) |
| styleDescription | string | No | Style description for the rendering |
| viewType | string | No | View perspective: `2d-top-down` (default) or `3d-birds-eye` |

## Response

**200 OK**

```json
{
  "imageUrl": "/outputs/uuid-here.png"
}
```

| Field | Type | Description |
|-------|------|-------------|
| imageUrl | string | Path to the generated floor plan |

## Error Codes

| Status | Code | Description |
|--------|------|-------------|
| 400 | VALIDATION_ERROR | Invalid request parameters |
| 402 | PAYMENT_REQUIRED | x402 payment not completed |
| 413 | FILE_TOO_LARGE | File exceeds 10MB limit |
| 415 | UNSUPPORTED_FORMAT | Invalid file type (must be JPG, PNG, or WebP) |
| 422 | INVALID_IMAGE_DATA | Unable to process image |
| 500 | INTERNAL_ERROR | AI generation failed |
| 504 | AI_GENERATION_TIMEOUT | AI request timed out |

## Example

```bash
curl -X POST https://ps.codejar.net/api/floor-plan/generate \
  -F "image=@sketch.jpg" \
  -F "styleDescription=Modern minimalist" \
  -F "viewType=2d-top-down"
```

**Response:**
```json
{
  "imageUrl": "/outputs/550e8400-e29b-41d4-a716-446655440004.png"
}
```
