Apps

Apps · NocoCRM · Development

Development overview

NocoCRM is a complete NocoBase 3 application: it was generated from the NocoBase application template and has its own data model, services, APIs and pages on top of the foundation. All of its source is in the GitHub repository, and you can change it directly to add fields, pages, reports or agent capabilities for your own business.

This section is for developers. To get the code and start it locally, see Get started.

Foundation capabilities NocoCRM uses

General capabilities such as permissions, agents, mail, notifications and scheduled tasks come from NocoBase 3; NocoCRM does not rebuild them. Before you change any of these parts, read the documentation of the plugin behind it.

From NocoBase 3What NocoCRM uses it for
Application server, database layer and command lineThe server, migrations and seed data, configuration, build and deployment
Application template and UI component libraryLayout, routes, theme, the sign-in page, and the components every page uses
Authentication, users and API keysSign-in, user accounts and personal API keys
Authorization (permission sets, record access rules)The three roles, what each person can see and edit on every record, page grants, and the role settings page
Agents pluginAgents, conversations, skills, model services, usage, and the commands the CRM gives agents
Notification pluginsIn-app notifications
Lifecycle libraryApproval states and transitions, the actions each transition triggers, approver rules, and the flow chart on the approval process settings page
Scheduled tasksThe daily check, task preparation and the company signals check
Mail pluginEach member's mailbox: syncing, reading, writing and sending
File and i18n pluginsAttachments and their previews, and the 12 interface languages
Database ExplorerRead-only browsing of the application's tables

Develop with a coding agent

We recommend letting a coding agent such as Claude Code or Codex change the code. AGENTS.md at the repository root is the development guide written for them: where code goes, how to write migrations, the rules for APIs and permissions, and what to check after a change. .agents/rules/crm-*.md records the CRM's own conventions by topic, such as record pages, approvals, agents and permissions; pnpm install also syncs the NocoBase 3 development skills into .agents/skills/.

When you give an agent a task, just state the business goal, for example "Add a contract number field to opportunities, and show it in the list and on the detail page." The agent follows these guides to find what to change.

Code structure

The CRM's own code lives mainly here:

Plain text
client/
  routes.ts                 Routes and menus of all business pages
  pages/                    Pages: the workspace, list and detail pages of each record type, reports, Agents, business guidance, mail, WhatsApp, settings
  components/crm/           CRM components: record forms, timeline, AI cards, import and export, report charts and more
  components/ui/            shadcn/ui primitives, added only with the CLI
  locales/crm/              The CRM's interface text: index.ts holds English and Chinese, and each of the other 10 languages has its own file
server/
  providers/crm/            The CRM's business core: CrmService, field definitions, permissions, conversion, merging, background AI, reports, notifications
  providers/crm-agents/     How the CRM plugs into the Agents plugin: the Sales Expert, background agents, skills, conversation rules
  lifecycles/approvals.ts   The approval state machine
  routes/                   HTTP APIs
  config/                   Plugin configuration
  locales/crm-ai/texts/     Text the AI writes, one file for each of the 12 languages
ai/skills/                  SKILL.md of the six built-in method skills
database/main/migrations/   Database migrations
database/main/seeds/        Initial data: the two sales permission sets
tests/                      Logic tests, component tests and browser tests

The two most important files:

  • server/providers/crm/schema.ts: the field definitions of the six business objects. Server validation, the API document, forms, list columns, import and export, and the command descriptions for agents are all generated from it; see Data model.
  • server/providers/crm/service.ts: CrmService. Every read and write of a record goes through it, and it handles record permissions, field rules and system-maintained fields.

These directories follow the common structure of a NocoBase 3 application; see Project structure. For the common way to build pages, APIs, permissions and tests, see Application development overview.

Common commands

CommandWhat it does
pnpm devStarts the server and client with hot reload; pending migrations run on start
pnpm buildBuilds to dist/
pnpm startRuns the build
pnpm testRuns the tests in tests/
pnpm typecheckType-checks the client and server
pnpm lintLints the code
pnpm nocobase db applyRuns pending migrations and seeds without a restart
pnpm nocobase --helpLists all other commands

For everyday changes, check only the affected files, for example pnpm exec vitest run tests/logic/crm.test.ts. pnpm check runs every check and the build, which suits the time before a release.

API document and API keys

Every CRM API is declared in the API document, and the tests check this:

  • OpenAPI document: <app URL>/api/swagger
  • Interactive Swagger page: <app URL>/api/swagger/docs, usually http://127.0.0.1:13000/main/api/swagger/docs in local development

Requests can use a signed-in session or carry an x-api-key header. Administrators manage keys in System settings › API keys, and each member can also create their own keys in personal settings. A key calls the API with the identity and permissions of the person who created it.

The CRM's APIs sit directly under /api, for example /api/leads and /api/opportunities. On success they return { data }, and lists also return meta; on failure they return the standard error structure.

NocoBase docs assistant

Ask anything about NocoBase…

You can ask follow-up questions about recent answers.