# ahmed4attya/markazak-saas architecture

> Architecture diagram of the GitHub repository ahmed4attya/markazak-saas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmed4attya/markazak-saas
- Repository: https://github.com/ahmed4attya/markazak-saas

## Overview

مركزك منصة SaaS متعددة المستأجرين لإدارة مركز تدريبي. يبدأ المسار المعتاد من واجهة RTL لإدارة الدورات والمجموعات وتسجيل الطلاب، ثم متابعة الحضور والتحصيل، وصولاً إلى التقارير والشهادات. واجهات API هي طبقة التشغيل التي تتحقق من الجلسة وتنفذ الاستعلامات أو التغييرات على PostgreSQL. أظهرت الملفات عينة من هذه المسارات، لا كل استدعاءات الواجهة؛ لذلك لا أفترض وصلات تفصيلية بين الصفحات وواجهات API غير المثبتة. مسارات Stripe والذكاء الاصطناعي موثقة جزئياً، لذا تظهر تكاملاتها منفصلة.

Main entry points: [`lib/db.ts`](https://github.com/ahmed4attya/markazak-saas/blob/main/lib/db.ts) (وصول البيانات), [`lib/auth.ts`](https://github.com/ahmed4attya/markazak-saas/blob/main/lib/auth.ts) (الجلسات والصلاحيات), [`app/api/enrollments/route.ts`](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/enrollments/route.ts) (تسجيل الطلاب), [`app/api/invoices/route.ts`](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/invoices/route.ts) (الفواتير)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["واجهة المركز"]
  node_web["بوابة المركز<br/>[layout.tsx]"]
  node_dashboard["لوحة المعلومات<br/>[page.tsx]"]
end

subgraph group_operations["التشغيل التدريبي"]
  node_students["إدارة الطلاب<br/>[page.tsx]"]
  node_courses["إدارة الدورات<br/>[page.tsx]"]
  node_groups["المجموعات والقاعات<br/>[page.tsx]"]
  node_enrollments["تسجيل الطلاب<br/>[route.ts]"]
  node_attendance["متابعة الحضور<br/>[route.ts]"]
  node_teachers["إدارة المدربين<br/>[page.tsx]"]
  node_classrooms["إدارة القاعات<br/>[route.ts]"]
end

subgraph group_finance["المالية والشهادات"]
  node_invoices["الفواتير<br/>[route.ts]"]
  node_payments["المدفوعات<br/>[route.ts]"]
  node_financeui["واجهة المالية<br/>[page.tsx]"]
  node_stripe["دفع Stripe<br/>[route.ts]"]
  node_stripe_webhook["استقبال Stripe<br/>[route.ts]"]
  node_certificates["إصدار الشهادات<br/>[route.ts]"]
  node_verification["التحقق من الشهادات<br/>[route.ts]"]
end

subgraph group_insights["التقارير والإدارة"]
  node_reports["التقارير<br/>[route.ts]"]
  node_reportui["واجهة التقارير<br/>[page.tsx]"]
  node_ai["المساعد الذكي<br/>[route.ts]"]
  node_users["المستخدمون والصلاحيات<br/>[route.ts]"]
  node_settings["إعدادات المركز<br/>[route.ts]"]
end

subgraph group_platform["طبقة المنصة"]
  node_auth["الجلسات والصلاحيات<br/>[auth.ts]"]
  node_db_access["وصول البيانات<br/>[db.ts]"]
  node_audit["سجل التدقيق<br/>[audit.ts]"]
  node_postgres[("PostgreSQL")]
end

node_staff(("موظفو المركز"))
node_stripe_service["خدمة Stripe"]
node_ai_service["مزود ذكاء اصطناعي"]

node_staff -->|"يفتح"| node_web
node_web -->|"يعرض"| node_dashboard
node_enrollments -->|"يتحقق من التسجيل"| node_attendance
node_staff -->|"يدير"| node_students
node_staff -->|"يدير"| node_courses
node_staff -->|"ينظم"| node_groups
node_staff -->|"يدير"| node_teachers
node_groups -->|"يقرأ القاعات"| node_classrooms
node_attendance -->|"يتحقق من الجلسة"| node_auth
node_attendance -->|"يقرأ ويسجل"| node_db_access
node_enrollments -->|"يتحقق من الجلسة"| node_auth
node_enrollments -->|"يقرأ ويسجل"| node_db_access
node_invoices -->|"يتحقق من الجلسة"| node_auth
node_invoices -->|"يقرأ ويكتب"| node_db_access
node_invoices -->|"يسجل الإنشاء"| node_audit
node_payments -->|"يتحقق من الجلسة"| node_auth
node_payments -->|"ينفذ المعاملة"| node_db_access
node_payments -->|"يسجل الإنشاء"| node_audit
node_staff -->|"يراجع"| node_financeui
node_stripe -.->|"ينشئ جلسة دفع"| node_stripe_service
node_stripe_service -.->|"يرسل حدث"| node_stripe_webhook
node_certificates -->|"يتحقق من الجلسة"| node_auth
node_certificates -->|"يقرأ ويصدر"| node_db_access
node_verification -->|"يتحقق من الرمز"| node_db_access
node_staff -->|"يراجع"| node_reportui
node_reports -->|"يتحقق من الجلسة"| node_auth
node_reports -->|"يجمع المؤشرات"| node_db_access
node_ai -->|"يتحقق من الجلسة"| node_auth
node_ai -->|"يجمع السياق"| node_db_access
node_ai -.->|"يطلب إجابة"| node_ai_service
node_users -->|"يتحقق من الدور"| node_auth
node_users -->|"يقرأ ويكتب"| node_db_access
node_users -->|"يسجل التغييرات"| node_audit
node_settings -->|"يتحقق من الدور"| node_auth
node_settings -->|"يقرأ ويكتب"| node_db_access
node_db_access -->|"ينفذ الاستعلامات"| node_postgres

click node_web "https://github.com/ahmed4attya/markazak-saas/blob/main/app/layout.tsx"
click node_dashboard "https://github.com/ahmed4attya/markazak-saas/blob/main/app/dashboard/page.tsx"
click node_students "https://github.com/ahmed4attya/markazak-saas/blob/main/app/students/page.tsx"
click node_courses "https://github.com/ahmed4attya/markazak-saas/blob/main/app/courses/page.tsx"
click node_groups "https://github.com/ahmed4attya/markazak-saas/blob/main/app/groups/page.tsx"
click node_enrollments "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/enrollments/route.ts"
click node_attendance "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/attendance/route.ts"
click node_teachers "https://github.com/ahmed4attya/markazak-saas/blob/main/app/teachers/page.tsx"
click node_classrooms "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/classrooms/route.ts"
click node_invoices "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/invoices/route.ts"
click node_payments "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/payments/route.ts"
click node_financeui "https://github.com/ahmed4attya/markazak-saas/blob/main/app/finance/page.tsx"
click node_stripe "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/stripe/checkout/route.ts"
click node_stripe_webhook "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/stripe/webhook/route.ts"
click node_certificates "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/certificates/route.ts"
click node_verification "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/certificates/verify/route.ts"
click node_reports "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/reports/route.ts"
click node_reportui "https://github.com/ahmed4attya/markazak-saas/blob/main/app/reports/page.tsx"
click node_ai "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/ai/route.ts"
click node_users "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/users/route.ts"
click node_settings "https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/settings/route.ts"
click node_auth "https://github.com/ahmed4attya/markazak-saas/blob/main/lib/auth.ts"
click node_db_access "https://github.com/ahmed4attya/markazak-saas/blob/main/lib/db.ts"
click node_audit "https://github.com/ahmed4attya/markazak-saas/blob/main/lib/audit.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_dashboard toneBlue
class node_students,node_courses,node_groups,node_enrollments,node_attendance,node_teachers,node_classrooms toneAmber
class node_invoices,node_payments,node_financeui,node_stripe,node_stripe_webhook,node_certificates,node_verification toneMint
class node_reports,node_reportui,node_ai,node_users,node_settings toneRose
class node_auth,node_db_access,node_audit,node_postgres,node_staff,node_stripe_service,node_ai_service toneIndigo
```

## Components

### واجهة المركز

- [بوابة المركز](https://github.com/ahmed4attya/markazak-saas/blob/main/app/layout.tsx): `app/layout.tsx`
- [لوحة المعلومات](https://github.com/ahmed4attya/markazak-saas/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`

### التشغيل التدريبي

- [إدارة الطلاب](https://github.com/ahmed4attya/markazak-saas/blob/main/app/students/page.tsx): `app/students/page.tsx`
- [إدارة الدورات](https://github.com/ahmed4attya/markazak-saas/blob/main/app/courses/page.tsx): `app/courses/page.tsx`
- [المجموعات والقاعات](https://github.com/ahmed4attya/markazak-saas/blob/main/app/groups/page.tsx): `app/groups/page.tsx`
- [تسجيل الطلاب](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/enrollments/route.ts): `app/api/enrollments/route.ts`
- [متابعة الحضور](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/attendance/route.ts): `app/api/attendance/route.ts`
- [إدارة المدربين](https://github.com/ahmed4attya/markazak-saas/blob/main/app/teachers/page.tsx): `app/teachers/page.tsx`
- [إدارة القاعات](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/classrooms/route.ts): `app/api/classrooms/route.ts`

### المالية والشهادات

- [الفواتير](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/invoices/route.ts): `app/api/invoices/route.ts`
- [المدفوعات](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/payments/route.ts): `app/api/payments/route.ts`
- [واجهة المالية](https://github.com/ahmed4attya/markazak-saas/blob/main/app/finance/page.tsx): `app/finance/page.tsx`
- [دفع Stripe](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/stripe/checkout/route.ts): `app/api/stripe/checkout/route.ts`
- [استقبال Stripe](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/stripe/webhook/route.ts): `app/api/stripe/webhook/route.ts`
- [إصدار الشهادات](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/certificates/route.ts): `app/api/certificates/route.ts`
- [التحقق من الشهادات](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/certificates/verify/route.ts): `app/api/certificates/verify/route.ts`

### التقارير والإدارة

- [التقارير](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/reports/route.ts): `app/api/reports/route.ts`
- [واجهة التقارير](https://github.com/ahmed4attya/markazak-saas/blob/main/app/reports/page.tsx): `app/reports/page.tsx`
- [المساعد الذكي](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/ai/route.ts): `app/api/ai/route.ts`
- [المستخدمون والصلاحيات](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/users/route.ts): `app/api/users/route.ts`
- [إعدادات المركز](https://github.com/ahmed4attya/markazak-saas/blob/main/app/api/settings/route.ts): `app/api/settings/route.ts`

### طبقة المنصة

- [الجلسات والصلاحيات](https://github.com/ahmed4attya/markazak-saas/blob/main/lib/auth.ts): `lib/auth.ts`
- [وصول البيانات](https://github.com/ahmed4attya/markazak-saas/blob/main/lib/db.ts): `lib/db.ts`
- [سجل التدقيق](https://github.com/ahmed4attya/markazak-saas/blob/main/lib/audit.ts): `lib/audit.ts`
- **PostgreSQL**

### Other components

- **موظفو المركز**
- **خدمة Stripe**
- **مزود ذكاء اصطناعي**

## Connections

- موظفو المركز → بوابة المركز: يفتح
- بوابة المركز → لوحة المعلومات: يعرض
- تسجيل الطلاب → متابعة الحضور: يتحقق من التسجيل
- موظفو المركز → إدارة الطلاب: يدير
- موظفو المركز → إدارة الدورات: يدير
- موظفو المركز → المجموعات والقاعات: ينظم
- موظفو المركز → إدارة المدربين: يدير
- المجموعات والقاعات → إدارة القاعات: يقرأ القاعات
- متابعة الحضور → الجلسات والصلاحيات: يتحقق من الجلسة
- متابعة الحضور → وصول البيانات: يقرأ ويسجل
- تسجيل الطلاب → الجلسات والصلاحيات: يتحقق من الجلسة
- تسجيل الطلاب → وصول البيانات: يقرأ ويسجل
- الفواتير → الجلسات والصلاحيات: يتحقق من الجلسة
- الفواتير → وصول البيانات: يقرأ ويكتب
- الفواتير → سجل التدقيق: يسجل الإنشاء
- المدفوعات → الجلسات والصلاحيات: يتحقق من الجلسة
- المدفوعات → وصول البيانات: ينفذ المعاملة
- المدفوعات → سجل التدقيق: يسجل الإنشاء
- موظفو المركز → واجهة المالية: يراجع
- دفع Stripe → خدمة Stripe: ينشئ جلسة دفع
- خدمة Stripe → استقبال Stripe: يرسل حدث
- إصدار الشهادات → الجلسات والصلاحيات: يتحقق من الجلسة
- إصدار الشهادات → وصول البيانات: يقرأ ويصدر
- التحقق من الشهادات → وصول البيانات: يتحقق من الرمز
- موظفو المركز → واجهة التقارير: يراجع
- التقارير → الجلسات والصلاحيات: يتحقق من الجلسة
- التقارير → وصول البيانات: يجمع المؤشرات
- المساعد الذكي → الجلسات والصلاحيات: يتحقق من الجلسة
- المساعد الذكي → وصول البيانات: يجمع السياق
- المساعد الذكي → مزود ذكاء اصطناعي: يطلب إجابة
- المستخدمون والصلاحيات → الجلسات والصلاحيات: يتحقق من الدور
- المستخدمون والصلاحيات → وصول البيانات: يقرأ ويكتب
- المستخدمون والصلاحيات → سجل التدقيق: يسجل التغييرات
- إعدادات المركز → الجلسات والصلاحيات: يتحقق من الدور
- إعدادات المركز → وصول البيانات: يقرأ ويكتب
- وصول البيانات → PostgreSQL: ينفذ الاستعلامات
