# SupplierPulse API v1

Base URL: `/api/v1`

## Authentication

All endpoints except `/api/v1/health` require a valid Supabase auth session (cookie-based).

## Response Format

Success: `{ "data": [...], "meta": { "page": 1, "limit": 25, "total": 100 } }`
Error: `{ "error": "message" }`

## Endpoints

### GET /api/v1/projects
List projects with pagination and filters.

**Query params:** `page` (default 1), `limit` (default 25, max 100), `status` (code), `type` (code)

### POST /api/v1/projects
Create a new project.

**Body:** `{ project_type_id: string, supplier_id: string, ... }`

### GET /api/v1/projects/:id
Get project detail with supplier and consultant data.

### PATCH /api/v1/projects/:id
Update project fields (partial update).

### DELETE /api/v1/projects/:id
Delete project.

### GET /api/v1/suppliers
Search suppliers (server-side, max 20 results).

**Query params:** `q` (search term, ilike on name/number/city)

### POST /api/v1/suppliers
Create a new supplier.

**Body:** `{ supplier_name: string, ... }`

### GET /api/v1/oee
List OEE records.

**Query params:** `line`, `year`, `week_from`, `week_to`, `page`, `limit`

### POST /api/v1/oee
Create an OEE record.

**Body:** `{ line_name: string, year: number, week_number: number, ... }`

### GET /api/v1/assignments
List assignments for a consultant or date range.

**Query params:** `consultant_id`, `date_from` (ISO date), `date_to` (ISO date)

### GET /api/v1/master-data
Get master data values by type code.

**Query params:** `type` (required, e.g. `KIFAG_AREA`), `active_only` (boolean, default false)

### GET /api/v1/health
No auth required. Returns system status.

**Response:**
```json
{
  "status": "healthy",
  "timestamp": "2026-04-03T12:00:00.000Z",
  "version": "1.0.0",
  "environment": "development"
}
```
