Files
docs/overview/OVERVIEW-01-FLOWCHARTS.md
T
masoodafar-web efff5e9cd5 docs: consolidate 53 files into 15 structured files in 3 folders
- business/ (5): club-commission, payment, ecommerce, membership, content
- technical/ (5): cms-arch, ui, deployment, migration, api
- overview/ (5): flowcharts, index, changelog, glossary, roadmap
- Removed all old folders: backoffice, cms, deployment, docs, frontoffice, migration, ui-modernization, business (old)
- Updated internal links with relative folder paths
2026-02-18 22:29:37 +03:30

281 lines
22 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 📊 فلوچارت‌ها و دیاگرام‌های کلان
> **دید بالا (Big Picture): فلوی کاربر، مالی و داده**
> **آخرین بروزرسانی:** اسفند ۱۴۰۴
---
## ۱. فلوی کلان کاربر (User Journey)
```
┌─────────────────────────────────────────────────────────────────────────┐
│ FourSat — User Journey │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ [ورود به سایت] │
│ │ │
│ ▼ │
│ ◆ آیا ثبت‌نام کرده؟ ◆──── خیر ───→ [Landing Page] │
│ │ │ │
│ بله [ثبت‌نام] │
│ │ موبایل + OTP │
│ ▼ │ │
│ [Login + JWT] ▼ │
│ │ [پروفایل] │
│ ▼ │ │
│ ◆ عضو باشگاه؟ ◆ ▼ │
│ │ │ ┌───────────────┐ │
│ بله خیر │ Regular Store │ │
│ │ │ │ خرید عادی │ │
│ │ └──────────────→│ IPG پرداخت │ │
│ │ └───────────────┘ │
│ ▼ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Club Member Dashboard │ │
│ ├──────────┬──────────┬──────────┬─────────────┤ │
│ │ فروشگاه │ درخت شبکه │ کمیسیون │ Chatika AI │ │
│ │ تخفیفی │ باینری │ هفتگی │ │ │
│ │ (30%↓) │ │ │ │ │
│ └──────────┴──────────┴──────────┴─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
```
---
## ۲. فلوی مالی (Financial Flow)
```
┌─────────────────────────────────────────────────────────────────────────┐
│ FourSat — Financial Flow │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ═══════════════════ ورودی پول ═══════════════════ │
│ │
│ [ZarinPal IPG] ──→ ┐ │
│ [Daya Loan] ──→ ├──→ [PYMS Service] ──→ [DB Transaction] │
│ [Manual Pay] ──→ ┘ │ │
│ ▼ │
│ ═══════════ توزیع به ۳ کیف‌پول ═══════════ │
│ │
│ ┌────────────────┐ ┌─────────────────┐ ┌──────────────────┐ │
│ │ 💰 Balance │ │ 🌐 NetworkBal │ │ 🏷️ DiscountBal │ │
│ │ (نقدی) │ │ (شبکه‌ای) │ │ (تخفیفی) │ │
│ │ │ │ │ │ │ │
│ │ • خرید فروشگاه │ │ • محاسبه │ │ • فروشگاه تخفیفی │ │
│ │ • هزینه فعالسازی │ │ کمیسیون │ │ • سهم 30% از │ │
│ │ (25M) │ │ • سقف 300/هفته │ │ قیمت محصول │ │
│ └───────┬────────┘ └────────┬────────┘ └────────┬─────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ═══════════════════ خروجی پول ═══════════════════ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ 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 ─┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
```
---
## ۳. فلوی داده (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 │
│ │
└─────────────────────────────────────────────────────────────────────────┘
```
---
## ۴. درخت باینری شبکه (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│
└───────┘ └───────┘ └──────┘ └──────┘
Legend:
L = Left leg sales this week
R = Right leg sales this week
Active = فعال (contract signed)
Pend. = در انتظار فعالسازی
Max depth = 15 levels
```
---
## ۵. فلوی خرید — Regular vs Discount Store
```
┌────────────────────────────────┬──────────────────────────────────┐
│ Regular Store │ Discount Store │
├────────────────────────────────┼──────────────────────────────────┤
│ │ │
│ [مشاهده محصولات] │ [مشاهده محصولات] ← فقط باشگاه │
│ │ │ │ │
│ ▼ │ ▼ │
│ [Lazy Load — 12 per page] │ [Lazy Load — 12 per page] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [افزودن به سبد] │ [افزودن به سبد] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [بررسی موجودی] │ [بررسی موجودی] │
│ │ │ [بررسی DiscountBalance] │
│ ▼ │ │ │
│ [Checkout] │ ▼ │
│ │ │ [محاسبه سهم تخفیف (30%)] │
│ ▼ │ [محاسبه سهم نقدی (70%)] │
│ [ZarinPal IPG] │ │ │
│ [100% نقدی] │ ▼ │
│ │ │ [کسر از DiscountBalance] │
│ ▼ │ [ZarinPal IPG برای باقیمانده] │
│ [ثبت سفارش] │ │ │
│ │ │ ▼ │
│ ▼ │ [ثبت سفارش ترکیبی] │
│ [کسر موجودی] │ [کسر موجودی] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [SMS تأیید] │ [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) │ │ │
│ │ └───────────┘ └───────────────┘ │ │
│ └────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────┘
```
---
## ۷. Entity Relationship (ساده‌شده)
```
┌──────────┐ ┌──────────────┐ ┌──────────────┐
│ User │────→│ ClubMembership│────→│ NetworkNode │
│ │ │ │ │ (BinaryTree)│
└────┬─────┘ └──────────────┘ └──────────────┘
├────→ ┌──────────┐ ┌──────────┐
│ │ Order │────→│ OrderItem│────→ [Product]
│ └──────────┘ └──────────┘
├────→ ┌──────────────┐
│ │ Transaction │────→ [Wallet (×3)]
│ └──────────────┘
├────→ ┌──────────────┐
│ │ UserContract │
│ └──────────────┘
└────→ ┌──────────────┐
│ ChatMessage │
└──────────────┘
┌──────────┐ ┌───────────┐
│ Product │────→│ Inventory │
│ │────→│ Category │
│ │────→│ Images │
└──────────┘
┌──────────┐ ┌──────────────────────┐
│ SitePage │ │ SystemConfiguration │
│ (typed) │ │ (key-value) │
└──────────┘ └──────────────────────┘
┌──────────┐
│ BlogPost │────→ [Tags, Category, Author]
└──────────┘
```