How lyqgit/salvo-admin works
Project Type and Purpose
• This is a full-stack "admin" dashboard framework that combines:
• A Rust-based back end using the Salvo web framework (controllers, services, mappers, entities)
• A Vue 3 + Element Plus + Vite front end (based on Ruoyi-Vue3)
• Provides CRUD management of users, roles, departments, menus, dictionaries, notices, posts, plus a collaborative Excel editor (e-sheet via WebSocket).
High-Level Architecture
[Browser/Client]
↕ HTTP(S) & WebSocket
[Vue 3 + Element Plus SPA]
• Views & Components
• API layer (login, system, monitor, tool, etc.)
• WebSocket client for excel collaboration
• Vite dev server or static host
→
[Salvo Web Server (Rust)]
• Router layer (defines HTTP routes)
• Controller layer (chat, user, dept, dict, excel, monitor, swagger, etc.)
• Service layer (business logic)
• Mapper/DAO layer (MySQL queries via xml or code)
• Entity definitions (Rust structs for each table)
• Utils (JWT auth, Redis cache, MySQL pool, MD5, system config, response formatting)
• WebSocket handler for real-time Excel
• Swagger UI endpoint for docs
↕
[Storage & Cache]
• MySQL (persistent storage for all system data)
• Redis (caching, session management, pub/sub for WebSocket)
Component Relationships and Data Flow
a) User opens the Vue SPA → loads static assets (HTML/CSS/JS) via Vite or static server
b) SPA calls Salvo back end over REST:
• Authentication (login → JWT token or session cookie)
• CRUD operations → Controllers → Services → Mappers → MySQL
• Cache lookups/invalidations via Redis in Services or Utils
c) SPA opens a WebSocket connection to Salvo for collaborative Excel editing
• Messages routed to excel_websocket.rs → broadcast via Redis pub/sub if needed
d) API docs served at /swagger-ui, secured by basic auth
Architectural Patterns & Principles
• Layered/MVC-style: Router → Controller → Service → DAO (Mapper) → Database
• Separation of concerns:
• Controllers only handle HTTP concerns & request validation
• Services encapsulate business logic & coordinate transactions
• Mappers/DAOs handle raw SQL & mapping to Rust entities
• Utilities decouple cross-cutting concerns (auth, caching, hashing, response formatting)
• Real-time collaboration via WebSocket with Redis backing