一键导入
backend-rust
Rust gRPC backend patterns, folder structure, module anatomy, and infrastructure wiring for the Anachak multi-tenant SaaS platform.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Rust gRPC backend patterns, folder structure, module anatomy, and infrastructure wiring for the Anachak multi-tenant SaaS platform.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
CI/CD pipeline, Docker multi-stage build, GitHub Actions, and Cloud Run deployment for the Anachak platform.
TanStack Router + React frontend patterns, ConnectRPC gRPC-Web client, Zustand stores, Tailwind v4, i18n, and AppearancePanel theming for the Anachak platform.
Fish shell configuration, aliases, gRPC debugging, PostgreSQL CLI helpers, and dev workflow shortcuts for the Anachak platform.
基于 SOC 职业分类
| name | backend-rust |
| description | Rust gRPC backend patterns, folder structure, module anatomy, and infrastructure wiring for the Anachak multi-tenant SaaS platform. |
Comprehensive guide for working with the Anachak Rust gRPC backend — a multi-tenant SaaS platform with 11 modules, 32 utility packages, and 90+ RPCs.
| Layer | Technology | Version |
|---|---|---|
| Language | Rust | 2021 edition |
| Transport | gRPC (Tonic) + gRPC-Web | tonic 0.12 |
| Database | PostgreSQL (SQLx) | sqlx 0.8 |
| Proto | Protocol Buffers v3 | Buf CLI v2 |
| Auth | JWT (jsonwebtoken 9) | Access + Refresh |
| Password | Argon2 (argon2 0.5) | PHC-format |
| Payments | Bakong/KHQR (EMV-compliant) | reqwest 0.12 |
| Metrics | Prometheus | prometheus 0.13 |
| WebSocket | tokio-tungstenite 0.24 | Notification broadcast |
| OTP | TOTP (totp-rs 5) | Google Authenticator |
| SMS | Plasgate | Cambodia gateway |
| Resend | HTTP API | |
| IDs | ULID (ulid 1) | Sortable, unique |
| Cache | In-memory / Redis (optional) | Feature-gated |
| Observability | tracing + optional OpenTelemetry | Feature-gated otel |
| Hot Reload | cargo watch | cw alias |
| Topic | File |
|---|---|
| Folder structure | folder-structure.md |
| Module anatomy | module-anatomy.md |
| Infrastructure utils | infrastructure.md |
| Interceptor/layer chain | interceptors.md |
| Database patterns | database-patterns.md |
| Error handling | error-handling.md |
| Adding a new module | new-module-checklist.md |
| Proto & Buf | proto-and-buf.md |
| Module | Files | Key Responsibility |
|---|---|---|
| auth | 4 (auth.rs, auth_repo.rs, auth_service.rs, mod.rs) | User accounts, JWT, 2FA, OAuth, sessions, audit |
| company | 4 | Multi-tenant company/branch/member management |
| businesstype | 4 | Industry presets (28 types), pricing tiers |
| billing | 4 | KHQR payments, Bakong polling, streaming |
| coupon | 4 | Coupon creation, validation, redemption tracking |
| role | 4 | RBAC role/permission management |
| subscription | 4 | Plan lifecycle, branch-scoped subscriptions |
| notification | 4 | In-app notification delivery |
| currency | 4 | Multi-currency exchange rates |
| activity | 4 | Audit activity logging |
| admin | 4 | Cross-cutting admin operations |
| File | Purpose |
|---|---|
main.rs | Calls internal::startup::run() |
internal/startup/mod.rs | Server bootstrap — env, DB, utils, gRPC server, HTTP, cron, shutdown |
internal/startup/proto.rs | Proto module re-exports & file descriptor set |
internal/startup/events.rs | Event handler registration |
internal/startup/cron_jobs.rs | Cron job scheduling |
internal/startup/http_server.rs | Side-channel HTTP (metrics + WebSocket) |
build.rs | tonic-build proto compilation |
| Port | Protocol | Purpose |
|---|---|---|
50050 | gRPC | Native gRPC + gRPC-Web |
9090 | HTTP | Prometheus metrics |
9091 | WebSocket | Real-time notification broadcast |
<module>.rs (types) → <module>_repo.rs (data) → <module>_service.rs (business logic + gRPC)Arc<T> and passed explicitlyAuthInterceptor validates JWT + blacklist, injects user context into metadataShutdownCoordinator manages ordered teardown of 5 components.sql files in migrations/EventBus for decoupled reactions to domain eventsAppError enum → auto-converts to gRPC Status with x-error-code metadata