Content
# Bedrock Cloud
## 📖 Project Introduction
Bedrock Cloud is an enterprise-level cloud service platform based on **Spring Cloud** microservice architecture. The project adopts a front-end and back-end separation distributed microservice design, integrating core functional modules such as authentication and authorization, system management, resource management, log recording, WebSocket real-time communication, and **AI dialogue and knowledge base**, providing complete infrastructure support for enterprise applications.
This project is built based on the [bedrock-commons](https://github.com/Bedrock0105/bedrock-commons.git) basic framework component library, fully utilizing its provided general functional modules and best practices (including `bedrock-common-ai` / Spring AI).
### 🌐 Online Demo
| Project | Description |
|------|------|
| Demo Address | http://24.233.0.202/ |
| Account / Password | `superadmin` / `superadmin` |
See interface screenshots in the front-end warehouse [bedrock-ui](https://github.com/Bedrock0105/bedrock-ui.git) README.
### 🔗 Related Repositories
| Project | Address |
|------|------|
| Front-end bedrock-ui | https://github.com/Bedrock0105/bedrock-ui.git |
| Public Component bedrock-commons | https://github.com/Bedrock0105/bedrock-commons.git |
### ✨ Core Features
- 🏗️ **Microservice Architecture**: Based on Spring Cloud Gateway + Nacos + OpenFeign microservice architecture
- 🔐 **Unified Authentication**: OAuth2 + JWT implements unified authentication and authorization center
- 🚪 **API Gateway**: Spring Cloud Gateway implements routing forwarding, authentication, and rate limiting
- 📦 **Modular Design**: Clear module division, supporting independent deployment and expansion
- 🔄 **Service Governance**: Integrated Nacos service registration and discovery with configuration center
- 📊 **System Management**: Complete user, role, permission, organization, dictionary, and other management functions
- 💾 **Resource Management**: Supports OSS object storage configuration and management
- 📝 **Log Tracking**: Operation log recording and query
- 🔌 **WebSocket**: Real-time bidirectional communication support
- 🤖 **AI Capability**: Multi-vendor model, streaming dialogue, knowledge base RAG, vector database, MCP/tool, token statistics
- 📚 **API Documentation**: Integrated Knife4j automatic generation of interface documentation
- 🏢 **Multi-tenancy**: Supports multi-tenancy data isolation
- 🎯 **Code Generation**: Based on bedrock-commons code generation capability
## 🛠️ Technical Stack
### Basic Environment
- **Java Version**: JDK 17+
- **Build Tool**: Maven 3.6+
- **Encoding Format**: UTF-8
### Core Framework
| Framework | Description |
|------|------|
| Spring Boot | Application framework |
| Spring Cloud | Microservice framework |
| Spring Cloud Alibaba | Alibaba microservice solution |
| Nacos | Service registration and discovery with configuration center |
| Spring Cloud Gateway | API gateway |
| OpenFeign | Declarative service invocation |
| OAuth2 + JWT | Authentication and authorization |
### Data Storage
| Component | Description |
|------|------|
| MySQL | Relational database |
| Redis | Cache and session storage |
| MyBatis-Plus | ORM framework |
| Druid | Database connection pool |
### Other Components
| Component | Description |
|------|------|
| Knife4j | API documentation enhancement |
| Lombok | Simplify Java code |
| FastExcel | Excel processing |
| Protostuff | Serialization framework |
| Spring AI | Large model, vector database, Advisor, MCP (via `bedrock-common-ai`) |
| Redis Stack (optional) | RediSearch + RedisJSON, used as vector database backend |
## 📦 Project Structure
```
bedrock-cloud/
├── bedrock-api/ # API interface definition module (Feign client)
│ ├── bedrock-system-api/ # System management API
│ ├── bedrock-resource-api/ # Resource management API
│ ├── bedrock-log-api/ # Log management API
│ ├── bedrock-websocket-api/# WebSocket API
│ └── bedrock-ai-api/ # AI service API (entity / parameter / VO)
├── bedrock-auth/ # Authentication and authorization service
├── bedrock-common/ # Public module
├── bedrock-gateway/ # API gateway service
├── bedrock-modules/ # Business module
│ ├── bedrock-system/ # System management service
│ ├── bedrock-resource/ # Resource management service
│ ├── bedrock-log/ # Log management service
│ ├── bedrock-websocket/ # WebSocket service
│ └── bedrock-ai/ # AI service (dialogue / knowledge base / MCP)
├── doc/ # Documentation and configuration
│ ├── nacos/ # Nacos configuration file
│ └── sql/ # Database script (including bedrock-ai.sql)
└── pom.xml # Parent POM
```
## 📋 Module Description
### 1. bedrock-api - API Interface Definition Module
**Description**: Defines Feign client interfaces, parameter objects, and return value objects between microservices for service invocation.
**Sub-modules**:
#### bedrock-system-api
- **Function**: System management-related Feign client interfaces
- **Content**:
- Administrator management (IAdminClient)
- Online user management (IAdminOnlineClient)
- Dictionary management (IDictClient)
- System management (ISystemClient)
- Entity classes: Admin, Role, Menu, Dept, Dict, Tenant, etc.
- Parameter objects and VO objects
#### bedrock-resource-api
- **Function**: Resource management-related Feign client interfaces
- **Content**:
- OSS configuration management
- Resource upload and download interfaces
- Entity classes: OssConfig
- Parameter objects and VO objects
#### bedrock-log-api
- **Function**: Log management-related Feign client interfaces
- **Content**:
- Operation log recording
- Log query interfaces
- Parameter objects and VO objects
#### bedrock-websocket-api
- **Function**: WebSocket-related Feign client interfaces
- **Content**:
- WebSocket message push
- Online user management
- DTO and enumeration definitions
#### bedrock-ai-api
- **Function**: AI service-related entities, parameters, VO, enumerations, and constants (for `bedrock-ai` and front-end contract reuse)
- **Content**:
- Entities: `AiApiKey`, `AiModel`, `AiRole`, `AiChatRecord`, `AiChatMessage`, `AiKnowledge*`, `AiVectorDb`, `AiMcp`, `AiTokenUsage`, etc.
- Dialogue / knowledge base / token parameter, VO
- Attachment DTO: `UserMessageAttachment`
- Dictionary and error code: `AiPlatform`, model type, slicing mode, etc.
### 2. bedrock-auth - Authentication and Authorization Service
**Description**: Unified authentication and authorization center based on OAuth2 + JWT, responsible for user login authentication, token issuance, and verification.
**Core Functions**:
- OAuth2 password mode authentication
- JWT token generation and refresh
- Client management
- User authentication information encapsulation
- Support for multiple authorization methods extension
**Technology Stack**:
- bedrock-common-cloud (microservice foundation)
- bedrock-common-authentication (OAuth2 authentication)
- bedrock-system-api (user information service)
**Main Classes**:
- `AuthApplication`: Startup class
- `AuthController`: Authentication controller
- `AuthService`: Authentication service
- `JwtUtil`: JWT utility class
**Port**: Default from Nacos configuration
### 3. bedrock-gateway - API Gateway Service
**Description**: API gateway based on Spring Cloud Gateway, providing unified routing forwarding, authentication, rate limiting, and logging.
**Core Functions**:
- Dynamic routing configuration
- Unified identity authentication and authorization
- Request filtering and interception
- Load balancing
- API documentation aggregation (Knife4j Gateway)
- Cross-domain processing
- Exception unified processing
**Technology Stack**:
- Spring Cloud Gateway (responsive gateway)
- Spring WebFlux
- LoadBalancer (load balancing)
- Redis (session and rate limiting)
- Nacos (service discovery)
- Knife4j Gateway (document aggregation)
**Main Components**:
- `GatewayApplication`: Startup class
- Global filter: authentication filter, log filter, etc.
- Routing configuration
- Exception processor
**Features**:
- Exclude MySQL, Web MVC, and other unnecessary dependencies
- Use responsive programming model
- Support dynamic routing refresh
### 4. bedrock-common - Public Module
**Description**: Project public foundation module, providing general configuration, utility classes, and dependencies.
**Core Functions**:
- Database driver (MySQL)
- Serialization tool (Protostuff)
- Public code module reference
- SPI extension support
**Dependencies**:
- bedrock-common-code (from bedrock-commons)
- bedrock-common-spi (from bedrock-commons)
- MySQL Connector
- Protostuff serialization
### 5. bedrock-modules - Business Module Collection
**Description**: Parent module containing all business microservice modules.
#### 5.1 bedrock-system - System Management Service
**Function**: Provides complete system management functions, including user, role, permission, menu, department, dictionary, tenant, and other management.
**Core Functions**:
- **Administrator Management**: User CRUD, password reset, status management
- **Role Management**: Role definition, permission allocation
- **Menu Management**: Menu configuration, permission control
- **Department Management**: Organization architecture management
- **Dictionary Management**: Data dictionary maintenance
- **Tenant Management**: Multi-tenancy configuration and management
- **Online User**: Online user query and management
- **Parameter Configuration**: System parameter configuration
**Technology Stack**:
- bedrock-common-cloud (microservice foundation)
- bedrock-system-api (API definition)
- bedrock-common-excel (Excel import and export)
**Main Entities**:
- `Admin`: Administrator
- `Role`: Role
- `Menu`: Menu
- `Dept`: Department
- `Dict`: Dictionary
- `Tenant`: Tenant
- `AdminRole`: User-role association
- `RoleMenu`: Role-menu association
#### 5.2 bedrock-resource - Resource Management Service
**Function**: Provides file resource management and OSS object storage configuration functions.
**Core Functions**:
- OSS configuration management (Aliyun OSS, Tencent Cloud COS, etc.)
- File upload and download
- Resource access control
- Storage configuration switching
**Technology Stack**:
- bedrock-common-cloud (microservice foundation)
- bedrock-resource-api (API definition)
**Main Entities**:
- `OssConfig`: OSS configuration information
#### 5.3 bedrock-log - Log Management Service
**Function**: Provides operation log recording and query functions.
**Core Functions**:
- Operation log asynchronous recording
- Log query and statistics
- Log export
- Link tracking
**Technology Stack**:
- bedrock-common-cloud (microservice foundation)
- bedrock-log-api (API definition)
- bedrock-common-log (log component)
#### 5.4 bedrock-websocket - WebSocket Service
**Function**: Provides WebSocket real-time communication functions.
**Core Functions**:
- WebSocket connection management
- Real-time message push
- Online user status maintenance
- Heartbeat detection
- Point-to-point and broadcast messages
**Technology Stack**:
- bedrock-common-cloud (microservice foundation)
- bedrock-websocket-api (API definition)
- bedrock-common-websocket (WebSocket component)
**Application Scenarios**:
- Real-time notification push
- Online chat
- Real-time data update
- System message reminder
#### 5.5 bedrock-ai - AI Service
**Function**: AI business service based on Spring AI + `bedrock-common-ai`, providing multi-vendor model access, streaming dialogue, knowledge base RAG, vector database, MCP/tool, and token usage statistics.
**Core Functions**:
- **API Key / Model Management**: Multi-vendor key and Chat / Embedding / Image / Speech model configuration
- **AI Role**: System prompt word and role preset
- **Streaming Dialogue**: SSE (`/ai-chat-record/send-char-stream`), supporting attachment, historical memory, knowledge base retrieval, tool, and MCP
- **Creative Ability**: Image generation, mind map, article, etc. streaming / synchronous generation interface
- **Knowledge Base RAG**: Knowledge base / document / block management, document analysis and slicing into database, vector recall during dialogue
- **Vector Database**: Configurable Redis / Milvus / ES / Simple (default dependency includes Redis Store)
- **MCP / Local Tool**: Dynamic MCP client + `@ToolProvider` local tool
- **Token Statistics**: Statistics usage and trend by session / model
**Technology Stack**:
- `bedrock-common-cloud` (microservice foundation)
- `bedrock-common-ai` (model factory, vector database factory, Advisor, tool / MCP)
- `bedrock-ai-api` (API definition)
- `bedrock-resource-api` (attachment OSS)
- Spring AI (Tika document reading, MCP client, Redis Vector Store, etc.)
**Main Interface Prefixes**:
| Prefix | Description |
|------|------|
| `/ai-api-key` | API Key |
| `/ai-model` | Model |
| `/ai-role` | AI Role |
| `/ai-chat-record` | Session / streaming send / creation |
| `/ai-chat-message` | Message details |
| `/ai-knowledge` / `-doc` / `-chunk` | Knowledge base |
| `/ai-vector-db` | Vector database configuration |
| `/ai-mcp` / `/ai-tool` | MCP and tool |
| `/ai-token-usage` | Token usage |
**Startup Class**: `org.bedrock.ai.AIApplication` (service name `bedrock-ai`)
**Database Script**:
- Full: `doc/sql/mysql/bedrock-ai.sql` (table structure + menu dictionary)
- Incremental: `bedrock-ai-chat-message-rag-attachment.sql`, `*-menu.sql`, `*-dict.sql`, etc.
**Division with Public Module**:
- `bedrock-common-ai`: Factory, Advisor skeleton, SPI contract
- `bedrock-ai`: Configuration into database, knowledge base strategy, message and token persistence, specific enhancement and retrieval implementation
See [bedrock-commons / AI Public Module](../bedrock-commons/doc/23-AI%E5%85%B1%E6%9C%96%E9%83%A8%E4%BB%B6.md) for public capability description.
## 🚀 Quick Start
### Prerequisites
- JDK 17+
- Maven 3.6+
- MySQL 5.7+ / 8.0+
- Redis 6.0+ (if using Redis vector database, need **Redis Stack**: RediSearch + RedisJSON)
- Nacos 2.x+
### 1. Clone and Install Dependency
First, ensure [bedrock-commons](https://gitee.com/your-repo/bedrock-commons) is installed to local Maven repository:
```bash
git clone https://gitee.com/your-repo/bedrock-commons.git
cd bedrock-commons
mvn clean install
```
### 2. Clone Project
```bash
git clone https://gitee.com/your-repo/bedrock-cloud.git
cd bedrock-cloud
```
### 3. Initialize Database
Execute `doc/sql/mysql/bedrock.sql` script to create database and tables:
```bash
mysql -u root -p < doc/sql/mysql/bedrock.sql
```
Enable AI module, then execute AI script (table structure, menu, dictionary):
```bash
mysql -u root -p bedrock < doc/sql/mysql/bedrock-ai.sql
```
Existing database upgrade can be executed incrementally with `doc/sql/mysql/bedrock-ai-*.sql` scripts as needed.
### 4. Configure Nacos
1. Start Nacos Server
2. Import `doc/nacos/application-dev.yml` configuration into Nacos configuration center
3. Modify database, Redis, and other configurations according to actual environment
### 5. Modify Configuration
Modify configuration in Nacos according to actual situation:
```yaml
# Data source configuration
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/bedrock?...
username: your_username
password: your_password
# Redis configuration
data:
redis:
host: 127.0.0.1
port: 6379
password: your_redis_password
```
### 6. Compile and Package
```bash
mvn clean package
```
### 7. Start Service
It is recommended to start services in the following order:
```bash
# 1. Start gateway
java -jar bedrock-gateway/target/bedrock-gateway.jar
# 2. Start authentication service
java -jar bedrock-auth/target/bedrock-auth.jar
```
# 3. Start System Service
java -jar bedrock-modules/bedrock-system/target/bedrock-system.jar
# 4. Start Resource Service
java -jar bedrock-modules/bedrock-resource/target/bedrock-resource.jar
# 5. Start Log Service
java -jar bedrock-modules/bedrock-log/target/bedrock-log.jar
# 6. Start WebSocket Service
java -jar bedrock-modules/bedrock-websocket/target/bedrock-websocket.jar
# 7. Start AI Service (Optional)
java -jar bedrock-modules/bedrock-ai/target/bedrock-ai.jar
Or use IDE to run the Application startup class of each module (AI: `AIApplication`).
### 8. Access Service
- **API Documentation**: http://localhost:gateway-port/doc.html
- **Nacos Console**: http://localhost:8848/nacos
- **Spring Boot Admin**: If monitoring is configured, access the corresponding address
## ⚙️ Configuration Instructions
### Nacos Configuration
The project uses Nacos as the configuration center and service registry. The main configuration items include:
#### Application Configuration (application-dev.yml)
```yaml
bedrock:
security:
# Interfaces that do not require authentication
ignore-urls:
- /v3/api-docs
- /oauth/token
# Data Source Configuration
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/bedrock?...
username: root
password: password
driver-class-name: com.mysql.cj.jdbc.Driver
# Redis Configuration
data:
redis:
host: 127.0.0.1
port: 6379
password: password
database: 0
ssl:
enabled: false
```
### Service Ports
Each service port is specified in the Nacos configuration. It is recommended to plan as follows:
| Service | Port | Description |
|------|------|------|
| bedrock-gateway | 8080 | API Gateway |
| bedrock-auth | 8081 | Authentication Service |
| bedrock-system | 8082 | System Service |
| bedrock-resource | 8083 | Resource Service |
| bedrock-log | 8084 | Log Service |
| bedrock-websocket | 8085 | WebSocket Service |
| bedrock-ai | 8086 | AI Service (Conversation/Knowledge Base; local `application.yml` defaults to 8085, it is recommended to change to a non-conflicting port in Nacos) |
## 🔐 Authentication and Authorization
### OAuth2 Authentication Process
1. Client requests Token: `POST /oauth/token`
2. Carries username, password, and client information
3. Obtains access_token and refresh_token
4. Subsequent requests carry Token in Header: `Authorization: Bearer {token}`
### Default Account
A super administrator account is preset in the database:
- **Username**: superadmin
- **Password**: needs to view the encrypted password in the database or contact the administrator to reset
### Client Configuration
Default client configuration:
- **client_id**: artdesigpro
- **client_secret**: artdesigpro_secret
- **Authorization Type**: password, refresh_token
## 📊 Database Design
### Core Table Description
| Table Name | Description |
|------|------|
| bedrock_admin | Administrator Table |
| bedrock_role | Role Table |
| bedrock_menu | Menu Permission Table |
| bedrock_dept | Department Organization Table |
| bedrock_dict | Data Dictionary Table |
| bedrock_tenant | Tenant Table |
| bedrock_client | OAuth2 Client Table |
| bedrock_admin_role | User Role Association Table |
| bedrock_admin_dept | User Department Association Table |
| bedrock_role_menu | Role Menu Association Table |
| bedrock_admin_online | Online User Table |
| bedrock_oss_config | OSS Configuration Table |
#### AI Related Tables (`doc/sql/mysql/bedrock-ai.sql`)
| Table Name | Description |
|------|------|
| bedrock_ai_api_key | AI API Key Configuration |
| bedrock_ai_model | AI Model Configuration |
| bedrock_ai_role | AI Role/System Prompt Word |
| bedrock_ai_chat_record | Chat Session |
| bedrock_ai_chat_message | Chat Message (including attachments/chunk_ids) |
| bedrock_ai_token_usage | Token Usage |
| bedrock_ai_knowledge | Knowledge Base |
| bedrock_ai_knowledge_doc | Knowledge Base Document |
| bedrock_ai_knowledge_chunk | Knowledge Base Chunk |
| bedrock_ai_vector_db | Vector Database Connection Configuration |
| bedrock_ai_mcp | MCP Service Configuration |
For detailed table structure, please refer to `doc/sql/mysql/bedrock.sql` and `doc/sql/mysql/bedrock-ai.sql`
## 🔧 Development Guide
### Add New Module
1. Create a new API module in `bedrock-api`
2. Define Feign client interface, parameters, and return values
3. Create an implementation module in `bedrock-modules`
4. Implement business logic
5. Configure routing in the gateway (if necessary)
### Inter-Service Calls
Use OpenFeign for inter-service calls:
```java
@FeignClient("bedrock-system")
public interface ISystemClient {
@GetMapping("/admin/info")
Result<AdminVO> getAdminInfo(@RequestParam Long id);
}
```
### Permission Control
Add permission annotations to Controller methods:
```java
@PreAuthorize("@ss.hasPerm('system:admin:list')")
@GetMapping("/list")
public Result<List<AdminVO>> list() {
// ...
}
```
### Excel Import and Export
Use the bedrock-common-excel component:
```java
@PostMapping("/export")
public void export(HttpServletResponse response) {
ExcelUtils.export(response, "User List", dataList, AdminExportVO.class);
}
```
## 📝 API Documentation
The project integrates Knife4j to automatically generate API documentation. After starting the service, access:
- **Gateway Aggregated Documentation**: http://localhost:gateway-port/doc.html
- **Independent Documentation for Each Service**: http://localhost:service-port/doc.html
## 🐛 Frequently Asked Questions
### 1. Service Startup Failure
- Check if Nacos is running normally
- Check if database and Redis connection configurations are correct
- Check if ports are occupied
### 2. Inter-Service Call Failure
- Confirm if the service is registered in Nacos
- Check if the Feign client definition is correct
- View service logs to troubleshoot issues
### 3. Authentication Failure
- Check OAuth2 client configuration
- Confirm if the Token has expired
- Check if Redis is normal
### 4. Gateway Routing Issues
- Check routing configurations in Nacos
- Confirm if the target service is running normally
- View gateway logs
### 5. AI/Vector Database Related
- **AI SQL Not Executed**: Execute `doc/sql/mysql/bedrock-ai.sql` first
- **Redis Filter Field Error** (`Not allowed filter identifier name` / `Unknown field ... knowledgeId`): When creating a vector index, declare filterable metadata; old indexes need to be deleted or rebuilt with a new indexName, see [AI Public Module Documentation](../bedrock-commons/doc/23-AI公共模块.md)
- **Streaming Dialogue No Output**: Confirm the gateway does not buffer SSE, and the client consumes `/ai-chat-record/send-char-stream` according to `text/event-stream`
## 🤝 Contribution
We welcome contributions in any form!
1. **Fork** this repository
2. Create a new **Feat_xxx** branch (Feature function/Bugfix repair)
3. Submit code, ensuring it complies with specifications
4. Create a new **Pull Request**
5. Wait for code review and merge
### Contribution Guide
- Follow existing code styles and specifications
- Add necessary unit tests
- Update relevant documentation
- Submit information clearly and concisely
## 📄 License
This project adopts the MIT open-source protocol. See the [LICENSE](LICENSE) file for details.
**⭐ If this project helps you, give it a Star!**
MCP Config
Below is the configuration for this MCP Server. You can copy it directly to Cursor or other MCP clients.
mcp.json
Connection Info
You Might Also Like
No recommendations available