Architecture
apps/
web/ # Next.js 16—CRM dashboard (3000)
portal/ # customer portal (3001)
docs/ # + 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 (authorize, last-admin guard)
permissions/ # Permission catalog + 9 system role templates
events/ # Domain event outbox
search/ # Full-text search + hybrid retriever
ai/ # Provider-agnostic model factory (Anthropic, OpenAI, Google)
analytics/ # Metric registry + snapshot service
audit/ # Compliance audit trail
briefing/ # Daily-briefing engine
dashboards/ # Dashboards V2 registry
dashboard-snapshot/ # 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 object storage
ui/ # React lib (Radix + Tailwind + CVA)
tooling/
typescript/ # Shared tsconfig (ES2024, strict, bundler resolution)
vitest/ # Shared vitest config (v8 coverage)