feat: V2 microservices stack — backend services, gateway, JWT auth
Add full V2 architecture: identity, content, studio (.NET 10) and file, render, notification, gateway (Go) services with vendored deps, plus DB migrations, event/API contracts, and an init-db script. Wire the Next.js frontend to the gateway: server-side JWT auth routes (login/register/refresh/logout/me), gateway fetch helper, and session/ cookie/jwt helpers under src/lib. Containerize the stack via docker-compose.v2.yml and per-service Dockerfiles. Base images resolve through a Nexus mirror (Docker Hub) and MCR directly; npm/NuGet pull from Nexus groups. Self-host fonts via next/font/local to avoid Google Fonts (geo-blocked). Add CI workflow and ignore .env.v2, *.stackdump, and .NET bin/obj. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
using FlatRender.IdentitySvc.Models.Requests;
|
||||
using FlatRender.IdentitySvc.Models.Responses;
|
||||
|
||||
namespace FlatRender.IdentitySvc.Application.Services.Interfaces;
|
||||
|
||||
public interface IAuthService
|
||||
{
|
||||
Task<RegisterResponse> RegisterAsync(RegisterRequest request, string? ipAddress);
|
||||
Task<AuthTokensResponse> LoginAsync(LoginRequest request, string? ipAddress);
|
||||
Task<AuthTokensResponse> RefreshAsync(string refreshToken);
|
||||
Task LogoutAsync(Guid sessionId, Guid userId);
|
||||
Task<List<SessionResponse>> GetSessionsAsync(Guid userId);
|
||||
Task RevokeSessionAsync(Guid sessionId, Guid userId);
|
||||
Task<bool> VerifyEmailAsync(string tokenHash, string code);
|
||||
Task<bool> VerifyPhoneAsync(string tokenHash, string code);
|
||||
Task RequestPasswordResetAsync(string tenantSlug, string? email, string? phone);
|
||||
Task<bool> ConfirmPasswordResetAsync(string token, string newPassword);
|
||||
Task ChangePasswordAsync(Guid userId, string currentPassword, string newPassword);
|
||||
Task<MfaSetupResponse> SetupMfaAsync(Guid userId, string factorType, string? label);
|
||||
Task<bool> VerifyMfaAsync(Guid userId, Guid factorId, string code);
|
||||
Task<AuthTokensResponse> ChallengeMfaAsync(string mfaToken, string code);
|
||||
Task SubscribePushAsync(Guid userId, Guid tenantId, string endpoint, string p256dh, string auth, string? userAgent);
|
||||
Task UnsubscribePushAsync(Guid userId, string? endpoint);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using FlatRender.IdentitySvc.Models.Requests;
|
||||
using FlatRender.IdentitySvc.Models.Responses;
|
||||
|
||||
namespace FlatRender.IdentitySvc.Application.Services.Interfaces;
|
||||
|
||||
public interface IDiscountService
|
||||
{
|
||||
Task<DiscountValidateResponse> ValidateAsync(Guid tenantId, string code, Guid? planId);
|
||||
Task<PagedResponse<DiscountResponse>> ListAsync(Guid tenantId, int page, int pageSize);
|
||||
Task<DiscountResponse> CreateAsync(Guid tenantId, CreateDiscountRequest request);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using FlatRender.IdentitySvc.Models.Responses;
|
||||
|
||||
namespace FlatRender.IdentitySvc.Application.Services.Interfaces;
|
||||
|
||||
public interface IGamificationService
|
||||
{
|
||||
Task<List<QuestResponse>> GetActiveQuestsAsync(Guid userId, Guid tenantId);
|
||||
Task ClaimQuestPrizeAsync(Guid userId, Guid questId);
|
||||
Task<List<EarnedGiftResponse>> GetEarnedGiftsAsync(Guid userId);
|
||||
Task UseEarnedGiftAsync(Guid userId, Guid earnedGiftId);
|
||||
Task IncrementQuestProgressAsync(Guid userId, Guid tenantId, string targetEvent);
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
using FlatRender.IdentitySvc.Models.Requests;
|
||||
using FlatRender.IdentitySvc.Models.Responses;
|
||||
|
||||
namespace FlatRender.IdentitySvc.Application.Services.Interfaces;
|
||||
|
||||
public interface IPaymentService
|
||||
{
|
||||
Task<PagedResponse<PaymentResponse>> GetUserPaymentsAsync(Guid userId, int page, int pageSize);
|
||||
Task<PaymentResponse> GetByIdAsync(Guid paymentId, Guid userId);
|
||||
|
||||
// ── ZarinPal ────────────────────────────────────────────────────────────────
|
||||
/// <summary>Calls ZarinPal request API and returns the zarinpal.com redirect URL.</summary>
|
||||
Task<string> InitiateZarinPalAsync(Guid paymentId, Guid userId);
|
||||
Task<string> HandleZarinPalCallbackAsync(string authority, string status);
|
||||
|
||||
// ── SnapPay ──────────────────────────────────────────────────────────────────
|
||||
/// <summary>Calls SnapPay token API and returns the snappay.ir redirect URL.</summary>
|
||||
Task<string> InitiateSnapPayAsync(Guid paymentId, Guid userId);
|
||||
/// <summary>Handles SnapPay callback query params (paymentToken, shapSnapStatus).</summary>
|
||||
Task<string> HandleSnapPayCallbackAsync(string paymentToken, string shapStatus);
|
||||
|
||||
// ── Tara ─────────────────────────────────────────────────────────────────────
|
||||
/// <summary>Calls Tara request API and returns the tara.ir redirect URL.</summary>
|
||||
Task<string> InitiateTaraAsync(Guid paymentId, Guid userId);
|
||||
/// <summary>Handles Tara callback query params (token, status).</summary>
|
||||
Task<string> HandleTaraCallbackAsync(string token, string status);
|
||||
|
||||
// ── Stripe ───────────────────────────────────────────────────────────────────
|
||||
Task HandleStripeWebhookAsync(string payload, string signature);
|
||||
|
||||
// ── Refunds ───────────────────────────────────────────────────────────────────
|
||||
Task<RefundResponse> IssueRefundAsync(Guid paymentId, long? amountMinor, string reason, string refundTo);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using FlatRender.IdentitySvc.Models.Requests;
|
||||
using FlatRender.IdentitySvc.Models.Responses;
|
||||
|
||||
namespace FlatRender.IdentitySvc.Application.Services.Interfaces;
|
||||
|
||||
public interface IPlanService
|
||||
{
|
||||
Task<List<PlanResponse>> ListAsync(Guid tenantId, string? scope);
|
||||
Task<PlanResponse> GetByIdAsync(Guid planId);
|
||||
Task<UserPlanResponse?> GetCurrentPlanAsync(Guid userId);
|
||||
Task<PurchasePlanResponse> PurchasePlanAsync(Guid userId, Guid tenantId, PurchasePlanRequest request);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
using FlatRender.IdentitySvc.Domain.Entities;
|
||||
using FlatRender.IdentitySvc.Models.Requests;
|
||||
using FlatRender.IdentitySvc.Models.Responses;
|
||||
|
||||
namespace FlatRender.IdentitySvc.Application.Services.Interfaces;
|
||||
|
||||
public interface ITenantService
|
||||
{
|
||||
Task<PagedResponse<TenantResponse>> ListAsync(int page, int pageSize);
|
||||
Task<TenantResponse> CreateAsync(CreateTenantRequest request);
|
||||
Task<TenantResponse> GetByIdAsync(Guid tenantId);
|
||||
Task<TenantResponse> GetBySlugAsync(string slug);
|
||||
Task<TenantResponse> UpdateAsync(Guid tenantId, UpdateTenantRequest request);
|
||||
Task<TenantBrandingResponse> GetBrandingAsync(Guid tenantId);
|
||||
Task<TenantBrandingResponse> UpsertBrandingAsync(Guid tenantId, TenantBrandingRequest request);
|
||||
Task<DomainVerificationResponse> StartDomainVerificationAsync(Guid tenantId, string domain, string method);
|
||||
Task<List<TenantUsageDayResponse>> GetUsageAsync(Guid tenantId, DateOnly from, DateOnly to);
|
||||
|
||||
// API Keys
|
||||
Task<List<ApiKeyResponse>> GetApiKeysAsync(Guid tenantId);
|
||||
Task<ApiKeyCreatedResponse> CreateApiKeyAsync(Guid tenantId, Guid createdByUserId, CreateApiKeyRequest request);
|
||||
Task RevokeApiKeyAsync(Guid tenantId, Guid apiKeyId, string? reason);
|
||||
Task<ApiKeyValidateResponse> ValidateApiKeyAsync(string keyPrefix, string keyHash, string? ipAddress);
|
||||
|
||||
// Webhooks
|
||||
Task<List<WebhookResponse>> GetWebhooksAsync(Guid tenantId);
|
||||
Task<WebhookResponse> CreateWebhookAsync(Guid tenantId, CreateWebhookRequest request);
|
||||
Task DeleteWebhookAsync(Guid tenantId, Guid webhookId);
|
||||
Task<List<WebhookDeliveryResponse>> GetWebhookDeliveriesAsync(Guid tenantId, Guid webhookId);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using FlatRender.IdentitySvc.Domain.Entities;
|
||||
|
||||
namespace FlatRender.IdentitySvc.Application.Services.Interfaces;
|
||||
|
||||
public interface ITokenService
|
||||
{
|
||||
string GenerateAccessToken(User user, Tenant tenant);
|
||||
string GenerateRefreshToken();
|
||||
string HashToken(string token);
|
||||
(Guid userId, Guid tenantId, bool isAdmin) ValidateAccessToken(string token);
|
||||
string GenerateServiceToken();
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using FlatRender.IdentitySvc.Domain.Entities;
|
||||
using FlatRender.IdentitySvc.Models.Requests;
|
||||
using FlatRender.IdentitySvc.Models.Responses;
|
||||
|
||||
namespace FlatRender.IdentitySvc.Application.Services.Interfaces;
|
||||
|
||||
public interface IUserService
|
||||
{
|
||||
Task<UserResponse> GetMeAsync(Guid userId);
|
||||
Task<UserResponse> UpdateMeAsync(Guid userId, UpdateUserRequest request);
|
||||
Task<BalanceResponse> GetBalanceAsync(Guid userId);
|
||||
Task UpdateAvatarAsync(Guid userId, Guid? avatarId, string? avatarUrl);
|
||||
Task<UserResponse> GetByIdAsync(Guid userId);
|
||||
Task<PagedResponse<UserResponse>> SearchAsync(string? q, Guid? tenantId, int page, int pageSize);
|
||||
Task BanAsync(Guid userId, string reason, DateTime? unblockDate);
|
||||
Task UnbanAsync(Guid userId);
|
||||
}
|
||||
Reference in New Issue
Block a user