Skip to content

Local Setup

Prerequisites

  • Node.js 20+ (see .nvmrc for exact version)
  • npm 10+
  • Git
  • Wrangler CLI for chat worker development (npm install -g wrangler)

Install Dependencies

bash
git clone git@github.com:Anshul-Homelab/portfolio.git
cd portfolio
npm install

Environment Variables

Site (.env)

Copy .env.example and fill in values:

bash
NEXT_PUBLIC_SITE_URL=https://anshulbisen.com
NEXT_PUBLIC_POSTHOG_KEY=your_posthog_project_token_here
NEXT_PUBLIC_POSTHOG_HOST=https://ph.anshulbisen.com
NEXT_PUBLIC_CHAT_WORKER_URL=http://localhost:8787

For local development, NEXT_PUBLIC_CHAT_WORKER_URL should point to the local worker.

Chat Worker (chat-worker/.dev.vars)

Create this file with your secrets:

bash
GEMINI_API_KEY=<your-gemini-api-key>
RATE_LIMIT_BYPASS_TOKEN=<any-secret-string>
SLACK_BOT_TOKEN=<slack-bot-oauth-token>
SLACK_SIGNING_SECRET=<slack-signing-secret>
SLACK_CHANNEL_ID=<slack-channel-id>
TURNSTILE_SECRET_KEY=<turnstile-secret-key>

TIP

For local testing without real Slack/Gemini, the worker tests use mock bindings defined in chat-worker/vitest.config.ts.

Run the Site

bash
npm run dev

Opens at http://localhost:6173.

The dev script kills any existing process on port 6173 before starting.

Run the Chat Worker

  1. Generate the knowledge base first:
bash
npm run generate-kb
  1. Install worker dependencies and start:
bash
cd chat-worker
npm install
npm run dev

The worker runs at http://localhost:8787.

Available Scripts

ScriptDescription
npm run devStart Next.js dev server (port 6173)
npm run buildProduction build (static export to out/)
npm run lintESLint check
npm run typecheckTypeScript type checking
npm testPlaywright E2E tests
npm run test:uiPlaywright with interactive UI
npm run generate-kbGenerate chatbot knowledge base
npm run optimize-imagesOptimize images with Sharp
npm run optimize-images:dryDry run of image optimization

Chat Worker Scripts

ScriptDescription
npm run devStart worker locally (Wrangler)
npm run typecheckTypeScript check
npm testRun Vitest tests