|
1 |
| -## Introduction |
| 1 | +# SoybeanAdmin Rust |
2 | 2 |
|
3 |
| -[soybean-admin-rust](https://github.com/ByteByteBrew/soybean-admin-rust) is a backend API service for administrative systems, developed using Rust. This project utilizes [Axum](https://docs.rs/axum/latest/axum/) to handle web requests efficiently and [SeaORM](https://www.sea-ql.org/SeaORM/) for effective database management. Designed with simplicity and maintainability in mind, `soybean-admin-rust` provides a stable and straightforward solution for managing backend operations, catering to the needs of modern administrative applications. |
| 3 | +<p align="center"> |
| 4 | +<a href="https://github.com/soybeanjs/soybean-admin-rust/blob/main/LICENSE"> |
| 5 | +<img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="license"/> |
| 6 | +</a> |
| 7 | +<a href="https://github.com/soybeanjs/soybean-admin-rust/stargazers"> |
| 8 | +<img src="https://img.shields.io/github/stars/soybeanjs/soybean-admin-rust.svg" alt="stars"/> |
| 9 | +</a> |
| 10 | +<a href="https://github.com/soybeanjs/soybean-admin-rust/network/members"> |
| 11 | +<img src="https://img.shields.io/github/forks/soybeanjs/soybean-admin-rust.svg" alt="forks"/> |
| 12 | +</a> |
| 13 | +<a href="https://github.com/soybeanjs/soybean-admin-rust/issues"> |
| 14 | +<img src="https://img.shields.io/github/issues/soybeanjs/soybean-admin-rust.svg" alt="issues"/> |
| 15 | +</a> |
| 16 | +</p> |
| 17 | +<p align="center"> |
| 18 | +<a href="#简介">简介</a> • |
| 19 | +<a href="#特性">特性</a> • |
| 20 | +<a href="#项目结构">项目结构</a> • |
| 21 | +<a href="#快速开始">快速开始</a> • |
| 22 | +<a href="#技术栈">技术栈</a> • |
| 23 | +<a href="#贡献指南">贡献指南</a> • |
| 24 | +<a href="#许可证">许可证</a> |
| 25 | +</p> |
| 26 | + |
| 27 | +## 简介 |
| 28 | + |
| 29 | +SoybeanAdmin Rust 是一个基于 Rust 语言开发的现代化后台管理系统脚手架。项目采用 Axum 作为 Web 框架,SeaORM 作为数据库 ORM,提供了完整的后台管理基础功能实现。本项目特别注重性能和安全性,充分发挥了 Rust 语言的优势,为开发者提供一个强类型、高性能的后台管理系统开发基础。 |
| 30 | + |
| 31 | +项目实现了基础的 RBAC 权限管理体系,包括用户管理、角色管理、菜单管理等核心功能。无论是作为学习 Rust Web 开发的示例,还是作为实际项目的起点,都是一个理想的选择。 |
| 32 | + |
| 33 | +## 特性 |
| 34 | + |
| 35 | +- **高性能框架**:基于 Axum 的异步 Web 框架,提供极致的性能表现 |
| 36 | +- **类型安全**:充分利用 Rust 的类型系统,在编译时捕获潜在错误 |
| 37 | +- **基础功能**: |
| 38 | + - 用户管理 |
| 39 | + - 角色管理 |
| 40 | + - 菜单管理 |
| 41 | +- **权限管理**: |
| 42 | + - 基于 Casbin 的 RBAC 权限控制 |
| 43 | + - 支持多种权限模型配置 |
| 44 | + - 灵活的策略管理 |
| 45 | +- **数据库操作**: |
| 46 | + - 使用 SeaORM 提供类型安全的数据库操作 |
| 47 | + - 支持数据库迁移 |
| 48 | + - 连接池管理 |
| 49 | +- **安全特性**: |
| 50 | + - JWT 身份认证 |
| 51 | + - 密码加密存储 |
| 52 | + - CORS 配置 |
| 53 | +- **开发体验**: |
| 54 | + - 模块化的项目结构 |
| 55 | + - 统一的错误处理 |
| 56 | + - 完整的日志系统 |
| 57 | + - YAML 配置文件支持 (未来将支持 TOML、Properties 等) |
| 58 | + |
| 59 | +## 开发计划 |
| 60 | + |
| 61 | +- [ ] 操作日志记录 |
| 62 | +- [ ] 请求限流 |
| 63 | +- [ ] Redis 支持 |
| 64 | +- [ ] API 文档生成 |
| 65 | +- [ ] 多配置文件格式支持 |
| 66 | +- [ ] 更多权限模型支持 |
| 67 | + |
| 68 | +## 项目结构 |
| 69 | + |
| 70 | +``` |
| 71 | +soybean-admin-rust/ |
| 72 | +├── .cargo/ # Cargo 配置 |
| 73 | +├── axum-casbin/ # Axum Casbin 适配器 |
| 74 | +├── migration/ # 数据库迁移 |
| 75 | +├── sea-orm-adapter/ # SeaORM Casbin 适配器 |
| 76 | +├── server/ # 服务端代码 |
| 77 | +│ ├── api/ # API 接口定义 |
| 78 | +│ ├── bin/ # 可执行文件 |
| 79 | +│ ├── config/ # 配置管理 |
| 80 | +│ ├── constant/ # 常量定义 |
| 81 | +│ ├── core/ # 核心功能模块 |
| 82 | +│ ├── global/ # 全局变量和状态 |
| 83 | +│ ├── initialize/ # 初始化逻辑 |
| 84 | +│ ├── middleware/ # 中间件 |
| 85 | +│ ├── model/ # 数据模型 |
| 86 | +│ ├── resource/ # 资源文件 |
| 87 | +│ ├── resources/ # 静态资源 |
| 88 | +│ ├── router/ # 路由定义 |
| 89 | +│ ├── service/ # 业务逻辑 |
| 90 | +│ ├── shared/ # 共享代码 |
| 91 | +│ └── utils/ # 工具函数 |
| 92 | +├── xdb/ # ip2region |
| 93 | +``` |
| 94 | + |
| 95 | +## 快速开始 |
| 96 | + |
| 97 | +### 环境要求 |
| 98 | + |
| 99 | +- Rust 1.75.0 或更高版本 |
| 100 | +- PostgreSQL 13 或更高版本 |
| 101 | + |
| 102 | +### 安装步骤 |
| 103 | + |
| 104 | +1. 克隆项目 |
| 105 | + |
| 106 | +```bash |
| 107 | +git clone https://github.com/soybeanjs/soybean-admin-rust.git |
| 108 | +cd soybean-admin-rust |
| 109 | +``` |
| 110 | + |
| 111 | +2. 配置数据库 |
| 112 | + |
| 113 | +```bash |
| 114 | +# 编辑配置 本地开发环境 |
| 115 | +vim server/resources/application-test.yaml |
| 116 | +``` |
| 117 | + |
| 118 | +3. 运行迁移 |
| 119 | + |
| 120 | +```bash |
| 121 | +# copy .env.example 为 .env |
| 122 | +cp .env.example .env |
| 123 | +# 修改.env文件 |
| 124 | +vim .env |
| 125 | +# 运行迁移 |
| 126 | +make run-migration |
| 127 | +# 或 |
| 128 | +cargo run --bin migration |
| 129 | +``` |
| 130 | + |
| 131 | +4. 启动服务 |
| 132 | + |
| 133 | +```bash |
| 134 | +make run-server |
| 135 | +# 或 |
| 136 | +cargo run --bin server |
| 137 | +``` |
| 138 | + |
| 139 | +服务将在 `http://localhost:9528` 启动 |
| 140 | + |
| 141 | +## 技术栈 |
| 142 | + |
| 143 | +- **Web 框架**: Axum |
| 144 | +- **ORM**: SeaORM |
| 145 | +- **数据库**: PostgreSQL |
| 146 | +- **认证**: JWT |
| 147 | +- **权限**: Casbin |
| 148 | +- **日志**: tracing |
| 149 | +- **配置**: YAML |
| 150 | + |
| 151 | +## 贡献指南 |
| 152 | + |
| 153 | +1. Fork 本仓库 |
| 154 | +2. 创建您的特性分支 (`git checkout -b feature/AmazingFeature`) |
| 155 | +3. 提交您的改动 (`git commit -m 'feat: add some feature'`) |
| 156 | +4. 推送到分支 (`git push origin feature/AmazingFeature`) |
| 157 | +5. 开启一个 Pull Request |
| 158 | + |
| 159 | +## 许可证 |
| 160 | + |
| 161 | +本项目采用 Apache License 2.0 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情 |
| 162 | + |
| 163 | +如果您觉得这个项目对您有帮助,请给我们一个 ⭐️,这将鼓励我们持续改进! |
0 commit comments