feat: Implement initial AI-native CRM backend with dynamic entity and data management, AI agent tools, and core configurations.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# AI-Native CRM: Agent Handoff Guide
|
||||
|
||||
> [!IMPORTANT]
|
||||
> This document is for the AI Agent to quickly understand the project context, architecture, and current status during session resume.
|
||||
|
||||
## 🎯 Project Vision
|
||||
An **AI-Native CRM** where business modules and data are managed through AI-driven messages and tools, rather than traditional REST parameters.
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Architecture Overview
|
||||
|
||||
### Backend (`/backend`)
|
||||
* **Env**: JDK 19 + Spring Boot 3.2.4 + PostgreSQL.
|
||||
* **Key Logic**:
|
||||
* `CrmTools.java`: **The Message Hub**. Contains `@Tool` methods for **Define, Save, and Delete**. Directly interacts with Repositories.
|
||||
* `AgentController.java`: **Primary Entry Point**. Handles natural language commands or "Business Fact Reports".
|
||||
* **AI-Only Policy**: Create/Update/Delete endpoints have been removed from traditional controllers to force AI-driven flows.
|
||||
|
||||
### Frontend (`/frontend`)
|
||||
* **Env**: Next.js 15 (App Router).
|
||||
* **Components**:
|
||||
* `DynamicForm.tsx`: Shared component supporting **Entity Associations (`x-link-entity`)**, Enums, and Format constraints.
|
||||
* `EntityDataPage` (`/data/[entityCode]`): Full CRUD UI. Actions (Edit/Delete) route through AI messages.
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Key File Responsibilities
|
||||
|
||||
| File | Role |
|
||||
| :--- | :--- |
|
||||
| `backend/.../CrmTools.java` | **Source of Truth** for all data-changing tools. |
|
||||
| `frontend/src/components/DynamicForm.tsx` | Reusable Form Renderer (Schema + AI messaging). |
|
||||
| `frontend/src/app/data/[entityCode]/page.tsx` | Dynamic List View with Agent-driven Actions. |
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Core Conventions
|
||||
|
||||
1. **AI-First Mutation**: DO NOT create manual REST services for data mutation. Use the AI Tool interface.
|
||||
2. **Schema Extensions**:
|
||||
* Associations: `x-link-entity: 'module_code'`.
|
||||
* Constraints: `enum`, `pattern`, `format: 'date'`.
|
||||
3. **Fact-Based Messaging**: Frontend should report business facts (e.g., "User filled form X") and let the AI decide the tool to call.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Current Progress & Next Steps
|
||||
- [x] AI-Native CRUD implemented (Agent-driven Insert/Update/Delete).
|
||||
- [x] Entity Associations & Selectors supported.
|
||||
- [x] Unified DynamicForm for Generation & Management.
|
||||
- [ ] Next: Implement Advanced Search & Filtering via AI Query generation.
|
||||
- [ ] Next: Dashboard Analytics module for dynamic data summary.
|
||||
|
||||
---
|
||||
*Updated at: 2026-03-25. Follow this guide for AI-Native CRM development.*
|
||||
@@ -0,0 +1,49 @@
|
||||
# AI-Native CRM 系统开发手册
|
||||
|
||||
## 🎯 系统定位 (Core Vision)
|
||||
本系统是一款 **AI-Native (原生 AI)** 的声明式 CRM。与传统 CRM 的本质区别在于:
|
||||
* **非硬编码业务逻辑**:业务模块、字段定义和 UI 呈现均由 AI 动态生成并持久化。
|
||||
* **零研发排期**:业务专家通过自然语言描述需求,即可立刻生成生产可用的功能模块。
|
||||
|
||||
---
|
||||
|
||||
## 🚀 核心特性 (Key Features)
|
||||
|
||||
### 1. 生成式 UI (Generative UI)
|
||||
* 集成 **CopilotKit**,在前端实现 AI 对应用的深度操控。
|
||||
* 支持通过自然语言一键渲染(Render)基于 JSON Schema 的复杂表单。
|
||||
* **UniversalModuleRenderer**:万能组件渲染引擎,适配多种动态业务场景。
|
||||
|
||||
### 2. 动态多租户架构
|
||||
* 后端使用 `SysEntity` (元数据) 和 `SysDynamicData` (实例数据) 支撑无限扩展。
|
||||
* 支持不同租户、不同模块的字段在运行时动态注入,无需繁琐的数据库迁移动作。
|
||||
|
||||
### 3. AI 交互中枢 (AI Hub)
|
||||
* **后端驱动**:基于 **LangChain4j** 构建 Java 原生 AI 逻辑,支持 RAG 及复杂工作流。
|
||||
* **会话持久化**:原生支持 AI 会话的数据库存储,重启不丢失交互上下文。
|
||||
|
||||
---
|
||||
|
||||
## 📋 技术基准 (Benchmarks & Tech Stack)
|
||||
|
||||
### Backend (Java Ecosystem)
|
||||
* **Runner**: OpenJDK 19
|
||||
* **Framework**: Spring Boot 3.2.4 (Latest Stable)
|
||||
* **Persistence**: Spring Data JPA + Hibernate 6.x
|
||||
* **Database**: PostgreSQL (Support JSONB for Dynamic Data)
|
||||
* **AI SDK**: LangChain4j 0.30.0
|
||||
* **Build Tool**: Maven
|
||||
|
||||
### Frontend (Modern Web)
|
||||
* **Framework**: Next.js (App Router)
|
||||
* **Language**: TypeScript
|
||||
* **Styling**: Tailwind CSS + Shadcn UI (Visual Esthetics)
|
||||
* **Copilot**: CopilotKit (React SDK + Popup UI)
|
||||
* **Font**: Geist (Advanced Typography)
|
||||
|
||||
---
|
||||
|
||||
## 🛠 开发规范
|
||||
1. **动态性优先**:任何新功能应考虑是否可通过配置或 AI 生成,而非硬编码 Controller。
|
||||
2. **Schema 为王**:业务定义必须严格遵循 JSON Schema 标准,以保证前后端渲染的一致性。
|
||||
3. **Prompt 工程**:系统 Prompt 存储于前端 `page.tsx` 或后端专用 AI 服务类中,需定期维护。
|
||||
Reference in New Issue
Block a user