Skip to main content

Local Development Setup

How to set up the Client Portal development environment on your local machine.

Prerequisites

  • Node.js 18+ (or Bun as an alternative package manager)
  • Git for version control
  • Supabase CLI (npm install -g supabase) for edge function development and database migrations
  • Access to the 1-Hour-Automation GitHub organization

Clone and Install

# Clone the repo
git clone https://github.com/1-Hour-Automation/client-hub.git
cd client-hub

# Install dependencies
npm install

Alternatively, use Bun:

bun install

Environment Variables

Copy the example environment file and fill in the values:

cp .env.example .env

Required Variables

VariableDescriptionWhere to Get It
VITE_SUPABASE_URLSupabase project URLSupabase Dashboard > Settings > API
VITE_SUPABASE_ANON_KEYSupabase anonymous key (public, safe for client)Supabase Dashboard > Settings > API
SUPABASE_SERVICE_ROLE_KEYService role key (bypasses RLS -- scripts only)Supabase Dashboard > Settings > API
BLITZ_API_KEYBlitz API key for attorney enrichmentBlitz API dashboard
ANTHROPIC_API_KEYAnthropic API key for AI summarizationAnthropic console (also set as Supabase secret)
caution

SUPABASE_SERVICE_ROLE_KEY has full database access and bypasses all RLS policies. Never expose it in client-side code. It is only used by scripts in the scripts/ directory.

Optional Variables

VariableDescription
VITE_APP_ENVEnvironment identifier (development, staging, production)

Start the Dev Server

npm run dev

The app runs at http://localhost:5173 (Vite default port).

Hot module replacement is active -- changes to React components update in the browser instantly without a full page reload.

Build for Production

# Build
npm run build

# Preview the production build locally
npm run preview

The build output goes to dist/. This is what Netlify deploys.

Lint

npm run lint

Project Structure

Key directories to know:

client-hub/
├── src/
│ ├── pages/ # Page components (route targets)
│ ├── components/ # Reusable UI components
│ │ ├── ui/ # shadcn/ui base components (51 files)
│ │ ├── layout/ # AppLayout, Sidebar, TopBar
│ │ ├── guards/ # ProtectedRoute, RoleGuard
│ │ ├── sales/ # Internal sales section components
│ │ └── shared/ # DataTable, StatCard, EmptyState
│ ├── hooks/ # Custom React hooks
│ ├── integrations/
│ │ └── supabase/
│ │ ├── client.ts # Supabase client initialization
│ │ └── types.ts # TypeScript types (manually maintained)
│ └── lib/
│ ├── utils.ts # Utility functions
│ └── sales-types.ts # Sales-specific TypeScript types
├── supabase/
│ ├── functions/ # Edge functions (Deno)
│ ├── migrations/ # SQL migration files
│ └── config.toml # Supabase configuration
├── scripts/ # CLI scripts (enrichment, analysis, data)
├── public/ # Static assets
└── .env # Environment variables (not committed)

Working with Edge Functions Locally

Edge functions run in Deno, not Node. To develop and test them locally:

# Start the Supabase local development stack
supabase start

# Serve a specific function locally
supabase functions serve <function-name> --env-file .env

# Test with curl
curl -X POST http://localhost:54321/functions/v1/<function-name> \
-H "Authorization: Bearer <anon-key>" \
-H "Content-Type: application/json" \
-d '{"key": "value"}'

Edge function source files are in supabase/functions/*/index.ts. Each function has its own directory.

Working with the Database

# Apply pending migrations
supabase db push

# Create a new migration
supabase migration new <description>

# Reset local database (destructive)
supabase db reset
info

The attorneys table was created via the Supabase dashboard, not through migration files. It will not appear in auto-generated types. Types for this table are manually maintained in src/integrations/supabase/types.ts.

Common Development Tasks

TaskCommand
Start dev servernpm run dev
Build for productionnpm run build
Preview production buildnpm run preview
Run lintnpm run lint
Run enrichment (test)npx tsx scripts/enrich-attorneys.ts --test
Deploy edge functionsupabase functions deploy <name>
Apply migrationssupabase db push