Skip to content

mahoneliu/KMatrix-service

Repository files navigation

kmatrix

其他语言: 中文

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.

🛠️ 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:

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


🚀 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:
* 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):

    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):

    cd kmatrix-ui
    pnpm install
    # Start the admin dashboard
    pnpm dev:admin
    # Start the chat app
    pnpm dev:chat

🔗 Links and Contact


🤝 Special Thanks

KMatrix stands on the shoulders of giants. Special thanks to these excellent open-source projects:


📄 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.

About

KMatrix is an LLM workflow application and RAG (Retrieval-Augmented Generation) knowledge base system built upon RuoYi and LangChain4j / Langgraph4j. Drawing inspiration from projects like MaxKB and Dify, it delivers the stability, security, and scalability required for enterprise-grade applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors