How 1panel-dev/cordyscrm works
Purpose and deliverables
Cordys CRM is a self-hostable AI-enabled customer relationship management system. It ships a Java backend, desktop and mobile Vue clients, and a Docker installer that starts the application with MySQL and Redis. Primary product entry points are the browser SPA and mobile SPA; backend bootstrap is backend/app/src/main/java/cn/cordys/Application.java.
Runtime composition
• Maven multi-module backend: app launcher plus reusable framework and CRM domain module (backend/pom.xml, backend/app/pom.xml, backend/crm/pom.xml).
• Spring Boot serves the API; Spring/MyBatis persistence targets MySQL. Schema/data/permission evolution is versioned under backend/crm/src/main/resources/migration.
• Redis supports messaging/cache-style infrastructure and asynchronous consumers (backend/crm/src/main/java/cn/cordys/config/RedisConfig.java, backend/crm/src/main/java/cn/cordys/common/redis/MessagePublisher.java).
• Docker installer orchestrates CRM, MySQL, Redis, plus optional MCP/cockpit processes (installer/Dockerfile, installer/shells/start-all.sh, installer/conf/cordys-crm.properties).
Request boundary, tenancy, and authorization
HTTP requests enter controller classes, cross authentication/CSRF/API-key filters, establish organization context, and reach services. Shiro/session integration and organization scoping are cross-cutting boundaries, with permission aspects and resource-specific access-context providers enforcing data access.
Paths: backend/crm/src/main/java/cn/cordys/common/security/AuthFilter.java, backend/crm/src/main/java/cn/cordys/common/context/OrganizationContextWebFilter.java, backend/crm/src/main/java/cn/cordys/common/permission/CsPermissionAspect.java.
Configurable CRM data model
The system supports module/form/field configuration rather than only fixed CRM schemas. Field definitions and forms drive typed field resolution; business records commonly split core, field, and blob entities. This is the coupling point shared by customer, clue, opportunity, contract, order, product, and custom-form modules.
Paths: backend/crm/src/main/java/cn/cordys/crm/system/service/ModuleFormService.java, backend/crm/src/main/java/cn/cordys/common/resolver/field/ModuleFieldResolverFactory.java, backend/crm/src/main/java/cn/cordys/crm/form/service/CustomFormDataService.java.
Core sales lifecycle domains
The principal business flow is leads/clues → customers and contacts → opportunities/quotations → contracts, invoices, payment plans/records, and orders; ownership, pools, stages, follow-ups, exports, and audit logs surround these records. Each domain follows controller → service → MyBatis mapper/XML persistence.
Paths: backend/crm/src/main/java/cn/cordys/crm/clue/service/ClueService.java, backend/crm/src/main/java/cn/cordys/crm/customer/service/CustomerService.java, backend/crm/src/main/java/cn/cordys/crm/opportunity/service/OpportunityService.java.
Workflow, background work, and notifications
Approval flow definitions produce approval instances, tasks, records, resource snapshots, and action handling. Scheduled jobs handle expiration, cleanup, reminders, recycle rules, and opportunity rules. Redis consumers drive exports and SSE; notices can route to in-app, email, and enterprise collaboration senders.
Paths: backend/crm/src/main/java/cn/cordys/crm/approval/service/ApprovalInstanceService.java, backend/crm/src/main/java/cn/cordys/crm/system/consumer/ExportConsumer.java, backend/crm/src/main/java/cn/cordys/crm/system/notice/CommonNoticeSendService.java.
Frontend clients and integration boundary
The pnpm workspace has shared typed API/models plus Vite Vue desktop and mobile applications. Both use router guards, stores, permissions, dynamic form components, and domain API modules; desktop additionally exposes workflow/form design and dashboards. External integration adapters cover MaxKB agents/AI, DataEase BI, DingTalk, Lark, WeCom, SSO/OAuth, QCC, and tender services.
Paths: frontend/packages/web/src/main.ts, frontend/packages/mobile/src/main.ts, frontend/packages/lib-shared/api/modules/agent.ts.
Main entry points: OpportunityService.java Sales lifecycle services · Dockerfile Docker installer · Application.java Spring Boot API · CsPermissionAspect.java Permission enforcement
Components 17
Client applications
- Desktop Vue SPA · Primary browser CRM, dashboards, and designers.
frontend/packages/web/src/main.ts - Mobile Vue SPA
frontend/packages/mobile/src/main.ts - Shared API and models · Typed API modules used by both clients.
frontend/packages/lib-shared/api/modules/agent.ts
Spring CRM backend
- Spring Boot API · HTTP API and application bootstrap.
backend/app/src/main/java/cn/cordys/Application.java - Security and org boundary · Authentication, CSRF/API-key checks, and organization context.
backend/crm/src/main/java/cn/cordys/common/security/AuthFilter.java - Permission enforcement · Permission aspects and resource access contexts scope data access.
backend/crm/src/main/java/cn/cordys/common/permission/CsPermissionAspect.java - Sales lifecycle services · Leads, customers, opportunities, contracts, payments, and orders.
backend/crm/src/main/java/cn/cordys/crm/opportunity/service/OpportunityService.java - Configurable forms and fields · Module, form, and field definitions drive typed record data.
backend/crm/src/main/java/cn/cordys/crm/system/service/ModuleFormService.java - Approvals and jobs · Approval instances, tasks, scheduled rules, and reminders.
backend/crm/src/main/java/cn/cordys/crm/approval/service/ApprovalInstanceService.java - Exports and notices · Redis-driven exports/SSE and multi-channel notifications.
backend/crm/src/main/java/cn/cordys/crm/system/consumer/ExportConsumer.java - External adapters · AI, BI, collaboration, SSO, and business-data providers.
frontend/packages/lib-shared/api/modules/agent.ts
Data and messaging
- MyBatis persistence · CRM services persist through mappers and XML mappings.
- MySQL · Stores CRM records, configuration, workflow, and audit data.
- Schema migrations · Schema, seed data, and permission evolution.
backend/crm/src/main/resources/migration - Redis · Supports messaging, cache infrastructure, and consumers.
backend/crm/src/main/java/cn/cordys/config/RedisConfig.java
Deployment
- Docker installer · Starts CRM with MySQL, Redis, and optional processes.
installer/Dockerfile - MCP and cockpit
installer/shells/start-all.sh
Connections 22
- Desktop Vue SPA → Shared API and models: uses
- Mobile Vue SPA → Shared API and models: uses
- Shared API and models → Spring Boot API: calls API
- Spring Boot API → Security and org boundary: processes requests through
- Security and org boundary → Permission enforcement: establishes scoped access
- Permission enforcement → Sales lifecycle services: authorizes
- Permission enforcement → Configurable forms and fields: authorizes
- Sales lifecycle services → Configurable forms and fields: uses dynamic fields
- Sales lifecycle services → Approvals and jobs: creates approval work
- Sales lifecycle services → MyBatis persistence: persists via
- Configurable forms and fields → MyBatis persistence: persists definitions and data
- Approvals and jobs → MyBatis persistence: persists instances and tasks
- MyBatis persistence → MySQL: reads and writes
- Schema migrations → MySQL: evolves schema and data
- Sales lifecycle services → Redis: publishes async work
- Redis → Exports and notices: drives consumers
- Exports and notices → External adapters: sends through
- Spring Boot API → External adapters: connects to
- Docker installer → Spring Boot API: runs
- Docker installer → MySQL: runs
- Docker installer → Redis: runs
- Docker installer → MCP and cockpit: optionally starts