# Task 005 — Import System

## Objective

Enable bulk import of processed Excel market data into companies, people, and contact points with validation and batch tracking.

## Scope

- Simple import (single sheet + column mapping JSON)
- Processed import (multi-sheet GPT format)
- APIs: detect, preview, execute, history
- Protected UI at `/imports`
- `docs/18-import-system.md`

**Out of scope:** Full visual column mapper, Campaign_Ready → leads, CRM list UIs.

## Requirements

1. Support `.xlsx`, `.xls`, `.csv` with configurable column mapping (simple).
2. Row-level errors do not abort entire batch (partial success).
3. Import history via `ImportLog`.
4. Authenticated access only.

## Files to create or modify

| Path | Action |
|------|--------|
| `docs/18-import-system.md` | Create |
| `src/types/import.ts`, `src/lib/normalize.ts` | Create |
| `src/server/services/*-import*.ts` | Create |
| `src/server/repositories/import.repository.ts` | Create |
| `src/app/api/imports/**` | Create |
| `src/app/imports/**` | Create |
| `docs/03`, `04`, `01`, `02`, `16`, `README` | Update |

## Acceptance criteria

- [x] Processed detect/preview/execute from multi-sheet workbook
- [x] Simple import with mapping JSON
- [x] ImportLog and Source created
- [x] Companies, People, ContactPoints, ServiceMatch, DataQuality, DuplicateReview
- [x] Bad rows do not crash import
- [x] `npm run build` and `npm run lint` pass
- [x] Documentation and task index updated

**Status:** Complete
