The Problem

Most CRMs are databases with forms in front of them, and the AI versions bolt a chat box onto the side. The actual work—finding out what is true about a customer and writing it down—still falls to a human. This repo inverts that: the agent is the product, and the CRM is where the agent records what it learned. It runs autonomously on its own schedule, books follow-ups, spends a research budget, and stops when exhausted.

What This Does

Compaicrm is a fork of trycompai/crm (8,804 stars upstream). It's an open-source, agentic-first CRM built as a monorepo with three projects: apps/ (285 files) contains the Next.js frontend and NestJS API, packages/ (121 files) holds shared libraries, and .agents/ (386 files) is primarily documentation—skills and reference material for AI coding agents, not runtime code.

The architecture separates concerns deliberately. The NestJS API (apps/api/src/main.ts, apps/api/src/app.module) has no intelligence—it reports events by writing rows to a queue. The agent (apps/agent/) leases those rows and decides what they mean. The README states a hard rule: a Nest service calling an enrichment API is a bug. Nothing about a person is guessed; tools report observations, and a ledger prices evidence strength.

How It Is Wired

Execution starts at the API entry points: apps/api/api/index.ts and apps/api/src/main.ts. The API routes through apps/api/src/trpc/trpc.module (10 modules import it) and apps/api/src/trpc/middlewares/auth.middleware (10 importers). The module graph shows 515 internal modules with 395 import edges and 3 modules in circular dependencies.

The highest-blast-radius file is apps/api/src/database/database.constants.ts—24 modules depend on it, so churn there is expensive. apps/api/src/app.module (Ca 1, Ce 18, instability 0.95) and apps/api/src/google/google.module (Ca 1, Ce 16, instability 0.94) are unstable hubs that import broadly. The timeline components in apps/app/components/crm/timeline/ participate in a circular import cycle across three files.

How To Use It

The README documents a quick start, but the repo has no lockfile, so builds aren't reproducible. The stack is Bun, Postgres, and Docker.

git clone https://github.com/moses-y/Compaicrm
cd Compaicrm
# Copy .env.example to .env and configure
# Follow README quick-start section (commands not extracted here)

Configuration lives in .env.example. Sign-in is Google-only with a single allow-list environment variable. The repo includes a docker-compose.yml and Dockerfile for deployment. Missing from evidence: exact install commands, CI configuration, and a lockfile.

Real-World Use

This fits a small internal sales team that wants an autonomous research agent maintaining its CRM. The agent ingests email threads, creates companies and contacts, books follow-ups, and spends a research budget. A human reviews suggestions when evidence is weak. It's single-tenant by design—everyone who gets in sees everything.

Code Health & Issues

Static analysis found 122 issues (42 high, 80 medium) across 5 kinds:

  • High – Deep nesting (50 instances) in apps/api/src/crm/activity-stamp.service.ts, apps/agent/agent/lib/accounts.ts, apps/agent/agent/lib/crm.ts; max indentation depth 6.
  • High – Duplicated code: 6,437 repeated 6-line blocks across 236 files, notably .agents/skills/ai-elements/scripts/ and .claude/skills/ai-elements/scripts/.
  • High – Import cycles in apps/app/components/crm/timeline/ (3 files).
  • Medium – High branching density in apps/agent/agent/lib/names.ts, apps/api/src/companies/domain.ts (34 branch points over 103 lines).
  • Medium – Hub modules: apps/api/src/database/database.constants.ts and apps/agent/agent/lib/focus.ts (24 and 17 importers respectively).

SDLC gaps: no CI/CD pipeline, no lockfile, no Dependabot/Renovate, missing .editorconfig and .gitattributes. Tests exist (38 files) but nothing runs them automatically.

The Bottom Line

The architecture is thoughtful—separating the agent from the API and banning guessed facts is a principled design. The codebase needs CI, a lockfile, and deduplication before it's production-safe. Use it if you want an autonomous research agent maintaining your CRM and can accept a single-tenant, Google-only auth model.