An AI assistant for law firms that use Clio. Users chat through the web interface, Microsoft Teams, Slack, or MCP clients. The bot can answer questions about cases, look up firm procedures, and execute operations in Clio.
User → Chat Channel → Worker → Durable Object → AI + Clio → Response
Each organization gets its own Durable Object that manages conversations, settings, and Clio credentials. The Worker routes incoming messages to the right org's DO.
| Store | Scope | Contents |
|---|---|---|
| D1 | Shared | Auth, org registry, Knowledge Base chunks |
| Vectorize | Shared (filtered) | Embeddings for KB and org documents |
| DO SQLite | Per-org | Conversations, messages, settings, Clio schema cache |
| DO KV | Per-org | Encrypted Clio OAuth tokens |
| R2 | Per-org paths | Uploaded documents, audit logs |
git clone <repo-url>
cd docket
npm installCopy the example env files:
cp apps/api/.dev.vars.example apps/api/.dev.vars
cp apps/web/.dev.vars.example apps/web/.dev.varsCreate a .env file for the web app (Vite uses .env, Wrangler uses .dev.vars):
echo "VITE_API_URL=http://localhost:8787" > apps/web/.envEdit apps/api/.dev.vars with your Clio credentials and secrets.
Run the API and web app in separate terminals:
npm run dev:api # http://localhost:8787
npm run dev:web # http://localhost:5173npm test # Unit tests (all packages)
npm run test:e2e # End-to-end tests
npm run test:all # Both
# Web app specific
cd apps/web
npm test # Unit tests
npm run test:integration # Integration tests (requires API running)
npm run test:e2e # Playwright E2E tests
npm run test:e2e:ui # Playwright with interactive UIIntegration tests require the API server running on localhost:8787.
E2E tests use Playwright. Tests requiring authentication use storage state — a saved browser session that skips login:
cd apps/web
# 1. Generate auth state (login manually, state saved to .auth/)
npx playwright test --project=setup
# 2. Run authenticated tests
npm run test:e2eThe setup project logs in once and saves cookies/localStorage to .auth/user.json. Subsequent tests load this state to skip login.
Test structure:
test/e2e/auth-and-org.spec.ts— Signup, org creation, member invitation flowsplaywright.config.ts— Test configuration with setup project
# Deploy API (api.docketadmin.com)
cd apps/api && wrangler deploy
# Deploy Web (docketadmin.com)
cd apps/web && npm run build && wrangler deploy --env productioncd apps/api
# Local development
npx wrangler d1 migrations apply docket-db --local
# Production
npx wrangler d1 migrations apply docket-db --remoteThe system has two sources of RAG context:
| Component | Location | Purpose |
|---|---|---|
| Source files | apps/api/kb/*.md |
Markdown content |
| Bundled manifest | src/services/kb-manifest.ts |
Auto-generated imports |
| D1 table | kb_chunks |
Chunk text and metadata |
| Vectorize | type: "kb" vectors |
Semantic search |
| Component | Location | Purpose |
|---|---|---|
| Source files | R2 via /api/org/context |
Uploaded documents |
| D1 table | org_context_chunks |
Chunk text and metadata |
| Vectorize | type: "org" + org_id |
Per-org semantic search |
When KB markdown files change, reseed to update D1 and Vectorize:
cd apps/api
# 1. Regenerate the manifest (bundles MD files into worker)
npm run kb:manifest
# 2. Deploy the worker
npx wrangler deploy
# 3. Trigger the seed (clears and rebuilds kb_chunks + vectors)
curl -X POST https://api.docketadmin.com/internal/seed-kb \
-H "X-Seed-Secret: $SEED_SECRET"The seed only affects shared KB data. Org context is untouched.
- Owner — Full Clio access, can manage the organization and transfer ownership
- Admin — Full Clio access, can manage settings and invite users
- Member — Read-only Clio access, no org management
Detailed specs are in /docs/00-specs/:
00-overview— Product overview01-user-flows— User journeys02-technical-foundation— Architecture03-storage-schemas— Database schemas04-auth— Authentication05-channel-adapter— Teams/Slack/MCP adapters06-durable-objects— Per-org state07-knowledge-base— RAG implementation08-workers-ai— LLM integration09-clio-integration— Clio API10-development-plan— Development phases12-web-chat-interface— Web chat interface
Cloudflare Workers, Durable Objects, D1, Vectorize, R2, Workers AI (Llama 3.1), React Router 7, TypeScript, Zod, Drizzle ORM, Better Auth.