Architecture
apps/
web/ # Next.js 16 — CRM dashboard (3000)
portal/ # Next.js 16 — customer portal (3001)
docs/ # Next.js 16 + Fumadocs — generated API/domain/architecture docs (3002)
services/
api/ # Hono + tRPC API (4000)
workflows/ # Temporal worker (Google sync, automations)
packages/
db/ # Drizzle ORM, PostgreSQL 16 (pgvector), migrations, seed
domain-model/ # Zod schemas + TS types for all entities
auth/ # JWT auth, scrypt hashing, session config
authz/ # RBAC runtime — resolveEffectivePermissions, authorize, last-admin guard
permissions/ # Permission catalog + 9 system role templates (admin, field_supervisor, sales_rep, technician, accounting, …)
events/ # Domain event outbox — publish in tx, poll-dispatch
search/ # Full-text search + hybrid retriever (BM25 + pgvector + RRF)
ai/ # Provider-agnostic model factory (Anthropic, OpenAI, Google)
analytics/ # Metric registry + snapshot service
audit/ # Compliance audit trail
briefing/ # Daily-briefing engine (see Daily Briefing below)
dashboards/ # Dashboards V2 registry — dashboard/widget defs, layouts, access gating
dashboard-snapshot/ # Per-dashboard snapshot compute composables
sms/ # Twilio SMS — send, inbound sig verify, E.164, opt-out, templates
config/ # Zod-validated env vars + tenant config
email/ # SMTP transport + from-address policy
knowledge/ # PDF extraction + chunking for embeddings
linker/ # Google artifact ↔ CRM classifier (own pkg breaks api/workflows cycle)
observability/ # OpenTelemetry + Pino
payments/ # Stripe + surcharge calculator
storage/ # S3-compatible (MinIO local/CI, AWS S3 cloud)
ui/ # React lib (Radix + Tailwind + CVA)
tooling/
typescript/ # Shared tsconfig (ES2024, strict, bundler resolution)
vitest/ # Shared vitest config (v8 coverage)