> ## 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.

# Vehicle Fleet Management

> Adding vehicles, managing photos, tracking status, and per-vehicle profitability

# Vehicle Fleet Management

The Vehicles page lets you manage your entire fleet. Vehicles can be added manually or imported from Turo data, and each vehicle has a detail page showing photos, status, and financial performance.

## Adding Vehicles

<Accordion title="Auto-creation from CSV Import">
  When you import a Trip Earnings CSV, any new vehicle names that don't match existing records are automatically created. The vehicle is linked to future trips by name matching.
</Accordion>

<Accordion title="Manual Add">
  Use the `AddVehicleModal` to enter vehicle details: year, make, model, VIN, license plate, and status. VIN decoding is supported to auto-fill make/model/year.
</Accordion>

## Vehicle Detail Page

Each vehicle has a dedicated page at `/vehicles/[id]` showing:

* **Photo gallery** — Up to 15 photos managed via `PhotoUploader`
* **Vehicle info** — Year, make, model, VIN, license plate, status
* **Financial summary** — Earnings, expenses, profit, and margin for that vehicle
* **Trip history** — All trips for the vehicle with the same filtering as the main bookings page
* **Documents** — Associated documents (registration, insurance, etc.)

## Photo Management

The `PhotoUploader` and `VehiclePhotoSection` components handle:

* Upload up to 15 photos per vehicle
* Drag-and-drop reordering
* Set a primary photo (used as thumbnail across the app)
* Delete individual photos
* Photos are stored in Supabase Storage

## Status Lifecycle

Vehicles follow this status progression:

```
active → inactive → sold → deleted (soft)
```

| Status     | Meaning                                                  |
| ---------- | -------------------------------------------------------- |
| `active`   | Currently listed and available for rental                |
| `inactive` | Temporarily unlisted (maintenance, seasonal, etc.)       |
| `sold`     | Vehicle has been sold, retained for historical reporting |
| `deleted`  | Soft-deleted with confirmation via `DeleteVehicleDialog` |

<Warning>
  Deleting a vehicle is a soft delete. The record is retained for historical trip and financial data integrity. Deleted vehicles are hidden from active views but still appear in reports.
</Warning>

## Depreciation Tracking

The `DepreciationWidget` on the vehicle detail page shows estimated depreciation based on vehicle age and usage, helping hosts understand true cost of ownership.

## Key Components

| Component             | Purpose                              |
| --------------------- | ------------------------------------ |
| `AddVehicleModal`     | Form for manually adding a vehicle   |
| `PhotoUploader`       | Upload and manage vehicle photos     |
| `VehiclePhotoSection` | Photo gallery display on detail page |
| `DeleteVehicleDialog` | Confirmation dialog for soft delete  |
| `DepreciationWidget`  | Depreciation estimate display        |

## Data Layer

Vehicle CRUD operations are in `src/lib/db/index.ts`. The `useVehicles` hook (`src/hooks/useVehicles.ts`) provides fetching, creation, update, and delete. Photo operations use `src/hooks/useVehiclePhotos.ts` backed by `src/lib/db/storage.ts`.
