1185 lines
62 KiB
HTML
1185 lines
62 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="fa" dir="rtl">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>تحلیل معماری ماژولهای پایه xSaherelm | 1405-08-23</title>
|
||
<style>
|
||
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
|
||
|
||
:root {
|
||
--primary: #1a365d;
|
||
--primary-light: #2c5282;
|
||
--accent: #c9a961;
|
||
--accent-dark: #a8893f;
|
||
--bg: #faf9f6;
|
||
--card-bg: #ffffff;
|
||
--text: #1a202c;
|
||
--text-muted: #4a5568;
|
||
--border: #e2e8f0;
|
||
--success: #38a169;
|
||
--danger: #e53e3e;
|
||
--warning: #dd6b20;
|
||
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
|
||
}
|
||
|
||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||
|
||
body {
|
||
font-family: 'Vazirmatn', Tahoma, sans-serif;
|
||
background: var(--bg);
|
||
color: var(--text);
|
||
line-height: 1.9;
|
||
font-size: 15px;
|
||
padding: 30px 15px;
|
||
}
|
||
|
||
.document-container {
|
||
max-width: 950px;
|
||
margin: 0 auto;
|
||
background: var(--card-bg);
|
||
box-shadow: var(--shadow);
|
||
border-radius: 12px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.document-header {
|
||
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
|
||
color: white;
|
||
padding: 50px 40px 40px;
|
||
position: relative;
|
||
border-bottom: 4px solid var(--accent);
|
||
}
|
||
|
||
.document-header::before {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0; right: 0;
|
||
width: 200px; height: 200px;
|
||
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
|
||
border-radius: 50%;
|
||
transform: translate(50%, -50%);
|
||
}
|
||
|
||
.header-top {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 30px;
|
||
position: relative;
|
||
z-index: 1;
|
||
}
|
||
|
||
.company-badge {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
|
||
.company-logo {
|
||
width: 60px; height: 60px;
|
||
background: var(--accent);
|
||
border-radius: 12px;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
|
||
}
|
||
|
||
.doc-meta {
|
||
text-align: left;
|
||
font-size: 12px;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.doc-meta div { margin-bottom: 3px; }
|
||
|
||
.document-title {
|
||
text-align: center;
|
||
position: relative;
|
||
z-index: 1;
|
||
padding: 20px 0;
|
||
}
|
||
|
||
.document-title .label {
|
||
display: inline-block;
|
||
background: rgba(201,169,97,0.2);
|
||
color: var(--accent);
|
||
padding: 4px 16px;
|
||
border-radius: 20px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
margin-bottom: 15px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
|
||
.document-title h1 {
|
||
font-size: 28px;
|
||
font-weight: 800;
|
||
margin-bottom: 10px;
|
||
letter-spacing: -0.5px;
|
||
}
|
||
|
||
.document-title h2 {
|
||
font-size: 16px;
|
||
font-weight: 400;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.document-body {
|
||
padding: 40px;
|
||
}
|
||
|
||
.intro-text {
|
||
background: linear-gradient(to left, #f7fafc, #edf2f7);
|
||
border-right: 4px solid var(--accent);
|
||
padding: 20px 25px;
|
||
border-radius: 8px;
|
||
margin-bottom: 35px;
|
||
font-size: 14px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.section {
|
||
margin-bottom: 40px;
|
||
page-break-inside: avoid;
|
||
}
|
||
|
||
.section-header {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 15px;
|
||
padding-bottom: 12px;
|
||
border-bottom: 2px solid var(--border);
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.section-number {
|
||
width: 50px; height: 50px;
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
border-radius: 12px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-weight: 800;
|
||
font-size: 20px;
|
||
flex-shrink: 0;
|
||
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
|
||
}
|
||
|
||
.section-title { flex: 1; }
|
||
|
||
.section-title h3 {
|
||
font-size: 19px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 2px;
|
||
}
|
||
|
||
.section-title .subtitle {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.section-content {
|
||
padding-right: 10px;
|
||
}
|
||
|
||
.section-content p {
|
||
margin-bottom: 12px;
|
||
text-align: justify;
|
||
text-indent: 20px;
|
||
}
|
||
|
||
.section-content p.no-indent { text-indent: 0; }
|
||
|
||
.highlight-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #f6e05e;
|
||
border-right: 4px solid var(--accent);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.highlight-box strong {
|
||
color: var(--accent-dark);
|
||
}
|
||
|
||
.info-box {
|
||
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
|
||
border: 1px solid #90cdf4;
|
||
border-right: 4px solid var(--primary-light);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.success-box {
|
||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||
border: 1px solid #9ae6b4;
|
||
border-right: 4px solid var(--success);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.warning-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #fbd38d;
|
||
border-right: 4px solid var(--warning);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.styled-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 20px 0;
|
||
background: white;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||
}
|
||
|
||
.styled-table thead {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
}
|
||
|
||
.styled-table th {
|
||
padding: 14px 16px;
|
||
text-align: right;
|
||
font-weight: 600;
|
||
font-size: 13px;
|
||
}
|
||
|
||
.styled-table td {
|
||
padding: 13px 16px;
|
||
border-bottom: 1px solid var(--border);
|
||
font-size: 13px;
|
||
}
|
||
|
||
.styled-table tbody tr:last-child td { border-bottom: none; }
|
||
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
|
||
|
||
.styled-table .highlight-row {
|
||
background: #fffaf0 !important;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.comparison-grid {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 20px;
|
||
margin: 25px 0;
|
||
}
|
||
|
||
.comparison-card {
|
||
background: #f8fafc;
|
||
border: 2px solid var(--border);
|
||
border-radius: 10px;
|
||
padding: 20px;
|
||
position: relative;
|
||
}
|
||
|
||
.comparison-card.recommended {
|
||
border-color: var(--success);
|
||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||
}
|
||
|
||
.comparison-card .card-badge {
|
||
position: absolute;
|
||
top: -10px;
|
||
right: 20px;
|
||
background: var(--success);
|
||
color: white;
|
||
padding: 3px 12px;
|
||
border-radius: 15px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.comparison-card h4 {
|
||
font-size: 16px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 15px;
|
||
padding-bottom: 10px;
|
||
border-bottom: 2px solid var(--border);
|
||
}
|
||
|
||
.comparison-card.recommended h4 {
|
||
border-bottom-color: var(--success);
|
||
}
|
||
|
||
.comparison-card ul {
|
||
list-style: none;
|
||
padding: 0;
|
||
}
|
||
|
||
.comparison-card ul li {
|
||
padding: 8px 0;
|
||
border-bottom: 1px solid var(--border);
|
||
font-size: 13px;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.comparison-card ul li:last-child { border-bottom: none; }
|
||
|
||
.comparison-card ul li .value {
|
||
font-weight: 600;
|
||
color: var(--primary);
|
||
}
|
||
|
||
.quote-box {
|
||
background: linear-gradient(135deg, #f7fafc, #edf2f7);
|
||
border-right: 4px solid var(--accent);
|
||
padding: 20px 25px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
position: relative;
|
||
}
|
||
|
||
.quote-box::before {
|
||
content: '"';
|
||
position: absolute;
|
||
top: -10px;
|
||
right: 15px;
|
||
font-size: 60px;
|
||
color: var(--accent);
|
||
opacity: 0.3;
|
||
font-family: Georgia, serif;
|
||
}
|
||
|
||
.quote-box p {
|
||
font-style: italic;
|
||
color: var(--text-muted);
|
||
margin-bottom: 10px;
|
||
text-indent: 0 !important;
|
||
}
|
||
|
||
.quote-box .source {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
text-align: left;
|
||
font-style: normal;
|
||
}
|
||
|
||
.stats-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(3, 1fr);
|
||
gap: 15px;
|
||
margin: 25px 0;
|
||
}
|
||
|
||
.stat-card {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 20px;
|
||
border-radius: 10px;
|
||
text-align: center;
|
||
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
|
||
}
|
||
|
||
.stat-card .stat-value {
|
||
font-size: 24px;
|
||
font-weight: 800;
|
||
margin-bottom: 5px;
|
||
color: var(--accent);
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.stat-card .stat-label {
|
||
font-size: 12px;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.timeline {
|
||
position: relative;
|
||
padding: 20px 0;
|
||
margin: 25px 0;
|
||
}
|
||
|
||
.timeline::before {
|
||
content: '';
|
||
position: absolute;
|
||
right: 50%;
|
||
top: 0;
|
||
bottom: 0;
|
||
width: 3px;
|
||
background: var(--border);
|
||
transform: translateX(50%);
|
||
}
|
||
|
||
.timeline-item {
|
||
display: flex;
|
||
margin-bottom: 20px;
|
||
position: relative;
|
||
}
|
||
|
||
.timeline-item:nth-child(odd) {
|
||
flex-direction: row-reverse;
|
||
}
|
||
|
||
.timeline-content {
|
||
width: 45%;
|
||
background: #f8fafc;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
padding: 15px;
|
||
position: relative;
|
||
}
|
||
|
||
.timeline-item:nth-child(odd) .timeline-content {
|
||
margin-left: 5%;
|
||
}
|
||
|
||
.timeline-item:nth-child(even) .timeline-content {
|
||
margin-right: 5%;
|
||
}
|
||
|
||
.timeline-dot {
|
||
position: absolute;
|
||
right: 50%;
|
||
top: 20px;
|
||
width: 16px;
|
||
height: 16px;
|
||
background: var(--accent);
|
||
border: 3px solid white;
|
||
border-radius: 50%;
|
||
transform: translateX(50%);
|
||
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
|
||
z-index: 1;
|
||
}
|
||
|
||
.timeline-content h5 {
|
||
font-size: 14px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.timeline-content p {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
text-indent: 0 !important;
|
||
margin-bottom: 0 !important;
|
||
}
|
||
|
||
.reference-list {
|
||
list-style: none;
|
||
padding: 0;
|
||
margin: 20px 0;
|
||
}
|
||
|
||
.reference-list li {
|
||
background: #f8fafc;
|
||
border-right: 3px solid var(--primary-light);
|
||
padding: 15px 20px;
|
||
margin-bottom: 10px;
|
||
border-radius: 6px;
|
||
font-size: 13px;
|
||
}
|
||
|
||
.reference-list li strong {
|
||
color: var(--primary);
|
||
display: block;
|
||
margin-bottom: 5px;
|
||
}
|
||
|
||
.reference-list li .ref-source {
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
margin-top: 5px;
|
||
}
|
||
|
||
.conclusion-box {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 30px;
|
||
border-radius: 12px;
|
||
margin: 30px 0;
|
||
text-align: center;
|
||
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
|
||
}
|
||
|
||
.conclusion-box h3 {
|
||
font-size: 22px;
|
||
font-weight: 800;
|
||
margin-bottom: 15px;
|
||
color: var(--accent);
|
||
}
|
||
|
||
.conclusion-box p {
|
||
font-size: 14px;
|
||
line-height: 1.8;
|
||
text-indent: 0 !important;
|
||
margin-bottom: 15px;
|
||
}
|
||
|
||
.conclusion-box .highlight {
|
||
background: rgba(201,169,97,0.2);
|
||
padding: 15px 20px;
|
||
border-radius: 8px;
|
||
margin-top: 20px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
|
||
.document-footer {
|
||
background: var(--primary);
|
||
color: white;
|
||
padding: 25px 40px;
|
||
text-align: center;
|
||
font-size: 12px;
|
||
margin-top: 40px;
|
||
}
|
||
|
||
.document-footer .footer-brand {
|
||
font-weight: 700;
|
||
color: var(--accent);
|
||
margin-bottom: 5px;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.footer-divider {
|
||
width: 60px;
|
||
height: 2px;
|
||
background: var(--accent);
|
||
margin: 10px auto;
|
||
}
|
||
|
||
.page-info {
|
||
text-align: center;
|
||
padding: 15px;
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
border-top: 1px solid var(--border);
|
||
margin-top: 30px;
|
||
}
|
||
|
||
@media print {
|
||
body { background: white; padding: 0; }
|
||
.document-container { box-shadow: none; border-radius: 0; }
|
||
.section { page-break-inside: avoid; }
|
||
}
|
||
|
||
@media (max-width: 768px) {
|
||
.document-body { padding: 25px 20px; }
|
||
.document-header { padding: 30px 20px; }
|
||
.comparison-grid { grid-template-columns: 1fr; }
|
||
.stats-grid { grid-template-columns: 1fr; }
|
||
.header-top { flex-direction: column; gap: 15px; }
|
||
.doc-meta { text-align: center; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<div class="document-container">
|
||
|
||
<header class="document-header">
|
||
<div class="header-top">
|
||
<div class="company-badge">
|
||
<div class="company-logo"></div>
|
||
</div>
|
||
<div class="doc-meta">
|
||
<div>شماره مستند: ARCH-1405-0823</div>
|
||
<div>نسخه: ۱.۰</div>
|
||
<div>تاریخ تهیه: ۲۳ آبان ۱۴۰۵</div>
|
||
<div>طبقهبندی: داخلی / فنی</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="document-title">
|
||
<span class="label">ARCHITECTURE OVERVIEW</span>
|
||
<h1>تحلیل معماری ماژولهای پایه xSaherelm</h1>
|
||
<h2>بررسی ساختار، الگوها، وابستگیها و ریسکهای ۲۳ ماژول زیرساختی</h2>
|
||
</div>
|
||
</header>
|
||
|
||
<div class="document-body">
|
||
|
||
<div class="intro-text">
|
||
<strong>هدف مستند:</strong><br>
|
||
این گزارش حاصل بررسی کامل سورسکد ۲۳ ماژول پایهی واقع در مسیر <code>Modules/</code> فضای کاری xSaherelm است. در این بررسی فایلهای <code>.csproj</code>، ساختار پوشهها، قراردادها (Interfaces)، پیادهسازیها (Providers)، الگوهای ثبت سرویس (DI) و زنجیرهی وابستگی بین ماژولها تحلیل شده و در نهایت نقاط قوت، ریسکها و پیشنهادهای بهبود معماری ارائه شده است. تمامی آمار (تعداد فایل و خطوط) مستقیماً از کد استخراج شده و پوشههای <code>bin/obj</code> در شمارش لحاظ نشدهاند.
|
||
</div>
|
||
|
||
<!-- ===================== بخش ۱ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۱</div>
|
||
<div class="section-title">
|
||
<h3>خلاصه اجرایی</h3>
|
||
<div class="subtitle">Executive Summary</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>مجموعه ماژولهای xSaherelm یک <strong>فریمورک ماژولار سرویسگرا</strong> بر پایه .NET Standard 2.0 است که بهصورت لایهای طراحی شده است: از لایهی استثناها و ابزارهای عمومی شروع میشود، در لایهی داده (Repository + Unit of Work + GraphQL) تثبیت میگردد، سپس زیرساختهای هویت، Push (SignalR)، رویداد (Kafka/RabbitMQ/ZeroMQ) و لاگ را فراهم کرده و در نهایت سرویسهای دامنه (Tag، String، Category، File، Content، Webinar، Bot، AI) را روی این ستون فقرات میسازد.</p>
|
||
|
||
<div class="stats-grid">
|
||
<div class="stat-card">
|
||
<div class="stat-value">۲۳</div>
|
||
<div class="stat-label">ماژول بررسیشده (netstandard2.0 / C# 12)</div>
|
||
</div>
|
||
<div class="stat-card">
|
||
<div class="stat-value">۱,۰۳۱</div>
|
||
<div class="stat-label">فایل سورس C#</div>
|
||
</div>
|
||
<div class="stat-card">
|
||
<div class="stat-value">≈ ۹۶,۱۰۰</div>
|
||
<div class="stat-label">خط کد (بدون bin/obj)</div>
|
||
</div>
|
||
</div>
|
||
|
||
<p>مهمترین ویژگی معماری، <strong>الگوی تکرارشوندهی «Entity Service Blueprint»</strong> است: هر موجودیت دامنه (مثلاً XTag یا XAiConversation) با مجموعهای ثابت از ۱۵ تا ۲۰ کلاس (Repository های EF/Mongo/InMemory، KeyGenerator، RepositoryEvents، Seeder، EntityHub/DtoHub برای SignalR، GraphType/GraphQuery/GraphSchema و RepositoryService/ServiceProvider) پیاده میشود و از طریق یک <code>XRepositoryDescriptor</code> در DI ثبت میگردد. این رویکرد یکنواختی بسیار بالایی ایجاد کرده اما هزینهی boilerplate قابل توجهی دارد.</p>
|
||
|
||
<div class="highlight-box">
|
||
<strong>جمعبندی یکخطی:</strong> معماری از نظر انسجام و قابلیت تعویض زیرساخت (DB/Broker/Transport) بسیار قوی است؛ ریسکهای اصلی در <em>قدیمیبودن نسخهی وابستگیها</em> (EF Core 3.1، ASP.NET Core 2.2)، <em>حجم زیاد ماژول xCommons</em> و <em>عمق زنجیرهی وابستگی</em> (xIdentityService در مرکز گراف) متمرکز است.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- ===================== بخش ۲ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۲</div>
|
||
<div class="section-title">
|
||
<h3>معماری کلان و لایهبندی</h3>
|
||
<div class="subtitle">Macro Architecture & Layering</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>با تحلیل <code>ProjectReference</code>های هر <code>.csproj</code>، گراف وابستگی ماژولها بهصورت یک DAG بدون حلقه استخراج شد. ماژولها به ۱۰ لایهی توپولوژیک تقسیم میشوند که هر لایه تنها به لایههای پایینتر وابسته است:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>لایه</th>
|
||
<th>ماژولها</th>
|
||
<th>نقش معماری</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>L0 – Kernel</td><td>xExceptions</td><td>کدهای خطای استاندارد (enum XException) + مدل XError</td></tr>
|
||
<tr><td>L1 – Commons</td><td>xCommons</td><td>Extensionها، Helperها، RateLimit، BackgroundService، Swagger، Authorization پایه</td></tr>
|
||
<tr><td>L2 – Models</td><td>xModels</td><td>کلاسهای پایهی Entity/Dto، XQuery/XQueryResult، In-Memory Store</td></tr>
|
||
<tr><td>L3 – Infra Core</td><td>xDataService، xIdentityModels، xMessageService، xStorageService، xEventService</td><td>دسترسی داده (EF/Mongo/InMemory + GraphQL)، مدلهای هویت، ایمیل/SMS، ذخیرهسازی فایل، EventBus</td></tr>
|
||
<tr><td>L4 – Transport</td><td>xHttpService، xLoggingService</td><td>کلاینت HTTP/SSE (RestSharp)، Logging/OpenTelemetry</td></tr>
|
||
<tr><td>L5 – Identity</td><td>xIdentityService</td><td>اتصال به IdentityServer، Token، Proxy، ApiKey، Policy</td></tr>
|
||
<tr><td>L6 – Realtime & Auth Helpers</td><td>xPushService، xIdentityHelper</td><td>SignalR Hubs پایه، Controllerهای Account، نقشها و Policyها</td></tr>
|
||
<tr><td>L7 – Core Domain</td><td>xTagService، xStringService، xBotService</td><td>برچسبگذاری، منابع رشتهای چندزبانه، ربات پیامرسان (Bale)</td></tr>
|
||
<tr><td>L8 – Domain</td><td>xFileService، xCategoryService، xTermsAndConditionsService، xAiModels</td><td>مدیریت فایل، دستهبندی، قوانین، مدلهای دادهی AI</td></tr>
|
||
<tr class="highlight-row"><td>L9 – Composite</td><td>xContentService، xWebinarService، xAiService</td><td>سرویسهای ترکیبی سطح بالا (محتوا، وبینار، MCP/AI)</td></tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="info-box">
|
||
<strong>نکتهی معماری:</strong> خط اصلی وابستگی بهصورت
|
||
<code>xExceptions → xCommons → xModels → xDataService → xIdentityService → xPushService → xTagService/xStringService → xFileService → xContentService</code>
|
||
است. این یعنی هر سرویس دامنه (حتی xStringService که مفهوماً به هویت ربطی ندارد) بهصورت گذرا به <strong>xIdentityService و تمامی پکیجهای آن</strong> وابسته میشود.
|
||
</div>
|
||
|
||
<h4 style="color:var(--primary);margin:20px 0 10px;">گراف وابستگی مستقیم (ProjectReference)</h4>
|
||
<table class="styled-table">
|
||
<thead><tr><th>ماژول</th><th>وابستگیهای مستقیم</th></tr></thead>
|
||
<tbody>
|
||
<tr><td>xExceptions</td><td>—</td></tr>
|
||
<tr><td>xCommons</td><td>xExceptions</td></tr>
|
||
<tr><td>xModels</td><td>xCommons</td></tr>
|
||
<tr><td>xDataService</td><td>xModels</td></tr>
|
||
<tr><td>xIdentityModels</td><td>xModels</td></tr>
|
||
<tr><td>xMessageService</td><td>xModels</td></tr>
|
||
<tr><td>xStorageService</td><td>xModels</td></tr>
|
||
<tr><td>xEventService</td><td>xCommons</td></tr>
|
||
<tr><td>xHttpService</td><td>xIdentityModels</td></tr>
|
||
<tr><td>xLoggingService</td><td>xEventService</td></tr>
|
||
<tr><td>xIdentityService</td><td>xDataService، xHttpService</td></tr>
|
||
<tr><td>xPushService</td><td>xIdentityService</td></tr>
|
||
<tr><td>xIdentityHelper</td><td>xPushService، xIdentityService</td></tr>
|
||
<tr><td>xTagService</td><td>xPushService</td></tr>
|
||
<tr><td>xStringService</td><td>xPushService</td></tr>
|
||
<tr><td>xBotService</td><td>xHttpService، xDataService، xPushService</td></tr>
|
||
<tr><td>xFileService</td><td>xTagService، xStorageService</td></tr>
|
||
<tr><td>xCategoryService</td><td>xStringService</td></tr>
|
||
<tr><td>xTermsAndConditionsService</td><td>xStringService</td></tr>
|
||
<tr><td>xAiModels</td><td>xStringService</td></tr>
|
||
<tr><td>xContentService</td><td>xTagService، xFileService، xStringService</td></tr>
|
||
<tr><td>xWebinarService</td><td>xFileService</td></tr>
|
||
<tr><td>xAiService</td><td>xAiModels، xFileService</td></tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- ===================== بخش ۳ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۳</div>
|
||
<div class="section-title">
|
||
<h3>الگوهای طراحی مشترک</h3>
|
||
<div class="subtitle">Cross-cutting Design Patterns</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>بررسی کد نشان میدهد که چند الگوی ثابت در تمامی ماژولها بهکار رفته و در واقع «زبان مشترک» فریمورک را تشکیل میدهند:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead><tr><th>الگو</th><th>محل تعریف</th><th>شرح پیادهسازی</th></tr></thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><strong>Generic Repository + Unit of Work</strong></td>
|
||
<td>xDataService/Interfaces/IXBaseRepository.cs</td>
|
||
<td>قرارداد کامل CRUD با پشتیبانی Soft-Delete (فیلد <code>Deleted</code> در <code>XBaseEntity<T></code>)، صفحهبندی <code>XQuery/XQueryResult</code>، <code>IAsyncEnumerable</code>، include/order builder و <code>SaveChangesAsync</code>. سه پیادهسازی: <code>XBaseEFRepository</code>، <code>XBaseMongoRepository</code>، <code>XBaseInMemoryRepository</code>.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Repository Descriptor (Type Registry)</strong></td>
|
||
<td>xDataService/Models/XRepositoryDescriptor.cs</td>
|
||
<td>یک کلاس غیرجنریک که ۱۶ <code>Type</code> (Entity، Key، Context، GraphType، GraphQuery، Events، KeyGenerator، Seeder و…) را نگه میدارد و با <code>services.AddXRepository(descriptor)</code> کل زنجیره را ثبت میکند. نسخههای جنریک <code>XEFRepositoryDescriptor<…17 type param…></code> type-safety را تضمین میکنند.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Service Layer با AutoMapper</strong></td>
|
||
<td>xDataService/Interfaces/IXBaseRepositoryService.cs</td>
|
||
<td>لایهی <code>IXBaseRepositoryService<TEntity,TDto,TKey></code> همان API Repository را روی Dto ارائه میکند و <code>IMapper</code> و <code>MapperConfiguration</code> را expose میکند.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Entity/Dto Hubs (SignalR Broadcast)</strong></td>
|
||
<td>xPushService/Interfaces/IXBaseEntityHub.cs</td>
|
||
<td>هر موجودیت دو Hub دارد (<code>XxxEntityHub</code>، <code>XxxDtoHub</code>) با متدهای Add/AddMany/Update/Delete که تغییرات CRUD را به کلاینتها push میکند. ثبت با <code>XPushServiceHelper.AddHub<T>()</code>.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Repository Events (Observer)</strong></td>
|
||
<td>xDataService/Providers/XBaseRepositoryEvents.cs</td>
|
||
<td>با <code>System.Reactive</code> رویدادهای Added/Updated/Removed را منتشر میکند؛ Hubها و Enricherها به آن subscribe میشوند.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>GraphQL per Entity</strong></td>
|
||
<td>xDataService/GraphQL/*</td>
|
||
<td>هر موجودیت <code>GraphType</code>، <code>GraphQuery</code>، <code>GraphSchema</code> و <code>GraphQLTypeHelper</code> دارد؛ Subscription روی رویدادهای Repository سوار است.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Entity Registerar</strong></td>
|
||
<td>xDataService/Providers/XBaseEntityRegisterar.cs</td>
|
||
<td>ثبت پیکربندی EF (<code>IEntityTypeConfiguration</code>) بهصورت افزونهای توسط هر ماژول؛ <code>XEntityRegisterarHandlerService</code> آنها را روی <code>XDbContext</code> اعمال میکند.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Provided / Provider</strong></td>
|
||
<td>xPushService/Providers/XBaseProvided.cs، xTagService/Providers/XBaseTagProvided.cs</td>
|
||
<td>الگوی ترکیبی: کلاسهای <code>XBaseProvided</code> پایهی کنترلرهایی هستند که از یک Provider تزریقشده استفاده میکنند؛ <code>XBaseProvidedHasTag</code> (۶۷۴ خط) قابلیت برچسبگذاری را به هر موجودیت اضافه میکند (Mixin via inheritance).</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>DI Extension + Configuration Node</strong></td>
|
||
<td>*/DI/XDIHelperExtension.cs + */Constants/ConfigurationNodeNames.cs</td>
|
||
<td>هر ماژول دقیقاً دو متد <code>AddXxxService(...)</code> و <code>UseXxxService(...)</code> دارد. اعتبارسنجی آرگومانها با <code>XException.InvalidArgs.ToException()</code> انجام میشود (۳۲۳ کاربرد در کل ماژولها).</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Resource Provider (i18n)</strong></td>
|
||
<td>xStringService/Interfaces/IXResourceProvider.cs</td>
|
||
<td>عناوین/توضیحات چندزبانهی موجودیتها (مثلاً <code>XCategoryTitleResourceProvider</code>, <code>XAiProjectTitleResourceProvider</code>) از طریق XString ذخیره میشوند؛ دلیل وابستگی xAiModels و xCategoryService به xStringService.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="success-box">
|
||
<strong>قرارداد خطا:</strong> enum <code>XException</code> با کدگذاری محدودهای (1xx Invalid، 2xx NotFound، …) و <code>[StringValue]</code> بهعنوان تنها منبع خطا در کل فریمورک استفاده میشود. پرکاربردترینها: InvalidArgs (۳۲۳)، NotFound (۸۲)، ActionFailed (۶۴)، InvalidConfiguration (۳۰)، NotAllowed (۲۷).
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- ===================== بخش ۴ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۴</div>
|
||
<div class="section-title">
|
||
<h3>تحلیل ماژولهای پایه (Kernel & Infrastructure)</h3>
|
||
<div class="subtitle">Foundation Modules Analysis</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<h4 style="color:var(--primary);margin:10px 0;">۴.۱ xExceptions — ۳ فایل / ۱۹۴ خط</h4>
|
||
<p class="no-indent">کوچکترین و پایهایترین ماژول. شامل enum <code>XException</code> با کدهای عددی دستهبندیشده، attribute <code>StringValue</code> و مدل <code>XError {Id, Message}</code>. هیچ وابستگی خارجی ندارد. <strong>ارزیابی:</strong> طراحی صحیح برای یک Kernel؛ تنها پیشنهاد، افزودن <code>XExceptionBase : Exception</code> تایپشده بهجای تبدیل enum به Exception در xCommons است تا لایهی Kernel مستقلتر شود.</p>
|
||
|
||
<h4 style="color:var(--primary);margin:10px 0;">۴.۲ xCommons — ۶۷ فایل / ۷,۶۴۳ خط</h4>
|
||
<p class="no-indent">شامل ۱۴ Extension، ۷ Helper (File/Network/Os/Reflection/XML)، RateLimit (Attribute + Middleware + Provider + Configuration)، سه نوع BackgroundService (<code>XBackgroundService</code>، <code>XResumableBackgroundService</code>، <code>XTimeBasedBackgroundService</code>)، <code>XFileTypeDetector</code>، <code>XCipher</code>، Swagger Filters و Authorization پایه (<code>RequiredRolesHandler</code>). کنترلرهای پایه <code>XBaseController / XBaseApiController / XBaseApiV1Controller</code> نیز اینجا هستند.</p>
|
||
<div class="warning-box">
|
||
<strong>ریسک معماری:</strong> xCommons به ۲۳ پکیج NuGet (AutoMapper، Swashbuckle، JwtBearer، PdfPig، Spire.PDF، libphonenumber، RecyclableMemoryStream…) وابسته است. چون <strong>همهی ماژولها</strong> بهصورت گذرا به xCommons وابستهاند، یک کتابخانهی صرفاً مدل (مانند xIdentityModels) نیز پکیجهای PDF و Swagger را حمل میکند. این ماژول کاندیدای اصلی تفکیک به <code>xCommons.Core</code>، <code>xCommons.AspNetCore</code> و <code>xCommons.Files</code> است.
|
||
</div>
|
||
|
||
<h4 style="color:var(--primary);margin:10px 0;">۴.۳ xModels — ۳۳ فایل / ۱,۳۶۶ خط</h4>
|
||
<p class="no-indent">سلسلهمراتب <code>XBaseEntity<T></code> (با Soft-Delete) و <code>XBaseEntityDto<T></code> برای کلیدهای Int/Long/Guid/String، <code>XBaseDescriptor</code>، <code>XBaseStorableDto</code> + <code>XBaseStoreEvent</code> (الگوی Store/Event برای کلاینت)، <code>XQuery/XQueryResult</code> برای صفحهبندی، Dtoهای مشترک (XPersonDto، XFileDto، XDeviceDto، XResourceDto) و <code>IXAuditable</code>. <strong>ارزیابی:</strong> طراحی تمیز و حداقلی؛ نکتهی قابلبهبود، نبود فیلدهای Audit (CreatedAt/UpdatedAt) در خود <code>XBaseEntity</code> است که بهصورت اختیاری با <code>IXAuditable</code> جبران شده.</p>
|
||
|
||
<h4 style="color:var(--primary);margin:10px 0;">۴.۴ xDataService — ۷۰ فایل / ۱۲,۲۲۷ خط</h4>
|
||
<p class="no-indent">قلب لایهی داده. <code>XDbContext</code> و <code>XUnitOfWorks</code>؛ سه Repository پایه (EF/Mongo/InMemory)؛ پنج KeyGenerator (Guid/SequentialGuid/Int/Long/String)؛ زیرساخت GraphQL (Query/Subscription/EventType/TypeHelper + Playground/Voyager)؛ آداپتورهای Mongo (<code>XMongoAsyncCursor</code>، <code>XMongoQueryable</code>، <code>XMongoReadPreferenceResolver</code>)؛ <code>XRepositoryDescriptorBuilder</code>؛ Seeder با <code>XDbSeedingMode</code>؛ پشتیبانی همزمان از SqlServer، Sqlite، MySql و Oracle.</p>
|
||
<div class="info-box">
|
||
<strong>نقطه قوت:</strong> انتزاع کامل روی سه نوع ذخیرهگاه با یک قرارداد واحد. <strong>ریسک:</strong> وابستگی به <code>Microsoft.EntityFrameworkCore 3.1.14</code> (EOL از دسامبر ۲۰۲۲)، <code>GraphQL 3.0</code> و <code>MongoDB.Driver 2.13</code>؛ همچنین نشت <code>IIncludableQueryable</code> از EF Core به امضای قرارداد <code>IXBaseRepository</code> که انتزاع Mongo/InMemory را ناقص میکند.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- ===================== بخش ۵ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۵</div>
|
||
<div class="section-title">
|
||
<h3>تحلیل ماژولهای زیرساختی میانی</h3>
|
||
<div class="subtitle">Infrastructure Services Analysis</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<table class="styled-table">
|
||
<thead><tr><th>ماژول</th><th>حجم</th><th>اجزای کلیدی</th><th>ارزیابی معماری</th></tr></thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><strong>xIdentityModels</strong></td>
|
||
<td>۶۰ فایل / ۳,۶۸۷ خط</td>
|
||
<td>۱۹ مدل (XToken، XLoginRequest/Response، XUserClaimsInfoDto ۲۵۰ خط، XBannedDevice، XCreateApiKeyRequest، XRotateApiKeyRequest)، ۱۲ Dto، ۷ Configuration (EF)، Navigations، Descriptors؛ پکیجهای JWT و Identity.Stores</td>
|
||
<td>تفکیک صحیح مدل از سرویس. پشتیبانی ApiKey (ایجاد/چرخش) نشاندهندهی تکامل اخیر است.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xHttpService</strong></td>
|
||
<td>۹ فایل / ۷۳۵ خط</td>
|
||
<td><code>IXHttpProvider</code> روی RestSharp 106، <code>XSseExtensions</code> برای Server-Sent Events، <code>XHttpMethod</code></td>
|
||
<td>ماژول کوچک و متمرکز؛ وابستگی به xIdentityModels فقط برای مدل Token است و میتواند با یک interface سبک جایگزین شود.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xIdentityService</strong></td>
|
||
<td>۵۵ فایل / ۱۱,۹۷۸ خط</td>
|
||
<td><code>XIdentityProvider</code> بهصورت ۸ partial (Admin، Application، Authentication، Friendship، Open، Profile، Registration، Search)، <code>XIdentityHttpProvider</code>، Middlewareهای <code>XProxyMiddleware</code>، <code>XIdentityTokenRefresher</code>، <code>XApiKeyUsageMiddleware</code>، <code>XPolicyHandler</code>، <code>XSecurityProvider</code>، <code>XInMemoryTokenProvider</code>، ۵ Controller پایه</td>
|
||
<td>دومین ماژول بزرگ. تقسیم partial برای مدیریت پیچیدگی مناسب است. <strong>ریسک:</strong> <code>IdentityModel.AspNetCore.OAuth2Introspection 4.0.0-preview.6</code> نسخهی پیشنمایش است. <code>XInMemoryTokenProvider</code> برای محیط چندنمونهای مناسب نیست.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xIdentityHelper</strong></td>
|
||
<td>۸ فایل / ۳,۹۹۶ خط</td>
|
||
<td><code>XAccountControllerBase</code> (۲,۷۹۹ خط!)، <code>XAuthorizationHelper</code> (۵۶۵)، <code>XUserRoles</code>، <code>XPolicies</code>، <code>XApiScopeHelper</code></td>
|
||
<td><strong>ریسک جدی:</strong> یک کنترلر ~۲,۸۰۰ خطی نشانهی God-Class است و باید به چند کنترلر موضوعی (Profile، Registration، Admin، Friendship) تفکیک شود. بقیهی ماژول صرفاً ثابتهاست.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xPushService</strong></td>
|
||
<td>۳۴ فایل / ۵,۹۸۰ خط</td>
|
||
<td><code>XBaseHub</code>، <code>XBaseEntityHub</code>، <code>XBaseWebRTCHub</code>، <code>IXHubContextFactory</code>، <code>XPushServiceUserNameProvider</code>، کنترلرهای Provided/RepositoryProvider/ServiceProvider؛ SignalR + MessagePack + NewtonsoftJson</td>
|
||
<td>پیادهسازی غنی (از جمله WebRTC signaling). وابستگی به xIdentityService فقط برای احراز هویت کاربر Hub است و موجب میشود تمام ماژولهای دامنه به Identity وابسته شوند؛ ناسازگاری نسخهی پکیجهای SignalR (1.1.0 / 3.1.31 / 5.0.17) قابل توجه است.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xEventService</strong></td>
|
||
<td>۲۶ فایل / ۲,۱۶۲ خط</td>
|
||
<td>Producer/Consumer پایه؛ سه پیادهسازی Kafka (Confluent 2.14)، RabbitMQ (6.2)، ZeroMQ (NetMQ 4.0)؛ <code>XEventServiceProvider</code>، <code>XEventMessage</code>، <code>XBaseEventConsumerBackgroundService</code></td>
|
||
<td>طراحی Strategy تمیز؛ انتخاب Broker از پیکربندی (<code>XEventBroker</code>). نکته: نبود Outbox pattern برای تضمین تحویل در کنار تراکنش DB.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xLoggingService</strong></td>
|
||
<td>۱۳ فایل / ۱,۰۹۶ خط</td>
|
||
<td><code>XLoggerProvider : ILoggerProvider</code>، <code>XLogDispatcher</code> (Background)، سه Writer (File/Database/Event)، <code>XRequestLoggingMiddleware</code>، OpenTelemetry (Hosting/Http/AspNetCore/OTLP 1.6)</td>
|
||
<td>الگوی Dispatcher + Writerهای قابلافزونه بسیار مناسب است؛ ادغام OpenTelemetry مدرنترین بخش زیرساخت است.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xMessageService</strong></td>
|
||
<td>۱۳ فایل / ۶۲۰ خط</td>
|
||
<td><code>IXMailService</code>، <code>IXSmsService</code>، <code>IXMessageProvider</code> (Facade)، مدلهای پیکربندی</td>
|
||
<td>ساده و کافی. RestSharp 106.6.10 با نسخهی xHttpService (106.11.7) یکسان نیست → پیشنهاد استفاده از <code>IXHttpProvider</code> بهجای RestSharp مستقیم.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xStorageService</strong></td>
|
||
<td>۱۰ فایل / ۱,۴۴۸ خط</td>
|
||
<td><code>XStorageProvider</code> (partial)، <code>XThumbnailProvider</code> با Magick.NET، <code>XStorageHelper</code>، مدلهای XFileResult/XImageInfo</td>
|
||
<td>انتزاع فقط روی فایلسیستم فیزیکی (<code>FileProviders.Physical</code>)؛ برای S3/Blob نیاز به interface جدید است که با وجود <code>IXStorageProvider</code> آسان خواهد بود.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- ===================== بخش ۶ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۶</div>
|
||
<div class="section-title">
|
||
<h3>تحلیل ماژولهای دامنه</h3>
|
||
<div class="subtitle">Domain Services Analysis</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>هفت ماژول دامنه از الگوی Entity Service Blueprint پیروی میکنند. جدول زیر موجودیتها و اجزای اختصاصی هر ماژول را خلاصه میکند:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead><tr><th>ماژول</th><th>حجم</th><th>موجودیتها</th><th>اجزای اختصاصی و ارزیابی</th></tr></thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><strong>xTagService</strong></td>
|
||
<td>۵۱ فایل / ۴,۵۴۹ خط</td>
|
||
<td>XTag</td>
|
||
<td><code>XBaseTagProvider</code> (۸۹۳ خط)، <code>XBaseProvidedHasTag</code> (۶۷۴)، <code>XBaseTagProvided</code> (۳۶۰) – زیرساخت «قابل برچسبگذاری شدن» برای سایر موجودیتها (File، Content). کنترلرهای پایه در ۷ فایل. الگوی Mixin مبتنی بر وراثت؛ سلسلهمراتب عمیق ولی قابلاستفادهی مجدد.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xStringService</strong></td>
|
||
<td>۵۱ فایل / ۶,۳۳۵ خط</td>
|
||
<td>XString</td>
|
||
<td>منابع رشتهای چندزبانه؛ <code>IXResourceProvider</code>, <code>IXItemResourceProvider</code>, <code>IXOwnedItemResourceProvider</code>؛ ۷ کنترلر پایه. پایهی i18n در Category، TermsAndConditions، Content و AiModels. ساختار DI آن (XDIHelperExtension) الگوی مرجع سایر ماژولهاست.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xFileService</strong></td>
|
||
<td>۴۶ فایل / ۲,۹۷۴ خط</td>
|
||
<td>XFile</td>
|
||
<td><code>XFileProvider</code> (۹۱۷ خط) اتصال Storage + Tag + Repository؛ <code>XFileTagProvided/Provider</code>. ماژول پل بین زیرساخت ذخیرهسازی و دامنه.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xCategoryService</strong></td>
|
||
<td>۹۸ فایل / ۹,۰۹۸ خط</td>
|
||
<td>XCategory، XSubCategory</td>
|
||
<td>دو موجودیت کامل (×۲ Blueprint) + Resource Providerهای Title/Description + <code>XCategorySubCategoryReferenceProvider</code>؛ ۱۰ کنترلر. بزرگترین ماژول دامنه از نظر تعداد فایل، عمدتاً به دلیل تکرار Blueprint.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xContentService</strong></td>
|
||
<td>۵۱ فایل / ۲,۳۳۷ خط</td>
|
||
<td>XContent</td>
|
||
<td><code>XContentProvider</code> (۶۳۷ خط)، <code>XContentEnricher</code> (۱۵۸) – الگوی Enricher برای غنیسازی Dto با دادهی File/Tag/String. نمونهی خوب ترکیب سرویسها (Composite).</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xWebinarService</strong></td>
|
||
<td>۶۲ فایل / ۱,۷۲۵ خط</td>
|
||
<td>XWebinar، XWebinarSubscriber</td>
|
||
<td>دو Blueprint کامل بدون کنترلر؛ میانگین ۲۸ خط بهازای فایل، بیانگر اینکه منطق دامنه هنوز کم است و ماژول عمدتاً اسکلت است.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xTermsAndConditionsService</strong></td>
|
||
<td>۹ فایل / ۵۰۶ خط</td>
|
||
<td>— (بدون Entity)</td>
|
||
<td><code>XTermsAndConditionsProvider</code> + <code>XTermsHub</code> + یک Controller پایه. از XString برای متن استفاده میکند؛ تنها ماژول دامنه بدون Repository اختصاصی.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>xBotService</strong></td>
|
||
<td>۴۵ فایل / ۲,۸۲۴ خط</td>
|
||
<td>XBotUser</td>
|
||
<td><code>XBotProvider</code> (۴۶۲ خط) برای API پیامرسان بله (<code>XBaleBotEndpoints</code>)، <code>XBotBotUpdateRecieverBackgroundService</code> (long-polling)، <code>XBotModels</code> (۴۱۹ خط). وابستگی مستقیم به xHttpService/xDataService/xPushService. نامگذاری «Reciever» غلط املایی دارد.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="highlight-box">
|
||
<strong>هزینهی Blueprint:</strong> در ۸ ماژول دامنه و AI، حدود <strong>۱۳ موجودیت</strong> × ~۱۸ فایل اسکلتی = بیش از <strong>۲۳۰ فایل</strong> با میانگین ۱۵–۲۵ خط. این فایلها تقریباً یکساناند و کاندیدای اصلی تولید خودکار با Source Generator یا الگوی T4 هستند.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- ===================== بخش ۷ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۷</div>
|
||
<div class="section-title">
|
||
<h3>تحلیل ماژولهای هوش مصنوعی</h3>
|
||
<div class="subtitle">AI Modules Analysis (xAiModels & xAiService)</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<h4 style="color:var(--primary);margin:10px 0;">۷.۱ xAiModels — ۱۹۸ فایل / ۱۰,۹۳۸ خط (بزرگترین ماژول از نظر تعداد فایل)</h4>
|
||
<p class="no-indent">پنج موجودیت کامل با Blueprint: <code>XAiProject</code>، <code>XAiConversation</code>، <code>XAiMessage</code>، <code>XAiVector</code> و <code>XAiMcpServer</code> (۶۰ Interface، ۹۰ Provider). علاوه بر آن:</p>
|
||
<ul style="margin:10px 25px;">
|
||
<li>الگوی <strong>Enricher</strong> برای هر موجودیت (۵ Enricher) و <code>XAiDataProvider</code> + <code>XAiDataProviderHub</code> بهعنوان Facade لایهی دادهی AI.</li>
|
||
<li>مدلهای JSON-RPC برای MCP (<code>XAiMcpJsonRpcRequest/Response/Error</code>, <code>XAiMcpToolDefinition/Descriptor</code>) و Attributeهای <code>XAiMcpTool</code>, <code>XAiMcpToolParam</code>, <code>XAiMcpToolType</code> برای declarative tool definition.</li>
|
||
<li><code>VectorHelper</code> و <code>XAiVectorSearchResult</code> برای جستجوی برداری (RAG)؛ ثابتهای <code>XAiKnowledgeScope</code>, <code>XAiMcpServerUsageScope</code>, <code>XAiModelProviderType</code>, <code>XAiChatRole</code>.</li>
|
||
<li><code>XAiMcpSseReader</code> و <code>XAiMcpHeaderBuilder</code> برای ترابری SSE/HTTP.</li>
|
||
<li>پکیجها: <code>Microsoft.Extensions.AI 10.4.1</code>، <code>Microsoft.Extensions.AI.OpenAI 10.10.0</code>، <code>OpenAI 2.14.0</code>، <code>TimeZoneConverter</code>.</li>
|
||
</ul>
|
||
<div class="warning-box">
|
||
<strong>ناسازگاری نام:</strong> در این ماژول ماژولها هم «Models» و هم «Data Service» و هم «MCP Transport Helpers» را در بر گرفته است؛ عملاً یک ماژول چندمسئولیتی است. نام <code>xAiModels</code> با محتوای آن (Repository، GraphQL، Hub، SSE Reader) همخوانی ندارد. همچنین دو فایل با فاصلهی اضافی در نام (<code>XAiMcpServerEntityRegisterar .cs</code>، <code>XAiMcpServerEntityConfiguration .cs</code>) وجود دارد. اختلاف نسخهی <code>Microsoft.Extensions.AI</code> (10.4.1) و <code>.OpenAI</code> (10.10.0) میتواند هشدار binding ایجاد کند.
|
||
</div>
|
||
|
||
<h4 style="color:var(--primary);margin:10px 0;">۷.۲ xAiService — ۱۹ فایل / ۱,۷۰۳ خط</h4>
|
||
<p class="no-indent">پیادهسازی <strong>Model Context Protocol (MCP)</strong> بهصورت Pure C# و بدون SDK خارجی:</p>
|
||
<table class="styled-table">
|
||
<thead><tr><th>کلاس</th><th>نقش</th></tr></thead>
|
||
<tbody>
|
||
<tr><td><code>XAiMcpHandler : IXAiMcpHandler</code></td><td>Dispatcher متدهای JSON-RPC: <code>initialize</code>، <code>tools/list</code>، <code>tools/call</code> با اعمال <code>userInfo</code> (Authorization per-tool)</td></tr>
|
||
<tr><td><code>XAiMcpToolScanner</code> / <code>XAiMcpToolBlueprint</code></td><td>اسکن Reflection کلاسهای دارای <code>[XAiMcpTool]</code> و ساخت schema ابزارها</td></tr>
|
||
<tr><td><code>XAiMcpAIFunction : AIFunction</code></td><td>پل بین ابزار MCP و <code>Microsoft.Extensions.AI</code> (Function Calling)</td></tr>
|
||
<tr><td><code>XAiMcpClient : IAsyncDisposable</code> + <code>XAiMcpHttpTransport</code></td><td>کلاینت MCP با ترابری HTTP/SSE برای اتصال به سرورهای ثبتشده در <code>XAiMcpServer</code></td></tr>
|
||
<tr><td><code>XAiMcpSessionStore</code> + <code>XAiMcpSessionCleanupService</code></td><td>مدیریت session در حافظه با پاکسازی زمانبندیشده (BackgroundService)</td></tr>
|
||
<tr><td><code>XAiMcpControllerBase</code></td><td>Endpoint پایهی MCP Server روی ASP.NET Core</td></tr>
|
||
<tr><td><code>XAiMcpArgumentHelper</code> / <code>XAiMcpResultExtractionHelper</code></td><td>تبدیل آرگومانها و استخراج نتیجهی tool call</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="success-box">
|
||
<strong>نقطه قوت:</strong> پیادهسازی سبک و شفاف MCP (هم Server و هم Client) با یکپارچگی مستقیم با <code>Microsoft.Extensions.AI</code>؛ مدل مجوز per-tool مبتنی بر <code>IXAiMcpUserContext</code> طراحی امنیتی مناسبی است. <strong>ریسک:</strong> SessionStore در حافظه برای deployment افقی مناسب نیست؛ هدفگیری <code>netstandard2.0</code> با پکیجهای <code>Microsoft.Extensions.AI 10.x</code> باید از نظر سازگاری runtime در پروژههای مصرفکننده بررسی شود.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- ===================== بخش ۸ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۸</div>
|
||
<div class="section-title">
|
||
<h3>ارزیابی کیفی: نقاط قوت و ریسکها</h3>
|
||
<div class="subtitle">Strengths & Risks Assessment</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<div class="comparison-grid">
|
||
<div class="comparison-card recommended">
|
||
<span class="card-badge">STRENGTHS</span>
|
||
<h4>نقاط قوت معماری</h4>
|
||
<ul>
|
||
<li><span>یکنواختی ساختار</span><span class="value">هر ماژول: Constants/DI/Interfaces/Models/Providers</span></li>
|
||
<li><span>انتزاع ذخیرهگاه</span><span class="value">EF / Mongo / InMemory</span></li>
|
||
<li><span>انتزاع Broker</span><span class="value">Kafka / RabbitMQ / ZeroMQ</span></li>
|
||
<li><span>Realtime اول</span><span class="value">SignalR Hub + GraphQL Subscription</span></li>
|
||
<li><span>خطای یکپارچه</span><span class="value">enum XException</span></li>
|
||
<li><span>i18n داخلی</span><span class="value">XString Resource Providers</span></li>
|
||
<li><span>Observability</span><span class="value">OpenTelemetry + Writers</span></li>
|
||
<li><span>گراف وابستگی</span><span class="value">DAG بدون حلقه</span></li>
|
||
<li><span>مستندسازی</span><span class="value">XML Doc فعال در همهی ماژولها</span></li>
|
||
</ul>
|
||
</div>
|
||
<div class="comparison-card">
|
||
<h4>ریسکها و بدهی فنی</h4>
|
||
<ul>
|
||
<li><span>EF Core / ASP.NET</span><span class="value" style="color:var(--danger)">3.1 / 2.2 (EOL)</span></li>
|
||
<li><span>xCommons</span><span class="value" style="color:var(--danger)">۲۳ پکیج، فشرده و سنگین</span></li>
|
||
<li><span>XAccountControllerBase</span><span class="value" style="color:var(--danger)">۲,۷۹۹ خط</span></li>
|
||
<li><span>نسخههای ناهمگون</span><span class="value" style="color:var(--warning)">SignalR، RestSharp، Extensions.AI</span></li>
|
||
<li><span>پکیج preview</span><span class="value" style="color:var(--warning)">OAuth2Introspection</span></li>
|
||
<li><span>نشت EF به قرارداد</span><span class="value" style="color:var(--warning)">IIncludableQueryable</span></li>
|
||
<li><span>State در حافظه</span><span class="value" style="color:var(--warning)">Token / MCP Session</span></li>
|
||
<li><span>Boilerplate</span><span class="value" style="color:var(--warning)">۲۳۰+ فایل اسکلتی</span></li>
|
||
<li><span>تست واحد</span><span class="value" style="color:var(--danger)">پروژهی تست در Modules یافت نشد</span></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
<h4 style="color:var(--primary);margin:20px 0 10px;">ماتریس حجم و پیچیدگی</h4>
|
||
<table class="styled-table">
|
||
<thead><tr><th>ماژول</th><th>فایل</th><th>خط</th><th>میانگین خط/فایل</th><th>پیچیدگی</th></tr></thead>
|
||
<tbody>
|
||
<tr><td>xDataService</td><td>۷۰</td><td>۱۲,۲۲۷</td><td>۱۷۵</td><td style="color:var(--danger);font-weight:600">بالا</td></tr>
|
||
<tr><td>xIdentityService</td><td>۵۵</td><td>۱۱,۹۷۸</td><td>۲۱۸</td><td style="color:var(--danger);font-weight:600">بالا</td></tr>
|
||
<tr><td>xAiModels</td><td>۱۹۸</td><td>۱۰,۹۳۸</td><td>۵۵</td><td style="color:var(--warning);font-weight:600">متوسط (تکراری)</td></tr>
|
||
<tr><td>xCategoryService</td><td>۹۸</td><td>۹,۰۹۸</td><td>۹۳</td><td style="color:var(--warning);font-weight:600">متوسط</td></tr>
|
||
<tr><td>xCommons</td><td>۶۷</td><td>۷,۶۴۳</td><td>۱۱۴</td><td style="color:var(--warning);font-weight:600">متوسط</td></tr>
|
||
<tr><td>xStringService</td><td>۵۱</td><td>۶,۳۳۵</td><td>۱۲۴</td><td style="color:var(--warning);font-weight:600">متوسط</td></tr>
|
||
<tr><td>xPushService</td><td>۳۴</td><td>۵,۹۸۰</td><td>۱۷۶</td><td style="color:var(--warning);font-weight:600">متوسط</td></tr>
|
||
<tr><td>xTagService</td><td>۵۱</td><td>۴,۵۴۹</td><td>۸۹</td><td>متوسط</td></tr>
|
||
<tr><td>xIdentityHelper</td><td>۸</td><td>۳,۹۹۶</td><td>۵۰۰</td><td style="color:var(--danger);font-weight:600">بالا (تمرکز)</td></tr>
|
||
<tr><td>xIdentityModels</td><td>۶۰</td><td>۳,۶۸۷</td><td>۶۱</td><td>پایین</td></tr>
|
||
<tr><td>xFileService</td><td>۴۶</td><td>۲,۹۷۴</td><td>۶۵</td><td>پایین</td></tr>
|
||
<tr><td>xBotService</td><td>۴۵</td><td>۲,۸۲۴</td><td>۶۳</td><td>پایین</td></tr>
|
||
<tr><td>xContentService</td><td>۵۱</td><td>۲,۳۳۷</td><td>۴۶</td><td>پایین</td></tr>
|
||
<tr><td>xEventService</td><td>۲۶</td><td>۲,۱۶۲</td><td>۸۳</td><td>پایین</td></tr>
|
||
<tr><td>xWebinarService</td><td>۶۲</td><td>۱,۷۲۵</td><td>۲۸</td><td>پایین (اسکلت)</td></tr>
|
||
<tr><td>xAiService</td><td>۱۹</td><td>۱,۷۰۳</td><td>۹۰</td><td>متوسط</td></tr>
|
||
<tr><td>xStorageService</td><td>۱۰</td><td>۱,۴۴۸</td><td>۱۴۵</td><td>پایین</td></tr>
|
||
<tr><td>xModels</td><td>۳۳</td><td>۱,۳۶۶</td><td>۴۱</td><td>پایین</td></tr>
|
||
<tr><td>xLoggingService</td><td>۱۳</td><td>۱,۰۹۶</td><td>۸۴</td><td>پایین</td></tr>
|
||
<tr><td>xHttpService</td><td>۹</td><td>۷۳۵</td><td>۸۲</td><td>پایین</td></tr>
|
||
<tr><td>xMessageService</td><td>۱۳</td><td>۶۲۰</td><td>۴۸</td><td>پایین</td></tr>
|
||
<tr><td>xTermsAndConditionsService</td><td>۹</td><td>۵۰۶</td><td>۵۶</td><td>پایین</td></tr>
|
||
<tr><td>xExceptions</td><td>۳</td><td>۱۹۴</td><td>۶۵</td><td>پایین</td></tr>
|
||
<tr class="highlight-row"><td><strong>مجموع</strong></td><td>۱,۰۳۱</td><td>≈ ۹۶,۱۲۱</td><td>۹۳</td><td>—</td></tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- ===================== بخش ۹ ===================== -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۹</div>
|
||
<div class="section-title">
|
||
<h3>پیشنهادهای بهبود و نقشهی راه</h3>
|
||
<div class="subtitle">Recommendations & Roadmap</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<div class="timeline">
|
||
<div class="timeline-item">
|
||
<div class="timeline-dot"></div>
|
||
<div class="timeline-content">
|
||
<h5>فاز ۱ – ثبات (کوتاهمدت)</h5>
|
||
<p>همترازی نسخهی پکیجهای SignalR، RestSharp و Microsoft.Extensions.AI در یک <code>Directory.Packages.props</code> (Central Package Management)؛ رفع نام فایلهای دارای فاصله؛ جایگزینی پکیج preview OAuth2Introspection.</p>
|
||
</div>
|
||
</div>
|
||
<div class="timeline-item">
|
||
<div class="timeline-dot"></div>
|
||
<div class="timeline-content">
|
||
<h5>فاز ۲ – تفکیک xCommons</h5>
|
||
<p>شکستن xCommons به <code>xCommons.Core</code> (Extensions/Helpers بدون وابستگی وب)، <code>xCommons.AspNetCore</code> (Controllers، Swagger، RateLimit، Authorization) و <code>xCommons.Files</code> (PDF، FileTypeDetector). کاهش ردپای وابستگی ماژولهای مدل.</p>
|
||
</div>
|
||
</div>
|
||
<div class="timeline-item">
|
||
<div class="timeline-dot"></div>
|
||
<div class="timeline-content">
|
||
<h5>فاز ۳ – کاهش Boilerplate</h5>
|
||
<p>پیادهسازی یک <strong>Source Generator</strong> یا Roslyn Analyzer که از روی <code>[XEntity]</code> روی کلاس Entity، تمامی ۱۸ کلاس Blueprint (Repositoryها، Hubها، GraphQL، KeyGenerator، Seeder، Services) را تولید کند. حذف ۲۳۰+ فایل دستی.</p>
|
||
</div>
|
||
</div>
|
||
<div class="timeline-item">
|
||
<div class="timeline-dot"></div>
|
||
<div class="timeline-content">
|
||
<h5>فاز ۴ – معکوسسازی وابستگی Push ← Identity</h5>
|
||
<p>استخراج <code>IXHubUserResolver</code> در xPushService و پیادهسازی آن در xIdentityService؛ به این ترتیب xTagService/xStringService دیگر به Identity وابسته نمیشوند و گراف وابستگی کمعمقتر میشود.</p>
|
||
</div>
|
||
</div>
|
||
<div class="timeline-item">
|
||
<div class="timeline-dot"></div>
|
||
<div class="timeline-content">
|
||
<h5>فاز ۵ – ارتقای پلتفرم</h5>
|
||
<p>مهاجرت از <code>netstandard2.0</code> به multi-target (<code>netstandard2.0;net8.0</code>) و ارتقای EF Core به 8.x، GraphQL به 7.x، MongoDB.Driver به 2.2x+. پاکسازی نشت <code>IIncludableQueryable</code> از قرارداد Repository با یک <code>IXIncludeBuilder</code> انتزاعی.</p>
|
||
</div>
|
||
</div>
|
||
<div class="timeline-item">
|
||
<div class="timeline-dot"></div>
|
||
<div class="timeline-content">
|
||
<h5>فاز ۶ – مقیاسپذیری و تست</h5>
|
||
<p>انتقال <code>XInMemoryTokenProvider</code> و <code>XAiMcpSessionStore</code> به پشتوانهی توزیعشده (Redis / IDistributedCache)؛ افزودن Outbox به xEventService؛ ایجاد پروژههای تست واحد برای xDataService و xIdentityService با <code>XBaseInMemoryRepository</code>؛ تفکیک <code>XAccountControllerBase</code>.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="conclusion-box">
|
||
<h3>جمعبندی نهایی</h3>
|
||
<p>مجموعهی ۲۳ ماژول xSaherelm یک فریمورک بالغ، یکنواخت و با انتزاعهای قوی در لایهی داده، رویداد، Realtime و هویت است که اخیراً با زیرساخت MCP و Microsoft.Extensions.AI به حوزهی هوش مصنوعی گسترش یافته است.</p>
|
||
<p>بزرگترین ارزش معماری، «زبان مشترک Blueprint» است که سرعت افزودن موجودیت جدید را بالا میبرد؛ بزرگترین بدهی فنی، قدیمیبودن پایهی پلتفرم و تمرکز بیش از حد وابستگیها در xCommons و xIdentityService است.</p>
|
||
<div class="highlight">
|
||
<strong>اولویت پیشنهادی:</strong><br>
|
||
Central Package Management ← تفکیک xCommons ← Source Generator برای Blueprint ← ارتقای EF Core / .NET
|
||
</div>
|
||
</div>
|
||
|
||
<div class="info-box">
|
||
<strong>محدودیتهای این تحلیل:</strong> آمار بهصورت ایستا از سورس استخراج شده و رفتار runtime (کارایی، لاگها، پوشش تست) ارزیابی نشده است. ماژولهای <code>xServices</code> و <code>*Holder</code> خارج از محدودهی درخواستی بودند و بررسی نشدند.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="page-info">
|
||
این مستند برای استفادهی داخلی تیم توسعه xSaherelm تهیه شده و بر اساس وضعیت سورسکد در تاریخ ۱۴۰۵/۰۸/۲۳ است.
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<footer class="document-footer">
|
||
<div class="footer-brand">طراحی و توسعه: هادی خزاعی اصل</div>
|
||
<div class="footer-divider"></div>
|
||
<div>تاریخ تهیه: ۲۳ آبان ۱۴۰۵ | نسخه: ۱.۰ | طبقهبندی: داخلی / فنی</div>
|
||
</footer>
|
||
|
||
</div>
|
||
|
||
</body>
|
||
</html>
|