# 📚 FourSat Project Documentation

> **آخرین بروزرسانی**: January 3, 2026  
> **وضعیت**: ✅ Production Ready  
> **Domain**: `*.se.kbs1.ir`

---

## ⚡ Quick Reference (نکات مهم)

### 🌐 آدرس‌های Stage
| سرویس | آدرس |
|-------|------|
| BackOffice | `https://backoffice.se.kbs1.ir` |
| BackOffice BFF | `https://backoffice-bff.se.kbs1.ir` |
| FrontOffice | `https://frontoffice.se.kbs1.ir` |
| FrontOffice BFF | `https://frontoffice-bff.se.kbs1.ir` |
| CMS | `https://cms.se.kbs1.ir` |
| Git | `git.se.kbs1.ir` |

### 📦 Git Repositories
```bash
# BackOffice
git remote -v  # kub-stage → https://git.se.kbs1.ir/admin/BackOffice.git

# BackOffice.BFF
git remote -v  # kub-stage → https://git.se.kbs1.ir/admin/BackOffice.BFF.git

# CMS
git remote -v  # gitea → https://git.se.kbs1.ir/admin/CMS.git
```

### 🔧 Build Commands
```bash
# BackOffice (Proto DLLs required)
cd BackOffice && ./build-deps.sh
cd src && dotnet build BackOffice.sln

# BFF/CMS
cd [Project]/src && dotnet build

# Deploy
git push kub-stage main
```

---

## 🏗️ معماری پروژه

```
┌───────────────────────────────────────────────────────────────┐
│                    FRONTEND (Blazor WASM)                      │
│         BackOffice (Admin) │ FrontOffice (User)                │
└───────────────────────────────────────────────────────────────┘
                              │
                        gRPC-Web + JWT
                              ▼
┌───────────────────────────────────────────────────────────────┐
│                    BFF (Backend For Frontend)                  │
│       BackOffice.BFF │ FrontOffice.BFF                         │
│       CQRS + MediatR + Proto Contracts                         │
└───────────────────────────────────────────────────────────────┘
                              │
                          gRPC
                              ▼
┌───────────────────────────────────────────────────────────────┐
│                    CMS Microservice                            │
│       Clean Architecture + PostgreSQL                          │
│       Commission │ Network │ Club │ Inventory                  │
└───────────────────────────────────────────────────────────────┘
```

---

## 📂 ساختار پروژه

```
FourSat/
├── BackOffice/              # Admin Panel (Blazor WASM)
│   ├── src/BackOffice/      # UI - 96 pages, 21 modules
│   ├── libs/                # Pre-built Proto DLLs (24)
│   └── build-deps.sh        # Build proto dependencies
│
├── BackOffice.BFF/          # Backend For Frontend
│   └── src/Protobufs/       # 24 Proto projects
│
├── FrontOffice/             # User Frontend (Blazor WASM)
├── FrontOffice.BFF/         # Backend For Frontend
│
├── CMS/                     # Core Microservice
│   └── src/
│       ├── CMSMicroservice.Domain/
│       ├── CMSMicroservice.Application/
│       ├── CMSMicroservice.Infrastructure/
│       └── CMSMicroservice.WebApi/
│
├── DataMigration/           # One-time Migration Tool
│
└── totalDoc/                # Documentation
    └── final-docs/          # ← این پوشه
```

---

## 🔄 مدل کاری (Workflow)

### توسعه Local:
```bash
# 1. تغییرات در کد
# 2. Build و تست
dotnet build && dotnet run

# 3. Commit
git add . && git commit -m "feat: description"
```

### Deploy به Stage:
```bash
# Push به remote → Gitea Actions → Docker → K8s
git push kub-stage main
```

### تغییر Proto:
```bash
# 1. تغییر در CMS/BackOffice.BFF
# 2. Rebuild DLLs
cd BackOffice && ./build-deps.sh
# 3. Build UI
cd src && dotnet build
```

---

## 📊 وضعیت سیستم‌ها

| سیستم | ماژول‌ها | وضعیت |
|-------|---------|--------|
| BackOffice | 21 ماژول, 96 صفحه | ✅ Ready |
| BackOffice.BFF | 24 Proto | ✅ Ready |
| CMS | Commission, Network, Club, Inventory | ✅ Ready |
| FrontOffice | User UI | ⏳ Active |

---

## 🛠️ Tech Stack

| Layer | Technology |
|-------|------------|
| Frontend | Blazor WebAssembly, MudBlazor, .NET 9.0 |
| BFF | ASP.NET Core, gRPC, MediatR, Mapster |
| Backend | Clean Architecture, EF Core, PostgreSQL |
| Communication | gRPC, gRPC-Web, Protobuf |
| CI/CD | Gitea Actions, Docker, Kubernetes |
| Auth | JWT |

---

## ⚠️ نکات مهم

1. **Proto DLLs**: قبل از build کردن BackOffice، حتماً `./build-deps.sh` اجرا شود
2. **Domain**: همه آدرس‌ها به `*.se.kbs1.ir` تغییر کرده
3. **PublicMessage.Protobuf**: تنها proto با `net8.0` (بقیه `net9.0`)
4. **Package Versions**: `Google.Protobuf: 3.28.3`, `Grpc.Core.Api: 2.71.0`

---

## 📋 فهرست مستندات

| # | فایل | موضوع |
|---|------|-------|
| 1 | [01-BACKOFFICE.md](./01-BACKOFFICE.md) | Admin Panel - ماژول‌ها و صفحات |
| 2 | [02-PROTO-GUIDE.md](./02-PROTO-GUIDE.md) | Proto & gRPC - راهنمای packaging |
| 3 | [03-DATA-MIGRATION.md](./03-DATA-MIGRATION.md) | Data Migration - 33 جدول |
| 4 | [04-CMS.md](./04-CMS.md) | CMS Microservice |
| 5 | [05-DEPLOYMENT.md](./05-DEPLOYMENT.md) | Deployment & CI/CD |

---

## 📁 آرشیو

مستندات قدیمی در `totalDoc/archive/` نگهداری می‌شوند
