Documentation Index
Fetch the complete documentation index at: https://dhanurgo.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Coding Conventions
This page covers the coding standards and conventions used throughout the HostMetrics codebase. All contributors should follow these rules to maintain consistency.File Naming
| Type | Convention | Example |
|---|---|---|
| Components | PascalCase.tsx | StatCard.tsx, TripTable.tsx |
| Hooks | useCamelCase.ts | useBookings.ts, useKPIs.ts |
| Utilities | camelCase.ts | dateUtils.ts, formatters.ts |
| Database modules | camelCase.ts or kebab-case.ts | partners.ts, import-service.ts |
| Test files | Name.test.tsx or name.test.ts | StatCard.test.tsx, useKPIs.test.ts |
Import Path Alias
All imports use the@/ alias which maps to src/:
Client vs Server Components
Next.js App Router defaults to server components. Add the'use client' directive only for interactive components that need browser APIs, hooks, or event handlers:
Conditional Class Merging
Use thecn() utility from @/lib/utils for conditional Tailwind classes. This wraps clsx and tailwind-merge:
TypeScript Strict Mode
The project uses TypeScript in strict mode. All new code must:- Define explicit types for function parameters and return values
- Avoid
any— useunknownwith type narrowing when the type is truly unknown - Define interfaces/types in
src/lib/db/schema/for database entities - Use generics where appropriate for reusable utilities
Component Composition
Prefer composition over prop drilling. Pass children or render props instead of threading data through many layers:State Management
HostMetrics does not use a global state library. State is managed with:- React hooks (
useState,useReducer) for local component state - React Context (
useAuth, etc.) for cross-cutting concerns like auth - Custom hooks (
useKPIs,useBookings, etc.) for data fetching and business logic - Supabase Realtime for live data updates where needed
Database Access Rules
All database operations live insrc/lib/db/. Every query must filter by user_id to enforce row-level data isolation:
src/lib/db/ module or a hook in src/hooks/.
Code Organization Summary
| What | Where |
|---|---|
| Page routes | src/app/(dashboard)/ or src/app/(auth)/ |
| React components | src/components/{feature}/ |
| Base UI primitives | src/components/ui/ |
| Custom hooks | src/hooks/ |
| Database operations | src/lib/db/ |
| Schema / types | src/lib/db/schema/ |
| Utility functions | src/lib/ |
| Tests | src/__tests__/ |
Error Handling
Database and API errors should be caught and surfaced with meaningful messages:error state so components can render appropriate error UI.