Setup Guide
Get the development environment running locally.
Prerequisites
- Bun 1.0+ (not npm or Node.js)
- PostgreSQL (via Supabase) or local install
- Git
- VS Code (recommended)
Installation
1. Clone Repository
bash
git clone https://github.com/your-org/your-repo.git
cd your-repo2. Install Dependencies
bash
bun install3. Environment Variables
Create .env file:
bash
cp .env.example .envEdit .env:
env
# Database (Supabase)
DATABASE_URL=postgresql://postgres:[password]@db.[project].supabase.co:5432/postgres
# Supabase
PUBLIC_SUPABASE_URL=https://[project].supabase.co
PUBLIC_SUPABASE_ANON_KEY=eyJ...
# Anthropic
ANTHROPIC_API_KEY=sk-ant-...
# Cloudflare R2 (for file storage)
R2_ACCOUNT_ID=your-account-id
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=your-bucket-name
# Optional
AI_TIMEOUT_MS=30000
MAX_RETRIES=34. Database Setup
Option A: Supabase Cloud
- Create project at supabase.com
- Copy connection string to
.env - Run migrations:
bash
bun drizzle-kit pushOption B: Local PostgreSQL
bash
# Start PostgreSQL
docker run -d \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
postgres:15
# Update .env
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/mydb
# Run migrations
bun drizzle-kit push5. Seed Database (Optional)
bash
bun run seedCreates:
- Test agency
- Test user (test@example.com / password123)
- Sample projects
6. Start Development Server
bash
bun run devOpens:
- Frontend: http://localhost:5173
- API: http://localhost:5173/api
7. Start Documentation (VitePress)
bash
cd docs
bun install
bun run docs:devOpens: http://localhost:5174
Verify Setup
Test Database Connection
bash
bun run db:testShould output:
✅ Database connected
✅ Tables exist: agencies, projects, versions, assets, ai_logs, usersTest API
bash
curl http://localhost:5173/api/healthShould return:
json
{"status":"ok","timestamp":"2025-05-04T..."}Test AI Integration
bash
bun run test:aiCalls Claude API with a test prompt. Should return success.
Development Workflow
File Structure
src/
├── routes/ # SvelteKit pages & API
│ ├── +layout.svelte
│ ├── +page.svelte
│ ├── projects/
│ └── api/
├── lib/
│ ├── components/ # UI components
│ ├── server/ # Server-only code
│ │ ├── db/
│ │ ├── ai/
│ │ └── api/
│ └── stores/ # Client state
└── app.htmlHot Reload
Changes are instantly reflected (no rebuild):
- Svelte components
- API routes (via
+server.ts) - Styles
Database schema changes require migration:
bash
bun drizzle-kit generate
bun drizzle-kit pushVS Code Extensions
Recommended:
- Svelte for VS Code (svelte.svelte-vscode)
- Tailwind CSS IntelliSense (bradlc.vscode-tailwindcss)
- Prettier (esbenp.prettier-vscode)
- ESLint (dbaeumer.vscode-eslint)
Install all:
bash
code --install-extension svelte.svelte-vscode
code --install-extension bradlc.vscode-tailwindcss
code --install-extension esbenp.prettier-vscode
code --install-extension dbaeumer.vscode-eslintTroubleshooting
Port Already in Use
bash
# Kill process on port 5173
lsof -ti:5173 | xargs kill -9Database Connection Failed
- Check
DATABASE_URLin.env - Verify PostgreSQL is running
- Check firewall/network
bash
# Test connection
psql $DATABASE_URLBun Command Not Found
bash
# Install Bun
curl -fsSL https://bun.sh/install | bashAI API Errors
- Verify
ANTHROPIC_API_KEYin.env - Check API key at console.anthropic.com
- Check rate limits