docs: convert all ASCII charts to Mermaid diagrams

Converted 40+ ASCII art diagrams across 12 files to Mermaid:
- flowchart TD/LR for process flows and architecture
- erDiagram for entity relationships
- graph TD for tree structures (binary tree, categories)
- gantt for roadmap sprints

Files: BUSINESS-01 to 05, TECH-01/03/04/05, OVERVIEW-01/02/05
Directory tree structures kept as plain code blocks (Mermaid N/A)
This commit is contained in:
masoodafar-web
2026-02-18 23:36:39 +03:30
parent aef6861e21
commit 1b04ba5326
12 changed files with 544 additions and 739 deletions
+170 -241
View File
@@ -7,283 +7,212 @@
## ۱. فلوی کلان کاربر (User Journey)
```
┌─────────────────────────────────────────────────────────────────────────┐
│ FourSat — User Journey │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ [ورود به سایت] │
│ │ │
│ ▼ │
│ ◆ آیا ثبت‌نام کرده؟ ◆──── خیر ───→ [Landing Page] │
│ │ │ │
│ بله [ثبت‌نام] │
│ │ موبایل + OTP │
│ ▼ │ │
│ [Login + JWT] ▼ │
│ │ [پروفایل] │
│ ▼ │ │
│ ◆ عضو باشگاه؟ ◆ ▼ │
│ │ │ ┌───────────────┐ │
│ بله خیر │ Regular Store │ │
│ │ │ │ خرید عادی │ │
│ │ └──────────────→│ IPG پرداخت │ │
│ │ └───────────────┘ │
│ ▼ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Club Member Dashboard │ │
│ ├──────────┬──────────┬──────────┬─────────────┤ │
│ │ فروشگاه │ درخت شبکه │ کمیسیون │ Chatika AI │ │
│ │ تخفیفی │ باینری │ هفتگی │ │ │
│ │ (per-product) │ │ │ │ │
│ └──────────┴──────────┴──────────┴─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
```mermaid
flowchart TD
A["🌐 ورود به سایت"] --> B{"آیا ثبت‌نام کرده؟"}
B -->|خیر| C["Landing Page"]
C --> D["ثبت‌نام\nموبایل + OTP"]
D --> E["پروفایل"]
E --> F
B -->|بله| G["Login + JWT"]
G --> H{"عضو باشگاه؟"}
H -->|خیر| F["🛒 Regular Store\nخرید عادی — IPG پرداخت"]
H -->|بله| I["🏆 Club Member Dashboard"]
I --> J["فروشگاه تخفیفی\nper-product MaxDiscount%"]
I --> K["درخت شبکه\nباینری"]
I --> L["کمیسیون\nهفتگی"]
I --> M["Chatika AI"]
```
---
## ۲. فلوی مالی (Financial Flow)
```
┌─────────────────────────────────────────────────────────────────────────┐
│ FourSat — Financial Flow │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ═══════════════════ ورودی پول ═══════════════════ │
│ │
│ [ZarinPal IPG] ──→ ┐ │
│ [Daya Loan] ──→ ├──→ [PYMS Service] ──→ [DB Transaction] │
│ [Manual Pay] ──→ ┘ │ │
│ ▼ │
│ ═══════════ توزیع به کیف‌پول‌ها ═══════════ │
│ │
│ ┌────────────────┐ ┌─────────────────┐ ┌──────────────────┐ │
│ │ 💰 Balance │ │ 🌟 NetworkBal │ │ 🏷️ DiscountBal │ │
│ │ (نقدی) │ │ (طلایی/کمیسیون)│ │ (تخفیفی) │ │
│ │ │ │ │ │ │ │
│ │ • IPG: +56M │ │ • شارژ نمی‌شود │ │ • IPG: +112M │ │
│ │ • Daya: +56M │ │ • فقط برای │ │ • Daya: +112M │ │
│ │ • فعالسازی │ │ محاسبه │ │ (دو برابر) │ │
│ │ -25.2M │ │ کمیسیون │ │ • per-product │ │
│ │ • خرید فروشگاه │ │ • سقف 300/هفته │ │ MaxDiscount% │ │
│ └───────┬────────┘ └────────┬────────┘ └────────┬─────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ═══════════════════ خروجی پول ═══════════════════ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Weekly Commission Pool │ │
│ │ │ │
│ │ Source: هر فعالسازی → 25.2M واریز │ │
│ │ Calculate: sp_CalculateWeeklyBalances │ │
│ │ Distribute: sp_CalculateWeeklyCommissionPool │ │
│ │ Formula: UserShare = UserBalance / TotalBalance │ │
│ │ Cap: MAX 300 per leg per week │ │
│ │ Carryover: به هفته بعد (max 300, else flush) │ │
│ │ │ │
│ │ ┌─ Member A: Balance=150 → Share=150/600 → 25% ─┐ │ │
│ │ │ Member B: Balance=200 → Share=200/600 → 33% │ │ │
│ │ │ Member C: Balance=250 → Share=250/600 → 42% │ │ │
│ │ └─ Total: 600 ─┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
```mermaid
flowchart TD
subgraph INPUT["═══ ورودی پول ═══"]
Z1["ZarinPal IPG"]
Z2["Daya Loan"]
Z3["Manual Pay"]
end
Z1 --> PYMS["PYMS Service"]
Z2 --> PYMS
Z3 --> PYMS
PYMS --> TX[("DB Transaction")]
TX --> W1 & W2 & W3
subgraph WALLETS["═══ توزیع به کیف‌پول‌ها ═══"]
W1["💰 Balance — نقدی\n• IPG: +56M\n• Daya: +56M\n• فعالسازی: −25.2M\n• خرید فروشگاه"]
W2["🌟 NetworkBalance — طلایی\n• شارژ نمی‌شود\n• فقط محاسبه کمیسیون\n• سقف 300/هفته"]
W3["🏷️ DiscountBalance — تخفیفی\n• IPG: +112M\n• Daya: +112M\n• per-product MaxDiscount%"]
end
W1 & W2 --> POOL
subgraph POOL["═══ Weekly Commission Pool ═══"]
P1["هر فعالسازی → 25.2M واریز به Pool"]
P2["sp_CalculateWeeklyBalances"]
P3["sp_CalculateWeeklyCommissionPool"]
P4["UserShare = UserBalance / TotalBalance"]
P5["Cap: MAX 300 per leg per week"]
P1 --> P2 --> P3 --> P4 --> P5
end
```
---
## ۳. فلوی داده (Data Flow)
```
┌─────────────────────────────────────────────────────────────────────────┐
│ FourSat — Data Flow │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ [Browser/Client] │
│ │ │
│ │ HTTPS │
│ ▼ │
│ [nginx / K8s Ingress] │
│ │ │
│ ├──→ / ──────────→ [FrontOffice :5003] (Blazor Server) │
│ │ │ │
│ ├──→ /admin ─────→ [BackOffice :5002] (Blazor WASM) │
│ │ │ │
│ └──→ /hangfire ──→ [CMS :5001] (Dashboard) │
│ │ │
│ ┌─────────────────────────────┘ │
│ │ gRPC (Protobuf v3, HTTP/2) │
│ ▼ │
│ [CMS Microservice :5001] │
│ │ │
│ ├──→ [MediatR] ──→ Commands/Queries ──→ Handlers │
│ │ │ │
│ ├──→ [Hangfire] ──→ Background Jobs │ │
│ │ • DayaLoan (15min) │ │
│ │ • Commission (weekly) │ │
│ │ • Chatika (5min) │ │
│ │ • InventorySync (hourly) │ │
│ │ │ │
│ └──→ [External Services] │ │
│ • ZarinPal API │ │
│ • Kavenegar API ▼ │
│ • DayaLoan API [EF Core 9] │
│ • Chatika API │ │
│ ▼ │
│ [SQL Server 2022] │
│ Schema: [CMS] │
│ ~15 main tables │
│ + 3 Stored Procs │
│ │
└─────────────────────────────────────────────────────────────────────────┘
```mermaid
flowchart TD
CLIENT["🌐 Browser / Client"] -->|HTTPS| NGINX["nginx / K8s Ingress"]
NGINX -->|"/"| FO["FrontOffice :5003\nBlazor Server"]
NGINX -->|"/admin"| BO["BackOffice :5002\nBlazor WASM"]
NGINX -->|"/hangfire"| CMS
FO -->|gRPC| CMS["CMS Microservice :5001"]
BO -->|gRPC| CMS
CMS --> MEDIATR["MediatR\nCommands / Queries → Handlers"]
CMS --> HF["Hangfire\n• DayaLoan — */20 min\n• Commission — Sunday 00:05\n• Chatika — */5 min"]
CMS --> EXT["External Services\n• ZarinPal API\n• Kavenegar API\n• DayaLoan API\n• Chatika API"]
MEDIATR --> EF["EF Core 9"]
HF --> EF
EF --> DB[("SQL Server 2022\nSchema: CMS\n~15 tables + 3 SPs")]
```
---
## ۴. درخت باینری شبکه (Network Tree)
```
┌─────────┐
│ Root │
│ (Admin) │
└────┬────┘
┌─────────┴─────────┐
┌────▼────┐ ┌────▼────┐
│ User A │ │ User B │
│ L=120 │ │ L=0 │
│ R=80 │ │ R=150 │
└────┬────┘ └────┬────┘
┌───────┴───────┐ ┌──────┴──────┐
┌────▼──┐ ┌────▼──┐ ┌──▼───┐ ┌───▼──┐
│User C │ │User D │ │User E│ │User F│
│Active │ │Active │ │Pend. │ │Active│
└───────┘ └───────┘ └──────┘ └──────┘
```mermaid
graph TD
ROOT["🔵 Root — Admin"]
ROOT --- A["👤 User A\nL=120 | R=80"]
ROOT --- B["👤 User B\nL=0 | R=150"]
Legend:
L = Left leg sales this week
R = Right leg sales this week
Active = فعال (contract signed)
Pend. = در انتظار فعالسازی
شبکه روی entity User مدل شده (NetworkParentId, LegPosition)
محاسبه کمیسیون تا عمق 15 سطح — درخت بدون محدودیت عمق
A --- C["✅ User C\nActive"]
A --- D["✅ User D\nActive"]
B --- E["⏳ User E\nPending"]
B --- F["✅ User F\nActive"]
style ROOT fill:#1976D2,color:#fff
style C fill:#4CAF50,color:#fff
style D fill:#4CAF50,color:#fff
style E fill:#FF9800,color:#fff
style F fill:#4CAF50,color:#fff
```
> **راهنما:**
> - `L` / `R` = فروش پای چپ / راست این هفته
> - **Active** = فعال (قرارداد امضا شده) — **Pending** = در انتظار فعالسازی
> - شبکه روی entity `User` مدل شده (`NetworkParentId`, `LegPosition`)
> - محاسبه کمیسیون تا عمق ۱۵ سطح — درخت بدون محدودیت عمق
---
## ۵. فلوی خرید — Regular vs Discount Store
### ۵.۱ Regular Store
```mermaid
flowchart TD
A1["مشاهده محصولات"] --> B1["Lazy Load — 12 per page"]
B1 --> C1["افزودن به سبد"]
C1 --> D1["بررسی موجودی"]
D1 --> E1["Checkout"]
E1 --> F1["ZarinPal IPG\n100% نقدی"]
F1 --> G1["ثبت سفارش"]
G1 --> H1["کسر موجودی"]
H1 --> I1["SMS تأیید"]
```
┌────────────────────────────────┬──────────────────────────────────┐
│ Regular Store │ Discount Store │
├────────────────────────────────┼──────────────────────────────────┤
│ │ │
│ [مشاهده محصولات] │ [مشاهده محصولات] ← فقط باشگاه │
│ │ │ │ │
│ ▼ │ ▼ │
│ [Lazy Load — 12 per page] │ [Lazy Load — 12 per page] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [افزودن به سبد] │ [افزودن به سبد] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [بررسی موجودی] │ [بررسی موجودی] │
│ │ │ [بررسی DiscountBalance] │
│ ▼ │ │ │
│ [Checkout] │ ▼ │
│ │ │ [محاسبه سهم تخفیف (MaxDiscount%)]│
│ ▼ │ [محاسبه سهم نقدی (باقیمانده)] │
│ [ZarinPal IPG] │ │ │
│ [100% نقدی] │ ▼ │
│ │ │ [کسر از DiscountBalance] │
│ ▼ │ [ZarinPal IPG برای باقیمانده] │
│ [ثبت سفارش] │ │ │
│ │ │ ▼ │
│ ▼ │ [ثبت سفارش ترکیبی] │
│ [کسر موجودی] │ [کسر موجودی] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [SMS تأیید] │ [SMS تأیید] │
│ │ │
└────────────────────────────────┴──────────────────────────────────┘
### ۵.۲ Discount Store
```mermaid
flowchart TD
A2["مشاهده محصولات\nفقط اعضای باشگاه"] --> B2["Lazy Load — 12 per page"]
B2 --> C2["افزودن به سبد"]
C2 --> D2["بررسی موجودی + DiscountBalance"]
D2 --> E2["محاسبه سهم تخفیف\nMaxDiscount% هر محصول"]
E2 --> F2["محاسبه سهم نقدی\nباقیمانده"]
F2 --> G2["کسر از DiscountBalance"]
G2 --> H2["ZarinPal IPG\nبرای باقیمانده نقدی"]
H2 --> I2["ثبت سفارش ترکیبی"]
I2 --> J2["کسر موجودی"]
J2 --> K2["SMS تأیید"]
```
---
## ۶. معماری Deployment
```
┌──────────────────────────────────────────────────────────────┐
│ Production Server │
│ 45.149.79.127 │
├──────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌────────────────────────────────────┐ │
│ │ nginx │────→│ Kubernetes Cluster │ │
│ │ :80/:443│ │ │ │
│ └─────────┘ │ ┌───────────┐ ┌───────────────┐ │ │
│ │ │CMS ×2 │ │FrontOffice ×2 │ │ │
│ │ │:5001 gRPC │ │:5003 Blazor │ │ │
│ │ └─────┬─────┘ └───────────────┘ │ │
│ │ │ │ │
│ │ ┌─────▼─────┐ ┌───────────────┐ │ │
│ │ │SQL Server │ │BackOffice ×1 │ │ │
│ │ │:1433 │ │:5002 Static │ │ │
│ │ └───────────┘ └───────────────┘ │ │
│ │ │ │
│ │ ┌───────────┐ ┌───────────────┐ │ │
│ │ │Nexus │ │Hangfire │ │ │
│ │ │:8081 │ │(inside CMS) │ │ │
│ │ └───────────┘ └───────────────┘ │ │
│ └────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────┘
```mermaid
flowchart TD
subgraph SERVER["🖥️ Production Server — 45.149.79.127"]
NGINX["nginx\n:80 / :443"]
subgraph K8S["☸ Kubernetes Cluster"]
CMS["CMS ×2\n:5001 gRPC"]
FO["FrontOffice ×2\n:5003 Blazor Server"]
BO["BackOffice ×1\n:5002 Static"]
DB[("SQL Server\n:1433")]
NEXUS["Nexus\n:8081"]
HF["Hangfire\ninside CMS"]
end
end
NGINX --> CMS
NGINX --> FO
NGINX --> BO
CMS --> DB
CMS --> HF
style SERVER fill:#f5f5f5,stroke:#333
style K8S fill:#e3f2fd,stroke:#1976D2
```
---
## ۷. Entity Relationship (ساده‌شده)
```
┌──────────┐ ┌──────────────┐
User │────→│ ClubMembership
│ +Network │ │ │
│ ParentId│ └──────────────┘
│ +LegPos │
└────┬─────┘
├────→ ┌──────────┐ ┌──────────┐
│ │ Order │────→│ OrderItem│────→ [Product]
│ └──────────┘ └──────────┘
├────→ ┌──────────────┐
│ │ Transaction │
│ └──────────────┘
├────→ ┌──────────────┐
│ │ UserWallet │────→ Balance + NetworkBalance + DiscountBalance
│ └──────────────┘
├────→ ┌──────────────┐
│ │ UserContract
│ └──────────────┘
└────→ ┌──────────────┐
│ ChatMessage │
└──────────────┘
┌──────────┐ ┌───────────┐
│ Product │────→│ Inventory │
│ │────→│ Category │
│ │────→│ Images │
└──────────┘
┌──────────┐ ┌──────────────────────┐
│ SitePage │ │ SystemConfiguration │
│ (typed) │ │ (key-value) │
└──────────┘ └──────────────────────┘
┌──────────┐
│ BlogPost │────→ [Tags, Category, Author]
└──────────┘
```mermaid
erDiagram
User ||--o{ ClubMembership : has
User ||--o| UserWallet : has
User ||--o{ UserContract : signs
User ||--o{ UserOrder : places
User ||--o{ ChatMessage : sends
User }o--o| User : "NetworkParentId"
UserOrder ||--|{ OrderItem : contains
OrderItem }o--|| Product : references
UserOrder ||--o{ Transaction : has
Product ||--o| Inventory : has
Product }o--|| Category : belongs_to
Product ||--o{ ProductImage : has
UserWallet ||--o{ UserWalletChangeLog : logs
BlogPost }o--|| Category : belongs_to
UserWallet {
long Balance
long NetworkBalance
long DiscountBalance
}
User {
Guid NetworkParentId
int LegPosition
}
UserContract {
Guid SignGuid
string SignedPdfFile
}
```