Skip to content

Development

Terminal window
# Start the dev server (hot-reload)
npm run dev
# Equivalent to: wrangler dev
# The server runs at http://localhost:8787

Wrangler dev mode uses local D1 (SQLite file in .wrangler/) and local KV. Run migrations and seed locally before starting:

Terminal window
npm run db:migrate
npm run seed > seed.sql
wrangler d1 execute lattice-db --local --file=seed.sql
npm run dev
Terminal window
# Health check
curl http://localhost:8787/health
# Get the company entity
curl -H "X-Lattice-Role: ceo" http://localhost:8787/api/v1/entities/lat_com_meridian
# List all teams
curl "http://localhost:8787/api/v1/entities?type=team"
# Get the full org tree
curl http://localhost:8787/api/v1/tree/lat_com_meridian
# Test role-based filtering: compare CEO vs team_member view
curl -H "X-Lattice-Role: ceo" http://localhost:8787/api/v1/entities/lat_com_meridian | jq '.entity.telos.budget'
curl -H "X-Lattice-Role: team_member" http://localhost:8787/api/v1/entities/lat_com_meridian | jq '.entity.telos.budget'
# CEO sees full budget; team_member sees empty array
Lattice/
├── src/
│ ├── schema/
│ │ ├── entity.ts # Entity, TelosState, extensions, workflow types
│ │ ├── api.ts # Request/response types, event types, error types
│ │ └── index.ts # Barrel export
│ ├── workers/
│ │ ├── gateway.ts # Hono app: all API routes, explorer UI, error handling
│ │ └── helpers.ts # D1 query helpers: entity reconstruction, events, cache
│ ├── middleware/
│ │ └── policy.ts # Role-based field filtering middleware
│ ├── db/
│ │ └── migrations/
│ │ └── 0001_init.sql # Full D1 schema: 10 tables, indexes
│ ├── seed/
│ │ └── generate.ts # Seed data generator for Meridian Systems
│ ├── ui/
│ │ └── explorer.html # Lattice Explorer single-page app
│ └── env.d.ts # HTML module declaration for text imports
├── wrangler.toml # Cloudflare Workers configuration
├── package.json # Dependencies and scripts
└── LATTICE.md # Full specification