This guide helps contributors run LatticePolicy locally for development, testing, and documentation review.
LatticePolicy is a property and casualty insurance policy underwriting system framework with a React frontend, Node.js/Express API, PostgreSQL database, Redis cache, and Docker Compose local stack.
Install these tools before starting:
| Tool | Required version | Purpose |
|---|---|---|
| Git | Current stable | Clone, branch, commit, and push changes |
| Node.js | 20 or later | Run the TypeScript workspaces |
| npm | Bundled with Node.js | Install workspace dependencies |
| Docker Desktop | Current stable | Run PostgreSQL, Redis, API, and UI containers |
| GitHub CLI | Optional | Create and manage pull requests from the terminal |
Verify the core tools:
git --version
node --version
npm --version
docker --version
docker compose versiongit clone https://github.com/kishorjakkula/LatticePolicy.git
cd LatticePolicyCreate a working branch from the latest main:
git checkout main
git pull origin main
git checkout -b docs/my-changeUse the branch naming guidance in CONTRIBUTING.md for feature, fix, docs, test, refactor, and chore work.
Copy the sample environment file:
cp .env.example .envFor Windows PowerShell:
Copy-Item .env.example .envLocal defaults:
| Variable | Required | Local purpose |
|---|---|---|
DB_USER |
Yes | PostgreSQL application user |
DB_PASSWORD |
Yes | PostgreSQL application password |
DB_NAME |
Yes | PostgreSQL database name |
JWT_SECRET |
Yes | Local token signing secret |
SENTRY_DSN |
No | Server error tracking DSN |
VITE_SENTRY_DSN |
No | Frontend error tracking DSN |
VITE_API_BASE_URL |
No | Public API base URL used by the browser app |
Do not commit .env or real secrets.
This is the fastest path for first-time contributors because it runs the database, cache, API, and UI together.
docker compose up -d --buildLocal services:
| Service | URL or port |
|---|---|
| Policy UI | http://localhost:5173 |
| Policy API health | http://localhost:3300/health |
| PostgreSQL | localhost:65432 |
| Redis | localhost:6379 |
Check container status:
docker compose psView logs:
docker compose logs -f server
docker compose logs -f frontendStop the stack:
docker compose downReset local database and cache volumes:
docker compose down -v
docker compose up -d --buildUse the volume reset only when you are comfortable deleting local PostgreSQL and Redis data.
Use this mode when actively changing the API or frontend and you want hot reload from the local Node.js processes.
Install workspace dependencies:
npm installStart only PostgreSQL and Redis:
docker compose up -d db cacheSet local runtime variables for the API.
PowerShell:
$env:DATABASE_URL="postgres://lattice_policy:yourStrongPassword@localhost:65432/lattice_policy"
$env:JWT_SECRET="change-me-please-use-a-long-random-string"
$env:REDIS_URL="redis://localhost:6379"
$env:CACHE_ENABLED="1"
npm run dev:serverBash:
export DATABASE_URL=postgres://lattice_policy:yourStrongPassword@localhost:65432/lattice_policy
export JWT_SECRET=change-me-please-use-a-long-random-string
export REDIS_URL=redis://localhost:6379
export CACHE_ENABLED=1
npm run dev:serverIn a second terminal, start the frontend:
npm run dev:frontendThe frontend dev server normally runs on http://localhost:5173. If port 5173 is already in use, Vite may choose another port and print the URL in the terminal.
SQL migrations live under server/migrations/.
When the API starts with DATABASE_URL configured, it:
- Connects to PostgreSQL.
- Ensures the
schema_migrationstable exists. - Applies unapplied SQL files from
server/migrations/in version order.
For normal local development, starting the API is enough to initialize the schema.
If database initialization fails, the server can continue in in-memory mode for limited UI exploration. Use PostgreSQL-backed mode when validating persistence, tenant isolation, policy lifecycle behavior, RBAC, customer portal behavior, or migrations.
Use tenant sample-carrier for local development.
Sample users:
| Username | Password | Role |
|---|---|---|
admin |
password |
Administrator |
uw1 |
password |
Underwriter |
agent1 |
password |
Agent |
These credentials are for local/demo use only.
The login API requires a tenant. The UI sends tenant context as part of the login flow. API callers should provide tenantId in the request body or X-Tenant in the request header.
Example:
curl -X POST http://localhost:3300/auth/login \
-H "Content-Type: application/json" \
-d "{\"tenantId\":\"sample-carrier\",\"username\":\"agent1\",\"password\":\"password\"}"| Command | Purpose |
|---|---|
npm install |
Install all workspace dependencies |
npm run dev:server |
Start the API in watch mode |
npm run dev:frontend |
Start the React frontend in Vite |
npm run build |
Build frontend and server |
npm run test |
Run frontend and server tests |
npm run test:integration |
Run Docker-backed PostgreSQL migration integration tests |
npm run test:e2e |
Run Playwright tests against an already-running local stack |
npm run test:e2e:docker |
Build/start Docker Compose, wait for API/UI readiness, and run Playwright |
npm run typecheck |
Run TypeScript checks across workspaces |
npm run smoke --workspace=server |
Run API smoke checks |
docker compose up -d --build |
Start the full local stack |
docker compose down |
Stop the local stack |
docker compose down -v |
Stop the stack and delete local volumes |
Run these checks before opening or updating a pull request:
npm run build
npm run test
npm run typecheckFor Docker, API runtime, database, or deployment changes, also run:
docker compose up -d --build
docker compose psFor browser workflow changes, install the Chromium browser once and run the E2E suite:
npx playwright install chromium
npm run test:e2e:dockerThe E2E suite defaults to http://localhost:5173 for the UI, http://localhost:3300 for the API, and tenant sample-carrier. Override with E2E_BASE_URL, E2E_API_BASE_URL, or E2E_TENANT_ID when needed.
For UI changes, include screenshots in the pull request when the visual behavior changes.
- Create a branch from the latest
main. - Make one focused change.
- Update tests and documentation when behavior changes.
- Run build, test, and typecheck locally.
- Commit with a clear message.
- Push the branch.
- Open a pull request into
main. - Wait for CI and review approval.
- Address review comments on the same branch.
- Merge using the repository's squash merge process after approval.
See CONTRIBUTING.md for the full branching, pull request, review, and merge process.
Another local process may be using one of the expected ports.
Common ports:
5173for the UI3300for the API65432for PostgreSQL6379for Redis
Stop the conflicting process or update the port mapping in docker-compose.yml for local testing.
Check that the database container is running:
docker compose ps db
docker compose logs dbAlso confirm DATABASE_URL, DB_USER, DB_PASSWORD, and DB_NAME match the Docker Compose configuration.
Use tenant sample-carrier. API callers must provide either:
tenantIdin the JSON request bodyX-Tenant: sample-carrierrequest header
Confirm the API is healthy:
curl http://localhost:3300/healthFor Docker-based UI builds, confirm VITE_API_BASE_URL is set to http://localhost:3300 before rebuilding the frontend image.
Clean and reinstall dependencies:
rm -rf node_modules frontend/node_modules server/node_modules packages/types/node_modules
npm installFor Windows PowerShell:
Remove-Item -Recurse -Force node_modules, frontend/node_modules, server/node_modules, packages/types/node_modules
npm installReset local Docker volumes:
docker compose down -v
docker compose up -d --buildThis deletes local PostgreSQL and Redis data.