# KMatrix **Repository Path**: mengfly/kmatrix-service ## Basic Information - **Project Name**: KMatrix - **Description**: 基于 RuoYi 与 LangChain4j / Langgraph4j 构建的大模型工作流应用和 RAG 知识库系统,借鉴了MaxKB、Difyf等项目,具备企业应用所需的稳定、安全、易扩展的特点。KMatrix适用于智能客服、企业内部知识库管理、知识密集型单位等场景。 - **Primary Language**: Java - **License**: MIT - **Default Branch**: master - **Homepage**: http://kmatrix.kykms.cn - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 123 - **Created**: 2026-03-14 - **Last Updated**: 2026-03-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

kmatrix

其他语言: [中文](./README.zh-CN.md)

KMatrix - AI-Enhanced Enterprise Knowledge Base Platform

A next-generation AI knowledge base workflow platform built on RuoYi-Vue-Plus and LangChain4j

License Spring Boot Vue 3 PostgreSQL

----------------------------------- ## 📖 Introduction **KMatrix** is a newly designed version of **KYKMS (Keyi Knowledge Management System)**, focusing on deep integration of traditional document management with advanced AI technologies. In the digital era, enterprises accumulate vast amounts of unstructured data but often struggle to utilize it effectively. KMatrix aims to solve this pain point by transforming static documents into dynamic knowledge services through **RAG (Retrieval-Augmented Generation)** technology and **visual workflow orchestration**. KMatrix is not just a document repository; it is an **AI Agent Incubation Platform**. Users can easily build intelligent Q&A assistants, customer service bots, document analysis experts, or business auxiliary bots based on local knowledge bases using a drag-and-drop workflow designer. It also supports natural language queries for databases to address long-tail business needs. Adhering to the philosophy of ease of use, KMatrix provides an **out-of-the-box** experience. With simple operations, anyone can build a knowledge base and create AI dialogue apps within one or a few days. At the same time, it offers high flexibility for customization to meet complex enterprise-level requirements. ----------------------------------- ## ✨ Core Highlights - **🚀 Modern Tech Stack**: Backend based on **RuoYi-Vue-Plus (Spring Boot 3 + JDK 17)**, frontend based on **Soybean Admin (Vue 3 + Vite + Naive UI)**, keeping up with technical trends with excellent performance and development experience. - **🧠 Powerful AI Engine**: Deeply integrated with **LangChain4j** and **LangGraph4j**, providing the strongest AI application development experience in the Java ecosystem. - **📚 Enhanced RAG**: - Uses **PostgreSQL + pgvector** for cosine similarity search, providing accurate natural language Q&A capabilities. - Supports full-text search with **GIN** indexing for precise keyword matching and scoring. - Supports hybrid search, combining vector and full-text search via the **RRF** (Reciprocal Rank Fusion) algorithm to balance semantic flexibility and keyword precision. - Uses **BGE-Reranker** (Cross-Encoder) for re-ranking to further improve retrieval accuracy. - Implements **parent-child chunking**: child chunks for precise matching and noise reduction, parent chunks for complete and coherent context. - Supports QA pairs for targeted answers and AI-generated questions for document chunks to automatically improve retrieval. - Supports parsing of various formats including PDF, Word, PPT, Excel, and Markdown, and supports manual adjustment of chunk content. - **⛓️ Visual Workflow**: Built-in workflow orchestration engine based on **Vue Flow**, supporting node drag-and-drop and connection configuration. Users can customize AI processing flows (e.g., Knowledge Retrieval -> LLM Reasoning -> Result Formatting). - **🔌 Seamless Embedding**: Embed an intelligent Q&A assistant into third-party business systems by copying just one line of script. - **🌍 Model Agnostic**: Supports integration with various LLMs, including local private models (DeepSeek R1 / Llama 3 / Qwen 2, etc.) and public cloud models from both domestic (Tongyi Qianwen / ByteDance Doubao / Zhipu AI / Kimi, etc.) and international providers (OpenAI / Gemini, etc.). - **🧩 Modular Design**: Complete separation of frontend and backend. - **kmatrix-service**: Robust backend services with RBAC permission support. - **kmatrix-ui**: Monorepo architecture containing the management dashboard (`@km/admin`) and embedded chat window (`@km/chat`). - **🎨 Ultimate UI Experience**: Uses Naive UI components for meticulously crafted interface interactions. Provides a smooth, Dify-like orchestration experience; supports dark mode, theme customization, and multi-language. - **🔒 Secure and Controllable**: Supports full on-premise deployment. Combined with Sa-Token authentication and granular permission control, it ensures the security of enterprise knowledge assets. - For more detailed features, please refer to 👉🏻 [KMatrix spec](http://docs.kykms.cn/docs/kmatrix/spec). ----------------------------------- ## 🛠️ Technical Architecture ### Backend (kmatrix-service) - **Core Framework**: Spring Boot 3.5.7 - **Language**: Java 17+ - **ORM Framework**: MyBatis Plus 3.5.14 + Dynamic Datasource - **Database**: PostgreSQL (Recommended, requires pgvector plugin) / MySQL / Oracle + Flyway upgrade management - **AI Framework**: LangChain4j, LangGraph4j - **Authentication**: Sa-Token 1.44.0 (JWT) - **Cache**: Redis 5+ (Redisson) - **Utils**: Hutool, Lombok, Knife4j ### Frontend (kmatrix-ui) - **Core Framework**: Vue 3.5.25 - **Build Tool**: Vite 7.2.6 - **Language**: TypeScript 5.9.3 - **UI Framework**: Naive UI 2.43.2 + TailwindCSS (UnoCSS) - **Workflow**: Vue Flow 1.48.1 - **Boilerplate**: Soybean Admin - **Package Management**: pnpm (Monorepo) ----------------------------------- ## 📂 Project Structure KMatrix follows a frontend-backend separation architecture. The code is organized as follows: ```none KMatrix/ ├── kmatrix-service/ # Backend service (Maven multi-module) │ ├── ruoyi-admin/ # Web service entry point │ ├── ruoyi-ai/ # AI core module (LangChain, RAG, Workflow) │ ├── ruoyi-common/ # Common module │ └── ... ├── kmatrix-ui/ # Frontend project (pnpm workspace) │ ├── apps/ │ │ ├── admin/ # Admin dashboard (Knowledge base management, App orchestration) │ │ └── chat/ # Chat window (Embedded AI assistant) │ ├── packages/ # Shared packages (hooks, utils, materials) │ └── ... └── docker/ # Container deployment scripts ``` This repository contains the backend project. Link to the frontend project: [https://github.com/mahoneliu/Kmatrix-ui](https://github.com/mahoneliu/Kmatrix-ui) ----------------------------------- ## 🚀 Quick Start ### Deployment via Docker - For a quick trial and exploration, it's highly recommended to use Docker for simple and fast deployment. - One-click startup: ```bash * Linux: docker run -d --name kmatrix-standalone -p 80:80 -v ~/kmatrix-data:/kmatrix-data registry.cn-guangzhou.aliyuncs.com/kyxxjs/kmatrix:latest * Windows: docker run -d --name kmatrix-standalone -p 80:80 -v c:\kmatrix-data:/kmatrix-data registry.cn-guangzhou.aliyuncs.com/kyxxjs/kmatrix:latest ``` - After all containers show a `healthy` status, access KMatrix via your browser: - http://[Target-Server-IP] - Default Login: - Username: admin - Default Password: admin123 ### Deployment via Source Code #### Prerequisites - **JDK**: >= 17 - **Node.js**: >= 20.19.0 - **pnpm**: >= 9.x - **Database**: PostgreSQL 15+ (requires `vector` plugin and `jieba` tokenizer) - **Redis**: 6.x+ 1. **Environment Setup**: - Install Redis. - Download the rerank model. - Install PostgreSQL and enable pgvector extension and jieba tokenizer. Note: PG deployment scripts and rerank model download scripts are available in the `script` directory. The project uses flyway to manage SQL. The startup project will automatically execute the initialization SQL. The SQL directory is: /kmatrix-admin/src/resources/sql. 2. **Backend Startup (kmatrix-service)**: ```bash cd kmatrix-service # Copy application-sample.yml to application-dev.yml and modify database, Redis, and rerank model configurations. mvn clean install # Start the ruoyi-admin module java -jar ruoyi-admin/target/ruoyi-admin.jar ``` 3. **Frontend Startup (kmatrix-ui)**: ```bash cd kmatrix-ui pnpm install # Start the admin dashboard pnpm dev:admin # Start the chat app pnpm dev:chat ``` ----------------------------------- ## 🔗 Links and Contact - **Online Demo**: [http://kmatrix-admin.kykms.cn](http://kmatrix-admin.kykms.cn) (Credentials: test/666666 or testadmin/admin123), Note: Data will be reset daily. - **Floating Window Demo**: Visit the [KMatrix Official Website](http://kmatrix.kykms.cn), check the chat icon in the bottom-right corner. - **Tech Documentation**: [Quick Start](http://docs.kykms.cn/docs/kmatrix/kmatrix-1h4rc8em9u0c4) - **WeChat**: Scan to join the community or for business cooperation. ![WeChat](./docs/images/wechat.jpg) - **Email**: ----------------------------------- ## 🤝 Special Thanks KMatrix stands on the shoulders of giants. Special thanks to these excellent open-source projects: - **RuoYi-Vue-Plus**: [https://gitee.com/dromara/RuoYi-Vue-Plus](https://gitee.com/dromara/RuoYi-Vue-Plus) - **Soybean Admin**: [https://github.com/soybeanjs/soybean-admin](https://github.com/soybeanjs/soybean-admin) - **LangChain4j**: [https://github.com/langchain4j/langchain4j](https://github.com/langchain4j/langchain4j) - **Vue Flow**: [https://github.com/bcakmakoglu/vue-flow](https://github.com/bcakmakoglu/vue-flow) ----------------------------------- ## 📄 License This software is licensed under the **MIT** License. You are free to use, modify, and distribute it, provided you retain the original copyright notice.