A full-stack admin panel built with a Rust backend and Vue 3 frontend. The backend provides a RESTful API powered by Axum and SeaORM with SQLite, while the frontend is a modern admin dashboard based on vue-pure-admin.
- Authentication: OAuth2 token-based auth with JWT, login/logout/refresh token support
- User Management: CRUD operations, pagination, password reset, enable/disable toggle, role assignment
- Role Management: CRUD operations, role-based access control, role-menu authorization
- Menu Management: Tree-structured menus, per-user menu permissions, parent-child hierarchy
- Organization Management: Tree-structured org units, batch delete, parent-child queries
- Dictionary Management: System dictionaries and dictionary items with type-based lookups
- System Log: Operation logging with pagination and sensitive data masking
- Request Logging Middleware: Automatic HTTP request tracking with response time measurement
rust-admin/
βββ backend/ # Rust REST API (Axum + SeaORM + SQLite)
β βββ src/
β β βββ api/ # HTTP layer (routes, middleware, app state)
β β βββ auth/ # Authentication (JWT + Redis token store)
β β βββ common/ # Shared utilities (error handling, pagination, traits)
β β βββ config/ # Application configuration
β β βββ migration/ # Database migrations
β β βββ system/ # Business modules (user, role, menu, org, dict, log, auth)
β βββ tests/ # Integration tests (organized by module)
β βββ config.toml # Server, Redis, and database configuration
βββ frontend/ # Vue 3 admin panel (vue-pure-admin)
βββ src/
β βββ api/ # API service functions
β βββ router/ # Vue Router configuration
β βββ store/ # Pinia state management
β βββ views/ # Page components
β βββ ... # Components, plugins, styles, utils
βββ vite.config.ts # Dev server with API proxy
The backend follows a layered architecture with trait-based dependency injection, inspired by Spring patterns:
| Layer | Responsibility | Example |
|---|---|---|
| Handlers | HTTP request/response | handlers.rs |
| Service | Business logic | service.rs |
| Repository | Data access (trait + impl) | repository.rs |
| Domain | Types, DTOs, entity aliases | domain.rs |
| Entity | SeaORM database models | entity.rs |
Each module under system/ follows this consistent structure, making it easy to add new business domains.
The frontend is based on the vue-pure-admin template with Element Plus UI and TailwindCSS:
- Vue 3 Composition API with
<script setup>syntax - Pinia for state management
- Element Plus component library
- TailwindCSS 4 utility-first styling
- Vue Router with lazy-loaded route modules
- Axios for HTTP requests with auto-refresh token support
- i18n multi-language support (en, zh-CN, zh-TW, ja, ko)
| Technology | Version | Purpose |
|---|---|---|
| Rust | Edition 2024 | Language |
| Axum | 0.8 | Web framework |
| SeaORM | 1.1 | ORM (SQLite) |
| Tokio | 1 | Async runtime |
| Redis | β | Token/session storage |
| SQLite | β | Primary database |
| JWT | β | Authentication tokens |
| Technology | Version | Purpose |
|---|---|---|
| Vue | 3.5+ | UI framework |
| TypeScript | 5.8+ | Type safety |
| Vite | 6 | Build tool |
| Element Plus | 2.9+ | UI component library |
| TailwindCSS | 4 | Utility CSS |
| Pinia | 3 | State management |
| Vue Router | 4 | Routing |
| VxeTable | 4.6 | Advanced table component |
| ECharts | 5 | Charts |
| Axios | 1.9 | HTTP client |
- Rust (latest stable, edition 2024 support)
- Node.js
^18.18.0 || ^20.9.0 || >=22.0.0 - pnpm
>=9 - Redis server running on
localhost:6379
git clone <your-repo-url>
cd rust-admincd backend
# Configure the database and Redis (edit config/config.toml if needed)
# The default config uses SQLite (auto-created) and localhost Redis
# Run database migrations and start the server
cargo runThe API server starts at http://127.0.0.1:3000.
cd frontend
# Install dependencies
pnpm install
# Start the dev server
pnpm devThe frontend dev server starts (port configured in .env), with /api requests proxied to http://127.0.0.1:3000.
Note: Run the backend and frontend in separate terminal sessions.
All API endpoints are prefixed with /api. Protected routes require a Bearer token in the Authorization header.
| Module | Endpoint Pattern | Description |
|---|---|---|
| Auth | POST /api/token |
Login |
| Auth | GET /api/token/logout |
Logout |
| Auth | GET /api/token/refresh/{refresh_token} |
Refresh token |
| Auth | GET /api/token/check_token |
Validate token |
| User | GET /api/sysUser/getPage |
Users (paginated) |
| User | POST/GET/PUT/DELETE /api/sysUser[/{id}] |
User CRUD |
| User | PUT /api/sysUser/resetPwd |
Reset password |
| User | PUT /api/sysUser/enable |
Toggle user enabled |
| Role | GET /api/sysRole/getPage |
Roles (paginated) |
| Role | POST/GET/PUT/DELETE /api/sysRole[/{id}] |
Role CRUD |
| Menu | GET /api/sysMenu/tree |
Menu tree |
| Menu | GET /api/sysMenu/user-menu |
Current user's menus |
| Menu | POST/GET/PUT/DELETE /api/sysMenu[/{id}] |
Menu CRUD |
| Org | GET /api/sysOrg/tree |
Organization tree |
| Org | POST/GET/PUT/DELETE /api/sysOrg[/{id}] |
Org CRUD |
| Dict | GET /api/sysDict/getPage |
Dictionaries (paginated) |
| Dict | POST/GET/PUT/DELETE /api/sysDict[/{id}] |
Dict CRUD |
| Dict Item | GET /api/sysDictItem/getByType |
Items by type |
| Dict Item | POST/GET/PUT/DELETE /api/sysDictItem[/{id}] |
Dict Item CRUD |
| Log | GET /api/sysLog/getPage |
Logs (paginated) |
| Log | POST/GET/PUT/DELETE /api/sysLog[/{id}] |
Log CRUD |
| Auth Config | GET /api/sysAuth/getMenuData/{role_code} |
Role menu data |
| Auth Config | POST /api/sysAuth/setMenuAuth |
Set menu permissions |
cd backend
# Run all tests
cargo test
# Run a specific test module
cargo test --test user_service_tests
cargo test --test role_api_tests
cargo test --test auth_service_tests
# Run a single test by name
cargo test -- <test_name>Tests use UUID-based temporary SQLite database files that are automatically created and cleaned up.
cd frontend
# Lint (required before commit)
pnpm lint
# Type checking
pnpm typecheckNote: No frontend test framework is currently configured.
jwt_secret = "your-secret-key"
database_url = "sqlite:data/users.db?mode=rwc" # Adjust path to your environment
[server]
host = "127.0.0.1"
port = 3000
[redis]
host = "localhost"
port = 6379
password = "123456"The dev server proxies /api β http://127.0.0.1:3000 for seamless backend integration.
cd backend
cargo fmt && cargo fmt -- --check # Format check
cargo clippy -- -D warnings # Lint (zero warnings)cd frontend
pnpm lint # Run all linters (ESLint + Prettier + Stylelint)
pnpm lint:eslint # Lint JS/TS/Vue only
pnpm lint:prettier # Format code
pnpm lint:stylelint # Lint CSS/SCSS
pnpm typecheck # TypeScript type checkingHusky + lint-staged automatically run linters on commit.
The frontend includes Docker support for containerized deployment:
cd frontend
# Build and run with Docker Compose
docker-compose up --buildSee frontend/Dockerfile and frontend/docker-compose.yml for configuration details.
cd backend
cargo build --release # Output β target/release/x-rustcd frontend
pnpm build # Output β dist/MIT