Files
docs/03-BACKEND/BackOffice.BFF
masoodafar-web 6380517ba2 docs: Add CHANGELOG-2025-12-26 and update documentation
- Add CHANGELOG-2025-12-26.md for App Version Management feature
- Update 00-INDEX.md with latest achievements and version 2.5
- Update BackOffice README with App Version Management info
- Update BackOffice.BFF README with new package versions
- Update FrontOffice README with ReferralCode feature
2025-12-26 06:12:24 +03:30
..

BackOffice.BFF

Backend For Frontend layer برای BackOffice UI

📋 خلاصه

BackOffice.BFF لایه واسط بین BackOffice UI و CMS microservices است که:

  • درخواست‌های UI را aggregate می‌کند
  • قراردادهای gRPC اختصاصی ارائه می‌دهد
  • منطق سطح BFF را پیاده‌سازی می‌کند

🏗️ معماری

Protobuf Projects (Own Contracts)

BackOffice.BFF از قراردادهای Protobuf اختصاصی خودش استفاده می‌کند:

Project Version Namespace Purpose
BackOffice.BFF.ClubMembership.Protobuf 0.0.7 Foursat.BackOffice.BFF.ClubMembership.Protos باشگاه مشتریان
BackOffice.BFF.Commission.Protobuf 0.0.13 Foursat.BackOffice.BFF.Commission.Protos کمیسیون
BackOffice.BFF.Configuration.Protobuf 1.0.20 BackOffice.BFF.Configuration.Protobuf.Protos تنظیمات + AppVersion
BackOffice.BFF.NetworkMembership.Protobuf 0.0.11 Foursat.BackOffice.BFF.NetworkMembership.Protos شبکه

تغییر معماری (۱۷ آذر ۱۴۰۴):

  • قبلا: استفاده مستقیم از CMSMicroservice.Protobuf (Anti-Pattern)
  • حالا: Protobuf اختصاصی با namespace مجزا
  • مزایا: جدایی concerns، versioning مستقل، کاهش coupling

GrpcServices Mode

همه پروژه‌های Protobuf با GrpcServices="Both" پیکربندی شده‌اند:

  • Server: Base classes برای پیاده‌سازی در BFF
  • Client: Client classes برای استفاده در BackOffice UI

HTTP Annotations (Swagger)

همه 33 endpoint با HTTP annotations پیاده‌سازی شده‌اند:

import "google/api/annotations.proto";

rpc GetClubMembershipById(GetClubMembershipByIdRequest) returns (GetClubMembershipByIdResponse) {
    option (google.api.http) = { get: "/GetClubMembershipById" };
}

Package: Google.Api.CommonProtos v2.10.0

🔧 Mapster Configuration

Immutable Type Handling

Protobuf messages دارای فیلدهای immutable هستند. از MapWith() استفاده کنید:

config.NewConfig<GetNetworkTreeResponseDto, GetNetworkTreeResponse>()
    .MapWith(src => new GetNetworkTreeResponse {
        Items = { src.Items.Select(x => new NetworkTreeNodeModel {
            UserId = x.UserId,
            FirstName = x.FirstName,
            // ...
        }) }
    });

Profiles:

  • NetworkMembershipProfile.cs
  • ProductsProfile.cs

📦 Package Publishing

برای publish به GitLab registry:

cd BackOffice.BFF.{Module}.Protobuf
dotnet pack -c Release
# Auto-push via PushToFourSat target

Registry: https://git.afrino.co/api/packages/FourSat/nuget