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

# Dashboard & KPIs

> Overview of the main dashboard, KPI definitions, calculation formulas, and revenue stream breakdowns

# Dashboard & KPIs

The main dashboard provides a real-time snapshot of your fleet's financial health, trip performance, and revenue composition. All metrics update based on the selected date range.

## KPI Categories

The dashboard organizes metrics into four groups: **Financial**, **Trip**, **Fleet**, and **Revenue Streams**.

### Financial KPIs

| Metric         | Formula                                        | Description                               |
| -------------- | ---------------------------------------------- | ----------------------------------------- |
| Host Earnings  | `SUM(total_earnings)` from completed trips     | Total income received from Turo           |
| Total Expenses | `SUM(expenses.amount) + SUM(maintenance.cost)` | All tracked costs including maintenance   |
| Net Profit     | `Host Earnings - Total Expenses`               | Bottom-line profitability                 |
| Profit Margin  | `(Net Profit / Host Earnings) * 100`           | Percentage of earnings retained as profit |

### Trip KPIs

| Metric            | Formula                                         | Description                   |
| ----------------- | ----------------------------------------------- | ----------------------------- |
| Trip Count        | Count of completed trips with positive earnings | Total completed rentals       |
| Avg Trip Earnings | `Host Earnings / Trip Count`                    | Revenue per trip              |
| Avg Trip Duration | `SUM(trip_days) / Trip Count`                   | Average rental length in days |
| Total Trip Days   | `SUM(trip_days)`                                | Cumulative rental days        |

### Fleet KPIs

| Metric              | Formula                                                            | Description                        |
| ------------------- | ------------------------------------------------------------------ | ---------------------------------- |
| Active Vehicles     | Count of vehicles with `status = 'active'`                         | Currently rentable fleet size      |
| Fleet Utilization   | `Total Rented Days / Total Rentable Days * 100`                    | How often your fleet is booked     |
| Avg Daily Rate      | `Vehicle Earnings / Actual Rented Days` (averaged across vehicles) | Revenue per rented day             |
| Active Vehicle Rate | `Active Vehicles / Vehicles With Trips * 100`                      | Percentage of fleet that is active |

<Info>
  Fleet utilization is calculated per-vehicle from first trip date to today, then aggregated. See [Utilization Calculation](/business-rules/utilization-calculation) for details.
</Info>

### Revenue Streams

Each completed trip's earnings are decomposed into these streams:

| Stream           | Source Fields                                     |
| ---------------- | ------------------------------------------------- |
| Net Rental Price | `trip_price` minus all discounts, fees, and taxes |
| Boost            | `boost_price`                                     |
| Delivery         | `delivery`                                        |
| Extras           | `extras`                                          |
| Tolls & Tickets  | `tolls_and_tickets`                               |
| Late Fees        | `late_fee + improper_return_fee`                  |
| Additional Usage | `additional_usage + excess_distance`              |
| Cleaning         | `cleaning + smoking`                              |
| Gas              | `gas_reimbursement + gas_fee`                     |
| EV Charging      | `on_trip_ev_charging + post_trip_ev_charging`     |

Zero-value streams are automatically hidden from the chart.

## Monthly Trends

The dashboard includes a monthly chart showing earnings, projected earnings (from upcoming bookings), expenses, and profit over time. Upcoming and in-progress trips appear as projected values for their end-date month.

## Architecture

All KPI calculations are **pure functions** with no side effects, located in `src/lib/kpi/calculations.ts`. Data fetching is separated in `src/lib/kpi/queries.ts`. The `useKPIs` hook in `src/hooks/useKPIs.ts` orchestrates fetching and calculation.

```
useKPIs hook → fetchKPIData() → calculateDashboardKPIs() → render
```

The main entry point is `calculateDashboardKPIs()`, which calls each sub-calculator and returns a single `DashboardKPIs` object containing all metric groups, monthly data, and recent trips.
