Skip to main content

Folder Structure

TuroDashboard/
├── src/
│   ├── app/                          # Next.js App Router
│   │   ├── (auth)/                   # Auth routes (login, signup, reset-password)
│   │   ├── (dashboard)/              # Protected dashboard routes
│   │   │   ├── dashboard/            # Main KPI dashboard
│   │   │   ├── bookings/             # Trip management + calendar
│   │   │   ├── vehicles/             # Fleet management
│   │   │   ├── vehicles/[id]/        # Vehicle detail
│   │   │   ├── investors/            # Investor hub
│   │   │   ├── investors/[id]/       # Investor detail (largest page)
│   │   │   ├── expenses/             # Expense tracking
│   │   │   ├── other-income/         # Miscellaneous income
│   │   │   ├── documents/            # Document management
│   │   │   ├── data-sources/         # CSV import
│   │   │   ├── reports/              # Financial reports
│   │   │   ├── fleet-pages/          # Fleet showcase editor
│   │   │   ├── settings/             # User settings (8 tabs)
│   │   │   ├── notifications/        # Notification center
│   │   │   └── help/                 # Help center
│   │   ├── api/                      # API routes (16 endpoints)
│   │   ├── fleet/[slug]/             # Public fleet showcase page
│   │   ├── p/[token]/                # Investor portal (token auth)
│   │   └── r/[token]/                # Investor report link
│   │
│   ├── components/                   # React components (~200+)
│   │   ├── ui/                       # shadcn/ui base (16 components)
│   │   ├── layout/                   # Sidebar
│   │   ├── auth/                     # AuthProvider
│   │   ├── dashboard/                # StatCard, FileUploader
│   │   ├── bookings/                 # 24 trip/booking components
│   │   ├── vehicles/                 # 6 vehicle components
│   │   ├── investors/                # 63 investor components (largest)
│   │   │   └── agreements/           # 6 agreement components
│   │   ├── expenses/                 # Expense modals
│   │   ├── documents/                # Document management
│   │   ├── data-sources/             # 11 import components
│   │   ├── fleet-pages/              # 15 fleet page components
│   │   ├── reports/                  # 22 report components
│   │   ├── settings/                 # 18 settings components
│   │   ├── billing/                  # 13 billing components
│   │   ├── charts/                   # Chart components
│   │   ├── portal/                   # Investor portal views
│   │   ├── misc-income/              # Income components
│   │   └── notifications/            # Notification boundary
│   │
│   ├── hooks/                        # 28 custom React hooks
│   │
│   ├── lib/
│   │   ├── db/                       # Database operations (50+ files)
│   │   │   ├── _client.ts            # Supabase client + getCurrentUserId()
│   │   │   ├── schema/               # TypeScript types (7 files, 2750+ lines)
│   │   │   ├── import-service.ts     # CSV parsing + import
│   │   │   ├── toll-transactions.ts  # Toll CSV import + reconciliation
│   │   │   └── ...                   # Per-table operation modules
│   │   ├── kpi/                      # KPI calculation module
│   │   │   ├── calculations.ts       # Pure functions (869 lines)
│   │   │   ├── queries.ts            # Data fetching
│   │   │   └── types.ts              # KPI type definitions
│   │   ├── calculations/             # Business calculations
│   │   │   ├── investorEarnings.ts   # Three-pool expense model
│   │   │   └── vehicleRevenue.ts     # Revenue adjustment logic
│   │   ├── documents/                # PDF generation (agreements, 1099)
│   │   ├── supabase/                 # Client/server Supabase setup
│   │   ├── tolls/                    # Toll scrapers + matching
│   │   ├── validation/               # Input validation
│   │   ├── categories/               # Expense category system
│   │   ├── audit/                    # Activity logging
│   │   ├── reports/                  # Report data fetching
│   │   ├── formatters.ts             # Currency, date formatting
│   │   ├── date-utils.ts             # Date manipulation
│   │   ├── depreciation.ts           # Vehicle depreciation calc
│   │   └── utils.ts                  # cn() and general utils
│   │
│   └── __tests__/                    # 60+ test files
│       ├── unit/                     # Vitest unit tests
│       │   ├── components/           # Component tests (40+)
│       │   ├── hooks/                # Hook tests (8)
│       │   └── lib/                  # Library tests (15)
│       ├── integration/              # Integration tests
│       ├── mocks/                    # Supabase + data mocks
│       └── kpi/                      # KPI calculation tests

├── chrome-extension/                 # Chrome extension source
├── lambda/                           # AWS Lambda functions (toll sync)
├── supabase/                         # Migration SQL files (24+)
├── e2e/                              # Playwright E2E tests
├── scripts/                          # DB scripts and migrations
└── docs/                             # This documentation

Key Conventions

  • Page routes use the App Router file convention (page.tsx, layout.tsx)
  • Auth routes are in (auth)/ group — no sidebar, public access
  • Dashboard routes are in (dashboard)/ group — sidebar, auth required
  • Components are organized by feature domain, not by type
  • Database operations are one file per table/domain in src/lib/db/
  • Hooks are one file per feature in src/hooks/