a7e7c85ff6e9297cb3f465e78e8e526cb9f9da10
缺陷修复: - PermissionService.setRolePermissions 增加 isSystem 检查 系统角色的权限不可被修改(之前可被任意改写) 测试覆盖(94项全部通过): - PHASE A: 身份认证(登录/错误密码/无效token/空凭据 8项) - PHASE B: 三层角色权限边界(26/21/5 权限一致性 3项) - PHASE C: 创建用户异常(重复/短密码/空字段/特殊字符 7项) - PHASE D: 编辑&角色变更(改名/升降级/非法值/并发/跨角色 12项) - PHASE E: 删除异常(删自己/admin/不存在/USER删/TA删 12项) - PHASE F: 权限系统(角色CRUD/权限改/权限一致性/元数据 25项) - PHASE G: 模块可达性(2项,非致命) - PHASE H: 前端UI(admin/ta_admin/user1 三角色 22项) - PHASE I: 边界缺陷(跨租户隔离/超长名 2项) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
AuraK
AuraK is a multi-tenant intelligent AI knowledge base platform. Built with React + NestJS, it's a full-stack RAG (Retrieval-Augmented Generation) system with external API support, RBAC, and tenant isolation.
✨ Features
- 🔐 User System: Complete user registration, login, and permission management
- 🤖 Multi-Model Support: OpenAI-compatible interfaces + Google Gemini native support
- 📚 Intelligent Knowledge Base: Document upload, chunking, vectorization, hybrid search
- 💬 Streaming Chat: Real-time display of processing status and generated content
- 🔍 Citation Tracking: Clear display of source documents and related segments for answers
- 🌍 Multi-Language Support: Japanese, Chinese, and English for interface and AI responses
- 👁️ Vision Capabilities: Supports multimodal models for image processing
- ⚙️ Flexible Configuration: User-specific API keys and inference parameter customization
- 🎯 Dual-Mode Processing: Fast mode (Tika) + High-precision mode (Vision Pipeline)
- 💰 Cost Management: User quota management and cost estimation
🏗️ Tech Stack
Frontend
- Framework: React 19 + TypeScript + Vite
- Styling: Tailwind CSS
- Icons: Lucide React
- State Management: React Context
Backend
- Framework: NestJS + TypeScript
- AI Framework: LangChain
- Database: SQLite (metadata) + Elasticsearch (vector storage)
- File Processing: Apache Tika + Vision Pipeline
- Authentication: JWT
- Document Conversion: LibreOffice + ImageMagick
🏢 Internal Network Deployment
This system supports deployment in internal networks. Main modifications include:
- External Resources: KaTeX CSS moved from external CDN to local resources
- AI Models: Supports configuring internal AI model services without external API access
- Build Configuration: Dockerfiles can be configured to use internal image registries
See Internal Deployment Guide for detailed configuration instructions.
🚀 Quick Start
Prerequisites
- Node.js 18+
- Yarn
- Docker & Docker Compose
1. Clone the Project
git clone <repository-url>
cd simple-kb
2. Install Dependencies
yarn install
3. Start Basic Services
docker-compose up -d elasticsearch tika libreoffice
4. Configure Environment Variables
# Backend environment setup
cp server/.env.sample server/.env
# Edit server/.env file (set API keys, etc.)
# Frontend environment setup
cp web/.env.example web/.env
# Edit web/.env file (modify frontend settings as needed)
See the comments in server/.env.sample and web/.env.example for detailed configuration.
5. Start Development Server
yarn dev
Access http://localhost:5173 to get started!
📖 User Guide
1. User Registration/Login
- Account registration is required for first-time use.
- Each user has their own independent knowledge base and model settings.
2. AI Model Configuration
- Add AI models from "Model Management".
- Supports OpenAI, DeepSeek, Claude and other compatible interfaces.
- Supports Google Gemini native interface.
- Configure LLM, Embedding, and Rerank models.
3. Document Upload
- Supports various formats: PDF, Word, PPT, Excel, etc.
- Choose between Fast mode (text-only) or High-precision mode (image + text mixed).
- Adjustable chunk size and overlap for documents.
- Select embedding model for vectorization.
4. Start Intelligent Q&A
- Ask questions based on uploaded documents.
- View search and generation process in real-time.
- Check answer sources and related document fragments.
🔧 Configuration Guide
Model Settings
- LLM Model: Used for dialogue generation (e.g., GPT-4, Gemini-1.5-Pro)
- Embedding Model: Used for document vectorization (e.g., text-embedding-3-small)
- Rerank Model: Used for re-ranking search results (optional)
Inference Parameters
- Temperature: Controls answer randomness (0-1)
- Max Tokens: Maximum output length
- Top K: Number of document segments to search
- Similarity Threshold: Filters low-relevance content
📁 Project Structure
simple-kb/
├── web/ # Frontend application
│ ├── components/ # React components
│ ├── services/ # API services
│ ├── contexts/ # React Context
│ └── utils/ # Utility functions
├── server/ # Backend application
│ ├── src/
│ │ ├── auth/ # Authentication module
│ │ ├── chat/ # Chat module
│ │ ├── knowledge-base/ # Knowledge base module
│ │ ├── model-config/ # Model configuration module
│ │ └── user/ # User module
│ └── data/ # Data storage
├── docs/ # Project documentation
└── docker-compose.yml # Docker configuration
📚 Documentation
- System Design Document
- Current Implementation Status
- API Documentation
- Deployment Guide
- RAG Feature Implementation
🐳 Docker Deployment
Development Environment
# Start basic services
docker-compose up -d elasticsearch tika
# Local development
yarn dev
Production Environment
# Build and start all services
docker-compose up -d
🤝 Contributing
- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is provided under the MIT license. See the LICENSE file for details.
🙏 Acknowledgments
- LangChain - AI application development framework
- NestJS - Node.js backend framework
- React - Frontend UI framework
- Elasticsearch - Search and analytics engine
- Apache Tika - Document parsing tool
📞 Support
For questions or suggestions, please submit an Issue or contact the maintainers.
Description
Languages
TypeScript
86.6%
JavaScript
10.9%
Python
1.6%
CSS
0.5%
Shell
0.2%
Other
0.1%