# XiHan.BasicApp **Repository Path**: XiHanFun/XiHan.BasicApp ## Basic Information - **Project Name**: XiHan.BasicApp - **Description**: 基于 XiHan.Framework 和 XiHan.UI 的超高颜值通用中后台内核。曦寒懿(XiHanFun)开源生态的基础应用,拥有底座、组件、应用的完整生态。 - **Primary Language**: C# - **License**: MIT - **Default Branch**: main - **Homepage**: https://basicapp.docs.xihanfun.com - **GVP Project**: No ## Statistics - **Stars**: 161 - **Forks**: 85 - **Created**: 2024-08-14 - **Last Updated**: 2026-09-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: xihan, Vue, 中后台, saas, Csharp ## README
A beautifully crafted general-purpose admin kernel built on .NET and Vue
A .NET 10 backend on XiHan.Framework, a Vue 3 frontend on XiHan.UI
Multi-tenancy · RBAC with data scopes and field masking · Code generation · Realtime
English | 简体中文
![]() Tenant selection |
![]() User management |
![]() User management (dark) |
![]() Server monitoring |
![]() Preferences |
![]() Operation log |
![]() Log traceability |
![]() About |
## Features
**Identity and authentication**
- User, role, department and menu management
- JWT with two tokens (access 120 minutes + refresh 7 days), multi-device sign-in and session management
- Multiple sign-in methods: password, email / SMS code, 2FA (TOTP / email / SMS, combinable as flags)
- Eight first-party OAuth providers built in — GitHub, Gitee, Google, QQ, WeChat, WeCom, DingTalk, Lark — enabled by configuration
- Sign-in protection: first-party SVG captcha (single-use, can be turned off), throttling on both account+IP and IP alone, failure lockout, forced password change after signing in with the default password
- PBKDF2 password hashing (OWASP-recommended iterations); one-time codes are destroyed on consumption and compared in constant time
**Permissions**
- Three-segment permission codes `module:resource:action`; the super administrator wildcard is `*`
- Role hierarchy through a closure table, five data scopes (self / own department / department and children / all / custom), six field-masking strategies
- Static separation of duties: mutually exclusive roles and cardinality constraints, evaluated per constraint group
- Permission requests with approval, revocable temporary delegation, and a change audit trail
**Multi-tenancy**
- Column-level isolation by default with `TenantId=0` reserved for global data; per-tenant databases are also supported
- Globally unique email sign-in that routes the user by membership (console / workbench / tenant picker), with tenant switching at any time
- Platform-mode operations for super administrators, who can step into any tenant
- Runtime gating by tenant edition allowlist; onboarding creates the administrator, roles and grants in one go; downgrading reclaims grants that fall outside the allowlist
**Audit logging**
- Six independent log streams: access, API, operation, exception, sign-in and entity change
- Automatic masking before persistence (passwords, tokens, secrets, ID numbers and more, with a counter-example allowlist to avoid over-masking); entity changes distinguish create / update / delete / restore
- Traceability timeline: aggregate across log types by trace ID, username, session, IP or user ID
**Code generation**
- Single-table, tree and master-detail modes: entities, DTOs, APIs and frontend pages in one shot
- Native Scriban templates embedded into the assembly, each with a manual variant; menu permissions, permission seeds, page descriptors and seeders are generated alongside
- Download as a zip or write to disk; writing to disk is off by default and requires an explicit absolute-path allowlist root, with fail-closed path traversal checks
**AI**
- Provider onboarding and API-key custody (encrypted at rest with DataProtection; chat and embedding models are configurable)
- Prompt library stored in the database, able to override the framework defaults
- Knowledge-base RAG: document ingestion and vector search (Qdrant), isolated per tenant, keeping the raw content so indexes can be rebuilt
- Registered skills automatically become chat tools and MCP tools; knowledge retrieval ships built in, and business skills join by implementing `IAiSkill`
- Configurable assistants, bridged into the chat page
**Platform**
- Dynamic APIs: application services are exposed through `[DynamicApi]` with no controller boilerplate, and Scalar documentation is generated automatically
- One source of truth for menus: the backend `PageRegistry` registers menu, route, component path, permission code and i18n key together
- Distributed caching end to end (authorization snapshots, edition gating, menus, settings, dictionaries) with precise invalidation on write paths
- Request tracing; two SignalR hubs (notifications and chat)
- Message center: email / SMS / in-app notification templates, overridable per tenant
- Open platform: a built-in OAuth2 / OIDC provider (third-party app registration, user consent) and per-user OpenAPI credentials with signed calls
- Server monitoring (motherboard / CPU / memory / disk / GPU / network / runtime), cache key lookup and pattern-based clearing
- Multi-backend file storage (local / Aliyun OSS / Tencent COS / MinIO), database-backed scheduled jobs, review workflow, i18n (Chinese / English)
- Export center: async tasks with CSV and XLSX writers on a delayed queue
**Frontend experience**
- Schema-driven list pages: search, table and export generated from configuration, with column settings, density switching, advanced search, saved personal views, row hover previews, tree mode and column resizing
- Permission-, tenant- and preference-aware: pages, fields and actions filtered by permission code with field masking; column and search preferences sync to the backend and stay consistent across devices
- Dynamic-island feedback, tabbed pages, favorites, command-palette global search
- Message center: top banner, sign-in dialog, notification center, with forced reading and role/department targeting
- Preference center: light/dark theme, brand color, layout style and density, synced to the cloud
- Rich text (Tiptap) and markdown editors, visual cron builder, JSON editor/viewer, code editor
- Lock screen, watermark, time zone switching, export center
## Tech Stack
Backend: .NET 10 with XiHan.Framework 4.0.0 (SqlSugar, Redis, SignalR, Serilog and Scalar all arrive through the framework). Frontend: Vue 3 + TypeScript + Vite 8 + XiHan.UI + Pinia + Tailwind CSS 4.
Item-by-item lists live in the [backend](./backend/README.md#dependency-footprint) and [frontend](./frontend/README.md#stack) engineering notes.
## Architecture
The system splits into a framework layer, a module layer and the host application; each module follows DDD layering internally (domain / application / infrastructure).
```text
┌─────────────────────────────────────────────────────────────┐
│ XiHan.BasicApp.WebHost │
│ (startup host, module composition) │
├──────────┬──────────┬──────────┬──────────┬─────────────────┤
│ CodeGen │ AI │ Workflow │ Printing │ Chat │
│(codegen) │ (AI/RAG) │(workflow)│(printing)│ (chat) │
├──────────┴──────────┴──────────┴──────────┴─────────────────┤
│ XiHan.BasicApp.Saas │
│ (RBAC / tenancy / org / approval / audit / messaging) │
├─────────────────────────────────────────────────────────────┤
│ XiHan.BasicApp.Web.Core │
│ (web base / dynamic API / docs / maintenance mode) │
├─────────────────────────────────────────────────────────────┤
│ XiHan.BasicApp.Core │
│ (application base / DDD / modularity) │
├─────────────────────────────────────────────────────────────┤
│ XiHan.Framework.* │
│ (auth / authorization / data / caching / events / tenancy) │
└─────────────────────────────────────────────────────────────┘
```
| Project | Description | Removable |
| --- | --- | --- |
| `XiHan.BasicApp.Core` | Application base composing the non-web framework modules and shared conventions | No |
| `XiHan.BasicApp.Web.Core` | Web base composing six framework web modules, provides the maintenance-mode middleware | No |
| `XiHan.BasicApp.Saas` | Platform governance: users / roles / permissions / menus / departments / tenants / settings / dictionaries / files / notifications / approvals / logs / jobs | No |
| `XiHan.BasicApp.CodeGeneration` | Code generation: data sources / schema import / template configuration / full-stack output | Yes |
| `XiHan.BasicApp.AI` | AI: providers and key custody / prompt library / knowledge-base RAG / skills as MCP tools / chat assistant | Yes (the assistant bridge depends on Chat) |
| `XiHan.BasicApp.Workflow` | Workflow: definitions / instances / todos — persistence and APIs over the framework engine | Yes |
| `XiHan.BasicApp.Printing` | Print templates: visual design / tenant and platform scopes / resolution by code | Yes |
| `XiHan.BasicApp.Chat` | Chat: direct / group / department / assistant conversations, realtime delivery, compliance auditing | Yes (also handle the AI assistant bridge) |
| `XiHan.BasicApp.WebHost` | Startup host composing every module | — |
```text
XiHan.BasicApp/
├── backend/ # backend (.NET 10)
│ ├── src/
│ │ ├── framework/ # Core / Web.Core base capabilities
│ │ ├── modules/ # Saas + five optional modules (CodeGen/AI/Workflow/Printing/Chat)
│ │ └── main/ # WebHost startup entry
│ ├── props/ # shared MSBuild properties
│ ├── scripts/ # version bump and cleanup scripts
│ └── test/ # test projects
├── frontend/ # frontend (Vue 3 + XiHan.UI)
│ ├── src/ # application sources (src/modules/ mirrors the optional backend modules)
│ └── packages/ # internal packages
└── assets/ # README assets
```
### Removing Optional Modules
An optional module is one backend project plus one `src/modules/