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
}
```
+19 -28
View File
@@ -71,34 +71,25 @@ totalDoc/
## نقشه ارتباط فایل‌ها
```
┌──────────────┐
O2: INDEX │ ← شما اینجا هستید
└──────┬───────┘
┌─────────────────┼──────────────────┐
│ │ │
┌────▼────┐ ┌────▼─────┐ ┌────▼─────┐
│Business │ │Technical │ │Overview │
│ (B1-B5) │ │ (T1-T5) │ │ (O1-O5) │
└────┬────┘ └────┬─────┘ └────┬─────┘
│ │ │
┌────┴────────────────┴──────────────────┴────┐
│ │
│ B1 ←→ B2 (مالی/باشگاه) │
│ B2 ←→ B3 (پرداخت/فروشگاه) │
│ B3 ←→ B4 (فروشگاه/کاربر) │
│ B4 ←→ B5 (کاربر/محتوا) │
│ B1 ←→ T1 (باشگاه/CMS) │
│ T1 ←→ T2 (CMS/UI) │
│ T1 ←→ T3 (CMS/Deploy) │
│ T3 ←→ T4 (Deploy/Migration) │
│ T1 ←→ T5 (CMS/API) │
│ O1: دیاگرام = بصری B1-B5 + T1-T5 │
│ O3: تاریخچه = changelog B1-B5 + T1-T5 │
│ O5: آینده = roadmap B1-B5 + T1-T5 │
│ │
└──────────────────────────────────────────────┘
```mermaid
graph TD
INDEX["📋 O2: INDEX\nشما اینجا هستید"]
INDEX --> BIZ["📁 Business\nB1-B5"]
INDEX --> TECH["📁 Technical\nT1-T5"]
INDEX --> OVR["📁 Overview\nO1-O5"]
BIZ --- B12["B1 ↔ B2\nمالی / باشگاه"]
BIZ --- B23["B2 ↔ B3\nپرداخت / فروشگاه"]
BIZ --- B34["B3 ↔ B4\nفروشگاه / کاربر"]
BIZ --- B45["B4 ↔ B5\nکاربر / محتوا"]
BIZ --- TECH
TECH --- T12["T1 ↔ T2 — CMS/UI"]
TECH --- T13["T1 ↔ T3 — CMS/Deploy"]
TECH --- T34["T3 ↔ T4 — Deploy/Migration"]
TECH --- T15["T1 ↔ T5 — CMS/API"]
OVR --- OX["O1: دیاگرام‌ها\nO3: تاریخچه\nO5: نقشه راه"]
```
---
+32 -30
View File
@@ -69,40 +69,42 @@ Documentation ████████████████████
### Q1 1404 (فروردین-خرداد)
```
Sprint 1 (فروردین):
├── H2: Mobile Responsive
├── H1: Product Bundle
└── M4: SEO Meta Tags
Sprint 2 (اردیبهشت):
├── M1: Manual Payment (if approved)
├── M2: SignalR Chatika
└── M6: Dashboard Charts
Sprint 3 (خرداد):
├── M3: Dark Mode
├── H3: Rate Limiting
└── L1: PWA
```mermaid
gantt
title Q1 1404 — فروردین تا خرداد
dateFormat YYYY-MM-DD
section Sprint 1 فروردین
H2 Mobile Responsive :a1, 2025-03-21, 5d
H1 Product Bundle :a2, after a1, 3d
M4 SEO Meta Tags :a3, after a2, 2d
section Sprint 2 اردیبهشت
M1 Manual Payment :b1, 2025-04-21, 3d
M2 SignalR Chatika :b2, after b1, 2d
M6 Dashboard Charts :b3, after b2, 3d
section Sprint 3 خرداد
M3 Dark Mode :c1, 2025-05-22, 2d
H3 Rate Limiting :c2, after c1, 2d
L1 PWA :c3, after c2, 3d
```
### Q2 1404 (تیر-شهریور)
```
Sprint 4 (تیر):
├── L3: Monitoring
├── L4: Log Aggregation
└── L2: API Versioning
Sprint 5 (مرداد):
├── L5: Product Compare
├── L6: Wishlist
└── L7: Email Templates
Sprint 6 (شهریور):
├── L8: Refund System
├── Performance Optimization
└── Security Audit
```mermaid
gantt
title Q2 1404 — تیر تا شهریور
dateFormat YYYY-MM-DD
section Sprint 4 تیر
L3 Monitoring :d1, 2025-06-22, 3d
L4 Log Aggregation :d2, after d1, 3d
L2 API Versioning :d3, after d2, 2d
section Sprint 5 مرداد
L5 Product Compare :e1, 2025-07-23, 2d
L6 Wishlist :e2, after e1, 2d
L7 Email Templates :e3, after e2, 2d
section Sprint 6 شهریور
L8 Refund System :f1, 2025-08-23, 5d
Performance Optimization :f2, after f1, 3d
Security Audit :f3, after f2, 3d
```
---