Local Setup
Prerequisites
- Node.js 20+ (see
.nvmrcfor 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 installEnvironment 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:8787For 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 devOpens at http://localhost:6173.
The dev script kills any existing process on port 6173 before starting.
Run the Chat Worker
- Generate the knowledge base first:
bash
npm run generate-kb- Install worker dependencies and start:
bash
cd chat-worker
npm install
npm run devThe worker runs at http://localhost:8787.
Available Scripts
| Script | Description |
|---|---|
npm run dev | Start Next.js dev server (port 6173) |
npm run build | Production build (static export to out/) |
npm run lint | ESLint check |
npm run typecheck | TypeScript type checking |
npm test | Playwright E2E tests |
npm run test:ui | Playwright with interactive UI |
npm run generate-kb | Generate chatbot knowledge base |
npm run optimize-images | Optimize images with Sharp |
npm run optimize-images:dry | Dry run of image optimization |
Chat Worker Scripts
| Script | Description |
|---|---|
npm run dev | Start worker locally (Wrangler) |
npm run typecheck | TypeScript check |
npm test | Run Vitest tests |