خريطة معمارية للمطورين والوكلاء. للتثبيت: README.md. للتعليمات: AGENTS.md.
flowchart TB
Dashboard[Dashboard UI] --> Actions[Server Actions]
Bot[WhatsApp Bot] --> BotAPI[Bot API]
Actions --> Prisma[(PostgreSQL)]
BotAPI --> Prisma
Actions --> Meili[(Meilisearch)]
| المسار | الغرض |
|---|---|
app/(dashboard)/ |
لوحة التحكم (محمية بـ middleware JWT) |
app/login/ |
تسجيل الدخول |
app/api/v1/bot/ |
Bot API (x-api-key) |
app/api/v1/dashboard/ |
Dashboard API (JWT cookie) |
app/api/v1/bot/orders/ |
Orders API للبوت (x-api-key) — مصدر واحد |
app/invoice/[id]/ |
فاتورة عامة (بدون auth) |
lib/actions/ |
منطق الأعمال |
لا نظام أدوار — أي مستخدم مسجّل = صلاحيات كاملة.
| الطبقة | الآلية |
|---|---|
| Dashboard pages | middleware.ts → JWT cookie |
| Server Actions | requireAuth() |
| Dashboard API | requireDashboardAuth() |
| Bot API | validateApiKey() |
استثناءات عامة: getStoreSettings(), getOrderById(), getDefaultCurrency() (فاتورة + login).
ProductPrice: unique على(productId, priceLabelId, currencyId, unitId)Customer.priceLabelIdيحدد تسعيرة البوت- راجع skill
nawaat-pricing
- Snapshot إلزامي في
OrderItemعند الإنشاء resolveItemPrice()للعرض — لا تعدّل snapshot لاحقاً- راجع skill
nawaat-orders
- resilient — لا تعطّل التطبيق
- راجع skill
nawaat-meilisearch
| المجال | الملفات الرئيسية |
|---|---|
| Inventory | lib/actions/inventory/, lib/config/product-code.config.ts |
| Pricing | lib/actions/inventory/price.actions.ts, lib/actions/price-labels.ts |
| Orders | lib/orders/service.ts, lib/actions/orders.ts, lib/order-utils.ts |
| Customers | lib/actions/customers.ts |
| Search | lib/meilisearch.ts, lib/utils/meilisearch-sync.ts |
مصدر الحقيقة: prisma/schema.prisma
بعد التغيير: npm run db:migrate + npm run db:generate + حدّث lib/prisma-includes.ts و lib/types/.