> ## Documentation Index
> Fetch the complete documentation index at: https://dhanurgo.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Document Management

> Uploading fleet documents, tracking expiry dates, and monitoring fleet document health

# Document Management

The Documents page provides centralized storage for all fleet-related paperwork. Track registrations, insurance policies, inspections, and 40+ other document types with expiry alerts and health scoring.

## Uploading Documents

Use `DocumentUploadDialog` to upload a document with:

* **File** — PDF, image, or other document file (stored in Supabase Storage)
* **Document type** — Selected from 40+ predefined types
* **Vehicle** — Associate with a specific vehicle (optional)
* **Expiry date** — When the document expires (optional but recommended)
* **Notes** — Free-text description

## Document Types

Documents are organized into categories:

| Category         | Example Types                                        |
| ---------------- | ---------------------------------------------------- |
| **Registration** | Vehicle registration, title, temporary plates        |
| **Insurance**    | Liability policy, comprehensive, gap insurance       |
| **Inspection**   | State inspection, emissions test, safety check       |
| **Maintenance**  | Service records, repair receipts, warranty docs      |
| **Legal**        | Lease agreement, lien release, power of attorney     |
| **Tax**          | 1099 forms, depreciation schedules, business license |
| **Rental**       | Turo listing agreement, guest damage claims          |
| **Other**        | Miscellaneous documentation                          |

Over 40 specific document types are available across these categories.

## Document Health Score

The `FleetHealthBar` component calculates a **health score** as a percentage:

```
Health Score = (Current Required Documents / Total Required Documents) * 100
```

A document is considered "current" if it exists and has not expired. Required document types (registration, insurance, inspection) are checked per vehicle.

<Warning>
  Documents approaching their expiry date trigger alerts in the notification center. Keep your fleet health score high by uploading renewals before expiry.
</Warning>

## Expiry Tracking

Each document can have an expiry date. The system provides:

* **Visual indicators** — Color-coded badges showing valid, expiring soon, or expired status
* **Notification alerts** — Upcoming expirations appear in the notification center
* **Health impact** — Expired documents lower the fleet health score

## Document Cards

`DocumentCard` displays each document with:

* Document type icon and label
* Associated vehicle name
* Upload date and expiry date
* Quick actions: download, view, delete
* Expiry status badge (valid / expiring / expired)

## Key Components

| Component              | Purpose                                    |
| ---------------------- | ------------------------------------------ |
| `DocumentUploadDialog` | Upload form with type selection and expiry |
| `FleetHealthBar`       | Fleet-wide document health percentage      |
| `DocumentCard`         | Individual document display with actions   |

## Data Layer

Documents are stored in the `documents` table with files in Supabase Storage. Operations are in `src/lib/db/documents.ts`. The `useDocuments` hook (`src/hooks/useDocuments.ts`) handles fetching and CRUD.
