Installation & Setup
Set up CodeCourier for local development. Covers system requirements, environment variables, Convex, Clerk, E2B, and Trigger.dev configuration.
This guide covers everything you need to run CodeCourier locally for development. CodeCourier is a Next.js application backed by Convex, Clerk, E2B, and Trigger.dev. Each service requires its own configuration, but once set up, the local development experience is fully functional with hot reloading and real-time data.
System requirements
- Node.js - Version 20.9.0 or later (required by Clerk SDK)
- Package manager - Bun (recommended, used in the project scripts) or npm/yarn/pnpm
- Git - For cloning the repository and managing branches
- Operating system - macOS, Linux, or Windows (with WSL recommended for the best experience)
Bun is optional
bun-nextjs-convex-clerk), all standard npm commands work as well. The instructions below show both options.Clone and install
Clone the repository
git clone https://github.com/your-org/codecourier.git
cd codecourierInstall dependencies
bun installThis installs all production and development dependencies including Next.js, Convex, Clerk, the E2B SDK, Trigger.dev SDK, Tailwind CSS, Radix UI, shadcn/ui, Framer Motion, and testing tools (Vitest, Playwright).
Environment variables
Create a .env.local file in the project root. The repository includes a .env.example file with all supported variables. Copy it as your starting point:
cp .env.example .env.localThe following variables are required for local development:
Convex
# Your Convex deployment URL (shown after running npx convex dev)
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud
# Convex site URL (used by Trigger.dev for HTTP callbacks)
CONVEX_SITE_URL=https://your-deployment.convex.siteClerk authentication
# Clerk publishable key (client-side, starts with pk_test_ or pk_live_)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxx
# Clerk secret key (server-side, starts with sk_test_ or sk_live_)
CLERK_SECRET_KEY=sk_test_xxx
# Clerk JWT issuer domain (found in Clerk dashboard > JWT Templates)
CLERK_JWT_ISSUER_DOMAIN=https://your-clerk-domain.clerk.accounts.dev
# Clerk webhook signing secret (for Convex HTTP webhook handler)
CLERK_WEBHOOK_SECRET=whsec_xxxTrigger.dev
# Shared secret for authenticating callbacks between Trigger.dev and Convex
TRIGGER_CALLBACK_SECRET=your-random-secret-stringGenerate a strong callback secret
TRIGGER_CALLBACK_SECRET is used to verify that incoming HTTP requests to Convex genuinely originate from your Trigger.dev jobs. Use a cryptographically random string (at least 32 characters). You can generate one with openssl rand -hex 32.Optional variables
# PostHog analytics (optional)
# NEXT_PUBLIC_POSTHOG_KEY=phc_xxx
# NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
# Meta/Facebook Pixel (optional)
# NEXT_PUBLIC_META_PIXEL_ID=123456789
# Google Ads conversion tracking (optional)
# NEXT_PUBLIC_GOOGLE_ADS_ID=AW-123456789Service setup
Set up Convex
Convex is the database and backend runtime for CodeCourier. Start the Convex development server, which syncs your local schema and functions to a development deployment:
npx convex devOn first run, the Convex CLI will prompt you to log in and create a new project. After setup, it prints your deployment URL - copy this into your .env.local as NEXT_PUBLIC_CONVEX_URL.
The Convex dev server watches for changes to files in the convex/ directory and automatically pushes schema and function updates. Keep this terminal running during development.
Convex environment variables
CLERK_WEBHOOK_SECRET and TRIGGER_CALLBACK_SECRET there.Configure Clerk authentication
Create a Clerk application at dashboard.clerk.com:
- Create a new application and enable your desired sign-in methods (Google, GitHub, email, etc.)
- Copy the Publishable Key and Secret Key from the API Keys page into your
.env.local - Set up a JWT Templatefor Convex. In the Clerk dashboard, navigate to JWT Templates, create a new template named “convex”, and configure the issuer and audience fields as documented in the Convex + Clerk integration guide
- Copy the JWT issuer domain into
CLERK_JWT_ISSUER_DOMAIN - Set up a Webhook endpoint pointing to your Convex site URL (e.g.,
https://your-deployment.convex.site/clerk-webhook). Enable user events (user.created, user.updated, user.deleted). Copy the signing secret intoCLERK_WEBHOOK_SECRET
Set up E2B sandbox access
E2B provides the cloud sandboxes where AI agents execute. Configuration is done at the project level inside the CodeCourier UI (Project Settings > API Keys), not as a local environment variable. However, to verify your E2B setup during development:
- Create an account at
e2b.devand obtain your API key from the dashboard - After starting CodeCourier, navigate to Project Settings and add your E2B API key in the API Keys section
The E2B SDK (e2b package) is already included in the project dependencies. Sandbox templates (which define the base environment and pre-installed tools) are configured per-workflow and managed through the CodeCourier UI.
Connect Trigger.dev
Trigger.dev handles background job execution for sandbox provisioning, workflow runs, and issue sessions. For local development:
- Sign up at
trigger.devand create a new project - Install the Trigger.dev CLI globally or use npx:
npx trigger.dev@latest devThis starts the Trigger.dev dev server, which connects to the Trigger.dev cloud to receive and process jobs locally. The project includes a trigger.config.ts file that defines all registered tasks.
Trigger.dev is optional for UI development
Start the development server
With Convex dev running in one terminal, start the Next.js development server in another:
bun devThe application starts at http://localhost:3000. You should see the Clerk sign-in page. After authenticating, you will be directed to create your first project or join an existing one.
Verify the installation
Run through this checklist to confirm everything is working:
- Authentication: You can sign in and out through Clerk. Your user appears in the Convex dashboard under the
userstable. - Project creation: You can create a new project. Check that the
projects,projectMembers, andprojectSettingstables populate in Convex. - Real-time updates: Open two browser tabs on the same project. Create a workflow in one tab and confirm it appears instantly in the other.
- API key storage: Add an E2B API key in project settings and verify it appears with only the last four characters visible.
Running tests
CodeCourier includes both unit tests (Vitest) and end-to-end tests (Playwright):
# Unit tests
npm run test
# Unit tests with watch mode
npm run test:watch
# Unit tests with coverage report
npm run test:coverage
# End-to-end tests (requires the dev server running)
npm run test:e2e
# E2E tests with interactive UI
npm run test:e2e:uiTroubleshooting
Convex dev fails to start
Ensure you are logged in to the Convex CLI (npx convex login) and that your convex.json file points to a valid project. If you see schema validation errors, check that all files in the convex/ directory compile without TypeScript errors.
Clerk authentication redirects loop
Verify that NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYmatches your Clerk application environment (test vs. production). Ensure the JWT template in Clerk is named “convex” and the issuer domain in CLERK_JWT_ISSUER_DOMAIN matches exactly.
Sandbox creation fails
Check that your E2B API key is correctly configured in project settings (not in .env.local - E2B keys are stored per-project in Convex). Verify the Trigger.dev dev server is running and connected. Check the Trigger.dev dashboard for job execution logs.
Type checking errors
Run the type checker to find issues:
npm run typecheckThe project uses TypeScript 5.9+ with strict mode. Convex generates types automatically in convex/_generated/ - if these are missing, make sure npx convex dev has run at least once.