ASAgriSense/Docs/Local Setup

Development

Local Setup

Prerequisites#

RequirementVersionNotes
Node.js≥ 20Use nvm or fnm for version management.
npm≥ 11Comes with Node.js. Verify: npm --version
Wrangler CLI≥ 4npm install -g wrangler. Cloudflare Workers local dev.
Neon accountCreate a free project at neon.tech. Grab the pooled connection string.
Clerk accountCreate an application at clerk.com. Copy publishable + secret keys.
Git≥ 2.30Standard. Verify: git --version

Clone & install#

  1. 1

    Clone the repository

    bash
    git clone <repo-url> commodity-management-platform
    cd commodity-management-platform
  2. 2

    Install all workspace dependencies

    bash
    npm install
  3. 3

    Set up environment variables

    Copy the example env file and fill in your values. Each app has its own .env.local file.

  4. 4

    Run database migrations

    bash
    npm run db:migrate:sms-settings
    npm run db:migrate:farmer-registry
    npm run db:migrate:farm-mapping
    npm run db:migrate:deforestation-risk
    npm run db:migrate:sustainability-programs
    npm run db:migrate:surveys
    npm run db:migrate:eudr-compliance
  5. 5

    Start all dev servers

    bash
    npm run dev

Dev servers#

AppURLStart command
Product frontendhttp://localhost:3000Turborepo starts it via npm run dev
Hono APIhttp://localhost:8788Turborepo starts it via npm run dev
This docs sitehttp://localhost:3001Turborepo starts it via npm run dev
Turborepo starts all three
Running npm run dev from the root starts all three apps in parallel via Turborepo. You do not need to start them individually.

Environment variables#

VariableRequiredNotes
DATABASE_URLRequiredNeon PostgreSQL connection string. Use the pooled connection URL.
AUTH_DEV_BYPASSOptionalSet to "true" to bypass Clerk JWT verification locally. Never set in production.
DEV_AUTH_EMAILOptionalSimulated user email when AUTH_DEV_BYPASS=true.
DEV_AUTH_ROLEOptionalSimulated role: org:admin | org:manager | org:officer
DEV_AUTH_TENANT_IDOptionalSimulated Clerk org ID (org_...).
DEV_AUTH_USER_IDOptionalSimulated Clerk user ID (user_...).
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYRequiredFrom Clerk dashboard → API Keys.
CLERK_SECRET_KEYRequiredFrom Clerk dashboard → API Keys. Keep this secret.
NEXT_PUBLIC_API_URLRequiredAPI base URL. Locally: http://localhost:8788
AUTH_DEV_BYPASS
AUTH_DEV_BYPASS=true bypasses Clerk JWT verification entirely — it is only for local development with Wrangler. Never deploy with this set. Use DEV_AUTH_ROLE=org:admin and DEV_AUTH_TENANT_ID=org_test alongside it to simulate a specific user.

Common commands#

CommandWhat it does
npm run devStart all dev servers in parallel.
npm run buildBuild all apps and packages in dependency order.
npm run lintESLint across all workspaces (--max-warnings 0).
npm run typecheckTypeScript type check across all workspaces.
npm run check-typesAlias for typecheck.
npm run testVitest across all workspaces.
npm run formatPrettier format all files.
npm run cleanRemove .next, .turbo build caches.

Running commands in a single workspace#

bash
# Typecheck only the docs app
npm run typecheck --workspace=docs

# Run tests for the farmer-registry backend package
npm run test --workspace=feature-farmer-registry

# Lint only the web app
npm run lint --workspace=web

Database migrations#

Each backend feature package manages its own Drizzle migrations. Migrations are stored in be-packages/feature-*/src/db/migrations/ and are checked into git.

bash
# Run migrations for a specific feature
npm run db:migrate:farmer-registry

# Generate a new migration after schema changes
npm run db:generate:farmer-registry