> For the complete documentation index, see [llms.txt](https://docs.automaktab.uz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.automaktab.uz/toliq-funksional-xarita/mindmap.md).

# Mind Map — Barcha Imkoniyatlar

```
                        ┌─────────────────────────────────────────────┐
                        │             AutoDrive CRM                   │
                        │       Barcha funksiyalar xaritasi           │
                        └─────────────────────────────────────────────┘
                                         │
          ┌───────────────┬───────────────┼───────────────┬───────────────┐
          │               │               │               │               │
      Kirish          Boshqaruv       Operativ        Hisobot        Integratsiya
     (Auth)         (Dashboard)      (CRUD)         (Analytics)     (Telegram)
```

***

## 1. KIRISH / AUTHENTIKATSIYA

### 1.1 Tizimga Kirish

```
Login Page → POST /auth/login → JWT token → httpOnly Cookie + Bearer
              │
              ├── Username: email
              ├── Password: kamida 8 belgi
              ├── Demo login: demo@automaktab.uz / demo1234
              ├── Xatolik: 429 (rate limit), 403 (inactive company)
              ├── Sessiya eskirgan bo'lsa → logout + clear cache
              └── Muvaffaqiyatli → dashboardga yo'naltirish
```

**\~> Kirish formasi** — email/password validation, yuklanayotgan state **\~> Sessiya tiklash** — `GET /auth/me` har bir ProtectedRoute mountida **\~> Majburiy parol o'zgartirish** — `must_change_password` → `/profile` ga redirect

### 1.2 Profil Boshqaruvi

```
Profile Page
 ├── Shaxsiy ma'lumotlar: ism, telefon (+998 format), email (read-only)
 ├── Parol o'zgartirish: current → new (8+ belgi, katta harf + raqam)
 ├── Telegram integratsiyasi
 │    ├── Ulanish holatini tekshirish: GET /telegram/link-status
 │    ├── Ulanish: POST /telegram/link-token → deep_link → botga yuborish
 │    ├── Uzish: DELETE /telegram/link
 │    └── Kundalik hisobot: PATCH /telegram/daily-report (owner/manager)
 ├── Profilni tahrirlash: faqat owner/manager/dev
 ├── Rol badge: "Biznes egasi" / "Filial menejeri"
 └── Branch badge: foydalanuvchi branchi
```

### 1.3 Tizimdan Chiqish

```
Logout → POST /auth/logout → queryClient.clear() → navigate(/login)
         └── 401 interceptor: barcha 401 xatoliklarni ushlaydi
              (login va auth/me dan tashqari)
```

### 1.4 Global Qidiruv

```
Cmd+K / Ctrl+K → Command Palette
 ├── Navigatsiya: barcha sahifalar (capability-gated)
 ├── Talabalar qidiruvi: GET /search?q= (min 2 belgi)
 ├── Guruhlar qidiruvi
 ├── Xodimlar qidiruvi
 └── Debounced search (300ms)
```

### 1.5 Routing va Guardlar

```
Public routes:    /login, /, /blog, /blog/:slug
Protected routes: barcha boshqa sahifalar (→ /login agar auth bo'lmasa)
                   ├── ProtectedRoute: auth tekshiruvi + session restore
                   ├── OwnerRoute: role === 'owner' || 'dev'
                   └── BranchAccessRoute: manageStaff capability
```

***

## 2. BOSHQARUV PANELLARI / DASHBOARDS

### 2.1 Owner Dashboard (Company Revenue)

```
/ → CompanyRevenueDashboard
 ├── Live caption: vaqt, timezone, sana (uzbek static month table)
 ├── Time-based greeting: "Xayrli tong/kun/kech" + ism
 ├── Quick actions: Add Payment, Add Student, Take Attendance
 ├── Period pills: today / week / month
 ├── Filter bar:
 │    ├── Sana oralig'i (presets + manual)
 │    ├── Branch (cross-tenant)
 │    ├── Course type (tezkor/avto_maktab)
 │    ├── Granularity (day/week)
 │    └── Refresh button
 ├── KPI tiles (4):
 │    ├── Bugungi daromad (primary gradient, count-up animatsiya)
 │    ├── Davr daromadi (sparkline bilan)
 │    ├── Qarzdorlik
 │    └── Davomat foizi
 ├── Revenue trend AreaChart (last-point dot accent, expandable table)
 ├── Recovery queue / Debtors list (priority dots: danger/warning/success)
 ├── Branch performance table (sortable: revenue, students, debt, rate)
 └── Payment status SVG donut (paid/partial/debt + coverage rate)
```

### 2.2 Legacy Dashboard (feature flag)

```
/ → LegacyMainDashboard (agar company_dashboard_v2 === false)
 ├── Course type Tabs (all/tezkor/avto_maktab)
 ├── Branch filter (owner/dev only)
 ├── 4 KPI cards: today revenue, active students, debt, graduates
 │    └── Har bir KPIda sparkline
 ├── Revenue trend AreaChart (Recharts)
 ├── Course mix PieChart (center label bilan)
 ├── Top 5 branches BarChart (horizontal) yoki plain list
 ├── Recent payments list (relative time)
 ├── Pulse activity log (audit, viewAudit role-gated)
 └── Branch comparison grouped bar chart (owner only)
```

### 2.3 Teacher Dashboard

```
/ → TeacherDashboard
 ├── Faol guruhlar soni
 ├── Jami talabalar soni
 ├── Imtihon natijalari (passed/failed/studying)
 └── Result horizontal bar chart
```

***

## 3. OPERATIV BOSHQARUV (CRUD)

### 3.1 Talabalar

#### 3.1.1 Ro'yxat

```
/students → StudentsPage
 ├── Course type Tabs (tezkor/avto_maktab) — URL-persisted
 ├── Branch filter (cross-tenant only)
 ├── Operator filter (owner/manager only)
 ├── Group membership filter (all/no_group/has_group)
 ├── Date range filter (Calendar popover, range mode)
 ├── Search (debounced 300ms, server-side)
 ├── Server-side pagination (50/page)
 ├── Client-side sort (toggle direction)
 ├── Desktop DataTable:
 │    ├── Tezkor: debt, group, result
 │    ├── Avto_maktab: initial_payment, second_payment, third_payment,
 │    │                 debt, group, completion_date, o83, contract_number, result
 │    └── Common: created_at, actions (edit/delete)
 ├── Mobile DataCard list (md:hidden)
 ├── Excel export (fetchAllStudents → xlsx → download)
 └── Fetching overlay spinner (backdrop-blur)
```

#### 3.1.2 Yaratish

```
Ikkita rejim:

1) Quick modal (StudentModal, ~1150 lines)
   ├── Fields: ism, familiya, telefon (+998), kurs turi, narx,
   │           boshlang'ich to'lov, to'lov usuli, guruh, filial, operator, izoh
   ├── Duplicate detection: bir xil ism/telefon tekshirish → ogohlantirish
   ├── Course auto-select: 1 ta active kurs bo'lsa, narx auto-filled
   ├── Save & add another: ketma-ket tez kiritish
   └── Edit mode: 5 tab (info, payments, exams, attendance, group history)

2) Detailed wizard (AddStudentDialog, ~1233 lines)
   ├── 3-step wizard:
   │    Step 1: Shaxsiy ma'lumotlar (ism, telefon, passport, tug'ilgan sana, jins, manzil)
   │    Step 2: Kurs & Branch (branch, course, group, lead source, referral)
   │    Step 3: To'lov (payment type, amount, method, date, contract agreement)
   ├── Step validation: har bir step mustaqil validate qilinadi
   ├── Completion date: auto-computed from course duration_days + start_date
   ├── Lead source: 7 options + "other" custom text
   ├── Referral: student or staff referrer (combobox/search)
   └── Contract signed: majburiy checkbox (refine validation)
```

#### 3.1.3 Tafsilot

```
/students/:id → StudentDetailPage
 ├── 5 tabs:
 │    ├── Ma'lumot: 12 field (phone, branch, group, course, price, debt, etc.)
 │    ├── To'lovlar: ledger table, add/edit/delete payment modals
 │    ├── Imtihonlar: StudentExamsTab (RecordExamModal)
 │    ├── Davomat: attendance history table
 │    └── Guruh tarixi: audit log filtering (owner/manager/dev only)
 ├── Header: ism, telefon, branch, group, debt badge, course type badge
 ├── Edit modal (StudentModal)
 ├── Deep-link: ?tab=payments → direct to payments tab
 └── Referrals count → filtered students page
```

#### 3.1.4 O'chirish

```
ConfirmDialog → DELETE /students/:id
 └── Invalidate: students + payments + dashboard query caches
```

### 3.2 To'lovlar

#### 3.2.1 Ro'yxat

```
/payments → PaymentsPage
 ├── Snapshot cards: today income, month income, total debt, debtor count
 ├── Filter bar:
 │    ├── Branch (cross-tenant)
 │    ├── Status (paid/unpaid/all)
 │    ├── Method (cash/card/all)
 │    ├── Course type
 │    ├── Date presets: today/week/month/lastMonth/all
 │    ├── Date range (Calendar)
 │    └── Search
 ├── Period summary cards (faqat filter active bo'lganda)
 ├── Sortable DataTable: index, student, branch, course type, total price,
 │                       amount paid, remaining debt (red/green), date, actions
 ├── Mobile DataCard list
 ├── Excel export (cross-tenant only, tooltip bilan)
 └── Inline edit/delete via embedded PaymentModal + ConfirmDialog
```

#### 3.2.2 Yaratish

```
PaymentModal (~525 lines)
 ├── Student search combobox (debounced 300ms)
 ├── Locked student mode (detail page dan)
 ├── Debt info card
 ├── Amount input (grouped digits, strip non-digits)
 ├── Payment method: naqd/karta/perechisleniya
 ├── Idempotency key: crypto.randomUUID() per modal open (duplicate prevention)
 ├── Over-debt confirmation: amount > debt → confirm dialog
 └── Edit mode: reconstructs pre-payment debt from remaining_debt + amount_paid
```

### 3.3 Guruhlar

#### 3.3.1 Ro'yxat

```
/groups → GroupsPage
 ├── Overview accordion: branches bo'yicha guruhlangan (default collapsed)
 ├── Filter bar: search, course type, branch (cross-tenant)
 ├── Sortable DataTable: name, branch, course type (colored badge), student count,
 │                       status, created_at, actions
 ├── Mobile DataCard list
 └── View transition → group detail
```

#### 3.3.2 Yaratish / Tahrirlash

```
GroupFormDialog
 ├── Fields: name, branch, course type
 ├── Duplicate name detection: same branch, case-insensitive
 ├── Cross-branch filtering
 └── Unsaved changes guard
```

#### 3.3.3 Tafsilot

```
/groups/:id → GroupDetailPage
 ├── 3 tabs:
 │    ├── Ma'lumot: teacher, course type, branch, student count
 │    ├── Talabalar: DataCard list, inline add/remove student
 │    └── Dars jadvali: template entries (day/time/type)
 └── Student info inline edit via StudentModal (disable price/payment fields)
```

### 3.4 Kurslar

```
/courses → CoursesPage
 ├── DataTable: name, branch, type (tezkor/avto_maktab), price, duration, status, actions
 ├── Mobile DataCard list
 ├── Create/Edit dialog: name, branch, type, price (grouped digits), duration (days)
 ├── Delete with confirm dialog
 ├── Unsaved changes guard
 └── Price input: groupDigits for display, strip non-digits on submit
```

### 3.5 Xodimlar (Staff)

#### 3.5.1 Menejerlar

```
/users → UsersPage (role="manager")
 ├── Search (debounced 300ms, server-side)
 ├── Branch filter (cross-tenant only)
 ├── Active/Inactive status filter
 ├── Server-side pagination (100/page)
 ├── DataTable: name, email, phone, branch, created_at
 ├── PersonModal create: fullName, email, password, phone, branchId
 └── Delete with confirm dialog
```

#### 3.5.2 O'qituvchilar

```
/teachers → TeachersPage
 ├── Search (debounced 300ms)
 ├── Server-side pagination (100/page)
 ├── DataTable: name, phone, specialization (theory/practice), branch,
 │              lesson_count, student_count, status
 ├── PersonModal create/edit: fullName, phone, specialization, branchId
 └── Delete with confirm dialog
```

#### 3.5.3 Operatorlar

```
/operators → OperatorsPage
 ├── Search (debounced 300ms)
 ├── Server-side pagination (100/page)
 ├── DataTable: name, phone, branch, registered_count, follow_through_rate, status
 ├── PersonModal create/edit: fullName, phone, branchId
 └── Delete with confirm dialog
```

### 3.6 Filiallar

```
/branches → BranchesPage
 ├── 2-column card grid: name, location, phone, manager, active students
 ├── Mobile DataCard list
 ├── Create/Edit dialog: name (required), location (required), phone (+998 format)
 ├── Delete with confirm dialog
 ├── Unsaved changes guard
 └── Role gate: manageBranches

/branches/:id → BranchDetailPage
 ├── Header: name, location, phone, manager
 ├── Analytics: active students (link), revenue, debt, today's payment
 ├── Revenue trend AreaChart
 └── Top debtors list → student detail
```

### 3.7 Davomat

#### 3.7.1 Darslar ro'yxati

```
/attendance → AttendancePage
 ├── Lesson card grid: date, title, type dot (theory=amber/practice=blue), group, teacher
 ├── Create lesson dialog (react-hook-form + zod)
 ├── Delete lesson with confirm dialog
 ├── Pagination (50/page)
 └── AttendanceDrawer integration
```

#### 3.7.2 AttendanceDrawer

```
Slide-in sheet (AttendanceDrawer)
 ├── Lesson info: date, group, lesson type
 ├── Student roster: status toggles
 │    ├── ✅ Kelgan (yashil)
 │    ├── ❌ Kelmagan (qizil)
 │    ├── ⏰ Kechikkan (sariq)
 │    └── 📝 Uzrli (ko'k)
 ├── Status cards row: summary per status
 ├── Batch save → POST /attendance/batch
 └── Unsaved changes guard
```

#### 3.7.3 Dars Jadvali

```
/schedule → SchedulePage
 ├── Tab 1: Calendar view
 │    ├── Week navigation (prev/next/today, Monday start)
 │    ├── 7-column calendar grid
 │    ├── Lesson cards: time, group, teacher, type chip, status
 │    └── Click lesson → AttendanceDrawer
 ├── Tab 2: Templates
 │    ├── List: group, day, time, type
 │    ├── Create dialog: group, day of week, start/end, type
 │    ├── Delete with confirm
 │    └── Generate lessons: weeks range (1-12), optional group filter
 └── Attendance marking via AttendanceDrawer
```

### 3.8 Imtihonlar

```
RecordExamModal (~226 lines)
 ├── Exam type: THEORY / PRACTICE
 ├── Result: passed (checkbox) / failed
 ├── Score: 0-100, optional
 ├── Date: default = today (UTC+5)
 ├── Notes: optional
 └── Self-contained mutation (useCreateExam)

StudentExamsTab (embedded in StudentModal)
 ├── Table: date, type, result, score, notes
 ├── Loading/empty/data states
 └── "Add exam" → RecordExamModal
```

### 3.9 Audit Jurnali

```
/audit → AuditLogPage
 ├── Filter bar:
 │    ├── Entity: all/student/payment/user/branch/group
 │    ├── Action: all/CREATE/UPDATE/DELETE
 │    ├── Date presets: today/week/month/lastMonth/all
 │    ├── Date range calendar
 │    └── User search (server-side → resolves to userId)
 ├── DataTable: user, role, action (colored), entity, details, time
 ├── Mobile DataCard list
 ├── Pagination (50/page)
 └── Smart user search: 1 match → filter; 0 or 2+ → sentinel __no_match__

/audit/:id → AuditDetailPage
 ├── Header: action badge (colored), entity, user, date
 ├── Info tab: user, role, action, entity, entity_id (linked), time
 ├── Changes tab:
 │    ├── UPDATE → before/after diff table (nested + flat)
 │    └── CREATE/DELETE → full dump
 └── Optimistic pre-fill from router state
```

***

## 4. UMUMIY / CROSS-CUTTING

### 4.1 Rol va Huquqlar Matritsasi

```
dev       → ALL (superset)
owner     → viewAllBranches, manageBranches, assignBranch, manageStaff,
            manageUsers, viewAudit
manager   → manageStaff, recordPayment, manageStudents, manageGroups,
            manageSchedule, takeAttendance
operator  → recordPayment, manageStudents, manageGroups,
            manageSchedule, takeAttendance
teacher   → takeAttendance, viewDashboard
```

### 4.2 Tenant Scoping

```
Platform (dev) → Company (owner) → Branch (manager/operator/teacher)
 ├── branch_id: auth store dagi user.branch_id (JWT)
 ├── isCrossTenant: role === 'owner' || 'dev' → barcha branchlarni ko'radi
 ├── useCan('capability'): hook-based tekshirish
 └── RoleGate component: UI elementlarni yashirish/ko'rsatish
```

### 4.3 Interfeys Elementlari

```
AppLayout
 ├── Sidebar (desktop: 82px rail, mobile: Sheet)
 │    └── Nav items: Dashboard, Branches, Schedule, Attendance, Groups,
 │                   Courses, Students, Payments, Operators, Teachers,
 │                   Users, Audit, Profile (capability-gated)
 ├── Topbar
 │    ├── Mobile hamburger menu
 │    ├── Branch label ("Barcha filiallar" / branch_name)
 │    ├── Search button (Cmd+K)
 │    ├── Theme toggle (dark/light)
 │    ├── Language switcher (uz/ru/en)
 │    └── Quick payment button (+)
 ├── Breadcrumbs (URL-based, dynamic)
 └── CommandPalette (Cmd+K global)
```

### 4.4 Data Display Pattern

```
Barcha list sahifalar:
 ├── Desktop: DataTable<T> (generic, sortable, striped)
 │    ├── Loading: skeleton rows
 │    ├── Error: error state (retry)
 │    ├── Empty: empty state (icon + message)
 │    └── Normal: striped rows
 ├── Mobile: DataCard list (fields grid)
 └── Pagination: PaginationControls (numbered + ellipsis)
```

### 4.5 Ma'lumotlar Caching (TanStack Query)

```
Pattern:
 ├── Query keys: factory pattern (baseKeys → all/list/page/detail)
 ├── Stale time: default 30s; org data (branches, teachers) = 5 min
 ├── Mutations invalidate: mostly keys.all (broad)
 ├── Cross-domain: Student ↔ Payment ↔ Dashboard
 └── Search: min 2 chars, no cache (pragmatic)
```

### 4.6 Xatolik Patternlari

```
 ├── 401 Interceptor: global axios response → logout (skip login/auth/me)
 ├── API errors: extractErrorMessage() → toast
 ├── Form validation: react-hook-form + zod (client-side)
 ├── Duplicate detection: student name/phone, group name
 ├── Rate limiting: 429 → max 1 retry
 └── Chunk load error → ChunkErrorBoundary → auto-reload (10s cooldown)
```

### 4.7 Tashkilot Ma'lumotlari (Org Data)

```
O'ZGARMAS/SEKIN O'ZGARADIGAN (staleTime: 5 min):
 ├── Branches
 ├── Teachers, Operators, Users (role lists)
 ├── Groups (list)
 └── Blog posts

TEZ O'ZGARADIGAN (staleTime: 30s default):
 ├── Students, Payments
 ├── Lessons, Attendance
 ├── Dashboard analytics
 └── Search results
```

***

## 5. UMUMIY SAHIFALAR (PUBLIC)

### 5.1 Landing Page

```
/ → LandingPage (~1900+ lines, 69KB)
 ├── GSAP animations: hero word-mask, parallax glow, floating mock
 ├── Stats count-up (scroll-triggered)
 ├── Staggered entrance: pain cards, benefit cards, features, FAQ
 ├── Theme toggle (dark/light)
 ├── Language switcher (uz/ru/en)
 ├── Blog teaser: latest 3 posts
 ├── FAQ accordion + JSON-LD (FAQPage schema)
 ├── Demo form (6 fields + GSAP success animation)
 ├── Dashboard mock (SVG: revenue sparkline, KPI cards, debtors)
 ├── Role cards: owner, manager, operator, teacher
 ├── Umami analytics tracking
 └── Auth check → auto-redirect to dashboard
```

### 5.2 Blog

```
/blog → BlogPage
 ├── Search (instant)
 ├── Tag filter (click toggle, X to remove)
 ├── 3-column card grid (2-col tablet, 1-col mobile)
 ├── Card: cover image (aspect-video, lazy, hover zoom), tags, title,
 │          excerpt (2-line clamp), reading time, views
 └── GSAP ScrollTrigger reveal

/blog/:slug → BlogPostPage
 ├── Cover image, tags, title, metadata
 ├── react-markdown + GFM + syntax highlighting (rehype-highlight)
 ├── Share menu: Web Share API / dropdown (copy link + Telegram)
 ├── Related posts (up to 3, matching tags)
 ├── Dynamic document title
 └── Vercel Edge middleware: SEO static HTML for crawlers
```

### 5.3 Demo So'rovi

```
DemoForm (~488 lines)
 ├── Fields: full_name, phone (+998), region, center_name, student_count, note
 ├── GSAP success animation: ring + checkmark draw
 ├── Rate limited (5/min)
 ├── prefers-reduced-motion support
 └── Umami tracking
```

***

## 6. TELEGRAM INTEGRATSIYASI

```
Foydalanuvchi darajasida:
 ├── Link status: GET /telegram/link-status
 ├── Link token: POST /telegram/link-token → deep_link
 ├── Unlink: DELETE /telegram/link
 └── Daily report: PATCH /telegram/daily-report (owner/manager)

Kompaniya darajasida:
 └── Telegram chat: PATCH /companies/me/telegram-chat

Bildirishnomalar:
 ├── Yangi talaba ro'yxatdan o'tganida
 ├── Yangi to'lov qilinganida
 └── Kundalik hisobot
```

***

## 7. XAVFSIZLIK

```
 ├── JWT authentication (httpOnly cookie + Bearer header)
 ├── Token version (password change → token version bump)
 ├── Role-based access control (dev/owner/manager/operator/teacher)
 ├── Capability-based gating (useCan hook)
 ├── Cross-tenant data isolation (branch_id scoping)
 ├── Idempotency key (payment duplicate prevention)
 ├── Rate limiting (429 handling)
 ├── Soft deletes (backend: deletedAt: null)
 ├── CORS (withCredentials)
 ├── Session restore on mount
 └── 401 auto-logout + cache clear
```

***

## 8. UMUMIY KOMPONENTLAR

| Komponent              | Foydalanish  | Muhim xususiyatlar                                                |
| ---------------------- | ------------ | ----------------------------------------------------------------- |
| **StudentModal**       | \~1150 lines | Talaba yaratish/tahrirlash, dual course type, duplicate detection |
| **AddStudentDialog**   | \~1233 lines | 3-step wizard, detailed student creation                          |
| **PaymentModal**       | \~525 lines  | To'lov yaratish, student combobox, idempotency, over-debt guard   |
| **PersonModal**        | \~445 lines  | Xodim yaratish (manager/operator/teacher)                         |
| **RecordExamModal**    | \~226 lines  | Imtihon natijasini qayd etish                                     |
| **AttendanceDrawer**   |              | Davomat paneli, status toggles, batch save                        |
| **ConfirmDialog**      | \~61 lines   | Delete/discard confirmation                                       |
| **DataTable**          | \~212 lines  | Generic sortable table (loading/error/empty)                      |
| **DataCard**           | \~95 lines   | Mobile card list                                                  |
| **PaginationControls** | \~81 lines   | Numbered pagination with ellipsis                                 |
| **EntityDetailShell**  | \~67 lines   | Detail page wrapper (loading/error/header)                        |
| **Sparkline**          | \~58 lines   | Mini area chart (4 tones)                                         |
| **SummaryCard**        | \~50 lines   | Dashboard KPI card                                                |
| **EmptyState**         | \~56 lines   | Empty/error state with action                                     |
| **CommandPalette**     | \~237 lines  | Global Cmd+K search                                               |
| **Sidebar**            | \~287 lines  | Navigation rail (role-gated)                                      |
| **Topbar**             | \~146 lines  | Top bar (theme, lang, search, quick payment)                      |
| **Breadcrumbs**        | \~96 lines   | URL-based breadcrumb                                              |
| **ReferralFields**     | \~256 lines  | Lead source + referrer selector                                   |
| **RoleGate**           | \~21 lines   | Capability-based conditional render                               |
| **DemoForm**           | \~488 lines  | Landing page demo request + GSAP animation                        |
| **BlogHeader**         | \~27 lines   | Blog navigation                                                   |
| **ChunkErrorBoundary** | \~54 lines   | Stale chunk recovery                                              |
| **OfflineBanner**      | \~30 lines   | Offline detection banner                                          |

***

## 9. BACKEND API Endpointlari (Frontend dan chaqiriladigan)

### Auth

| Endpoint              | Method | Service     | Mutation          |
| --------------------- | ------ | ----------- | ----------------- |
| /auth/login           | POST   | authService | useLogin          |
| /auth/me              | GET    | authService | useRestoreSession |
| /auth/change-password | POST   | authService | useChangePassword |
| /auth/logout          | POST   | authService | useLogout         |

### Talabalar

| Endpoint      | Method | Service        | Hook             |
| ------------- | ------ | -------------- | ---------------- |
| /students     | GET    | studentService | useStudentsPage  |
| /students/:id | GET    | studentService | useStudent       |
| /students     | POST   | studentService | useCreateStudent |
| /students/:id | PATCH  | studentService | useUpdateStudent |
| /students/:id | DELETE | studentService | useDeleteStudent |

### To'lovlar

| Endpoint           | Method | Service        | Hook               |
| ------------------ | ------ | -------------- | ------------------ |
| /payments          | GET    | paymentService | usePaymentsPage    |
| /payments/snapshot | GET    | paymentService | usePaymentSnapshot |
| /payments/summary  | GET    | paymentService | usePaymentSummary  |
| /payments          | POST   | paymentService | useCreatePayment   |
| /payments/:id      | PATCH  | paymentService | useUpdatePayment   |
| /payments/:id      | DELETE | paymentService | useDeletePayment   |

### Guruhlar, Kurslar, Filiallar

| Endpoint         | Method           | Service       | Hook                                      |
| ---------------- | ---------------- | ------------- | ----------------------------------------- |
| /groups          | GET/POST         | groupService  | useGroups/useCreateGroup                  |
| /groups/overview | GET              | groupService  | useGroupsOverview                         |
| /groups/:id      | GET/PATCH/DELETE | groupService  | useGroup/useUpdateGroup/useDeleteGroup    |
| /courses         | GET/POST         | courseService | useCourses/useCreateCourse                |
| /courses/:id     | GET/PATCH/DELETE | courseService | useCourse/useUpdateCourse/useDeleteCourse |
| /branches        | GET/POST         | branchService | useBranches/useCreateBranch               |
| /branches/:id    | GET/PATCH/DELETE | branchService | useBranch/useUpdateBranch/useDeleteBranch |

### Davomat va Jadval

| Endpoint            | Method          | Service           | Hook                                       |
| ------------------- | --------------- | ----------------- | ------------------------------------------ |
| /lessons            | GET/POST/DELETE | attendanceService | useLessons/useCreateLesson/useDeleteLesson |
| /lessons/:id        | GET             | attendanceService | useLessonById                              |
| /attendance         | GET             | attendanceService | useAttendanceHistory                       |
| /attendance/batch   | POST            | attendanceService | useBatchAttendance                         |
| /schedule/templates | GET/POST/DELETE | scheduleService   | useScheduleTemplates                       |
| /schedule/generate  | POST            | scheduleService   | useGenerateLessons                         |
| /schedule/calendar  | GET             | scheduleService   | useCalendarLessons                         |

### Foydalanuvchilar

| Endpoint   | Method    | Service                        | Hook                                   |
| ---------- | --------- | ------------------------------ | -------------------------------------- |
| /users     | GET/POST  | userService                    | useUsers/useUsersPage/useCreateManager |
| /users/:id | GET/PATCH | userService                    | useUser/useUpdateUser                  |
| /users/:id | DELETE    | teacherService/operatorService | useDeleteTeacher/useDeleteOperator     |

### Boshqa

| Endpoint                     | Method                | Service          | Hook                         |
| ---------------------------- | --------------------- | ---------------- | ---------------------------- |
| /dashboard/analytics         | GET                   | dashboardService | useDashboardAnalytics        |
| /dashboard/teacher-analytics | GET                   | dashboardService | useTeacherAnalytics          |
| /dashboard/company-overview  | GET                   | dashboardService | useCompanyOverview           |
| /exams/student/:studentId    | GET                   | examService      | useStudentExams              |
| /exams                       | POST                  | examService      | useCreateExam                |
| /audit-logs                  | GET/POST              | auditService     | useAuditLogs/useAuditLogById |
| /search?q=                   | GET                   | searchService    | useGlobalSearch              |
| /blog-posts                  | GET                   | blogService      | useBlogPosts                 |
| /blog-posts/:slug            | GET                   | blogService      | useBlogPost                  |
| /demo-requests               | POST                  | demoService      | useCreateDemoRequest         |
| /telegram/\*                 | GET/POST/DELETE/PATCH | telegramService  | useTelegram\*                |

***

## 10. TO'LIQ SAHIFA XARITASI (Routes)

| Path            | Component         | Guard             | Sidebar |
| --------------- | ----------------- | ----------------- | ------- |
| `/`             | LandingPage       | None              | No      |
| `/login`        | LoginPage         | None              | No      |
| `/blog`         | BlogPage          | None              | No      |
| `/blog/:slug`   | BlogPostPage      | None              | No      |
| `/dashboard`    | DashboardPage     | ProtectedRoute    | Yes     |
| `/students`     | StudentsPage      | ProtectedRoute    | Yes     |
| `/students/:id` | StudentDetailPage | ProtectedRoute    | Yes     |
| `/payments`     | PaymentsPage      | ProtectedRoute    | Yes     |
| `/groups`       | GroupsPage        | ProtectedRoute    | Yes     |
| `/groups/:id`   | GroupDetailPage   | ProtectedRoute    | Yes     |
| `/courses`      | CoursesPage       | BranchAccessRoute | Yes     |
| `/schedule`     | SchedulePage      | ProtectedRoute    | Yes     |
| `/attendance`   | AttendancePage    | ProtectedRoute    | Yes     |
| `/branches`     | BranchesPage      | OwnerRoute        | Yes     |
| `/branches/:id` | BranchDetailPage  | OwnerRoute        | Yes     |
| `/users`        | UsersPage         | OwnerRoute        | Yes     |
| `/users/:id`    | UserDetailPage    | BranchAccessRoute | Yes     |
| `/teachers`     | TeachersPage      | BranchAccessRoute | Yes     |
| `/operators`    | OperatorsPage     | BranchAccessRoute | Yes     |
| `/profile`      | ProfilePage       | ProtectedRoute    | Yes     |
| `/audit`        | AuditLogPage      | OwnerRoute        | Yes     |
| `/audit/:id`    | AuditDetailPage   | OwnerRoute        | Yes     |
| `/documents`    | DocumentsPage     | ProtectedRoute    | Yes     |
| `*`             | NotFound          | None              | No      |

***

## 11. MA'LUMOTLAR OQIMI (Data Flow)

```
User Action → Component → Service (TanStack Query)
                                    │
                          ┌─────────┴────────────┐
                          │                      │
                     useQuery                useMutation
                          │                      │
                  GET /api/...             POST/PATCH/DELETE
                          │                      │
                     parseListResponse      parseItemEnvelope
                          │                      │
                     React Query Cache     Invalidate keys
                          │                      │
                     Component re-render   Re-fetch queries
                          │                      │
                     UI update              UI update + toast
```

***

## 12. QO'SHIMCHA FUNKSIONALIKLAR

```
 ├── Theme: dark-mode-first, localStorage, matchMedia fallback, anti-FOUC
 ├── i18n: uz/ru/en, localStorage lang key, fallback uz
 ├── PWA: vite-plugin-pwa, auto-update, onNeedRefresh toast
 ├── Code splitting: manual chunks (react/query/ui/charts/i18n/blog/export)
 ├── View transitions: useViewTransitionNavigate (SPA animation)
 ├── Excel export: xlsx library, translated headers
 ├── URL persistence: barcha filtrlash URL search params da
 ├── Tashkent timezone: custom date helpers (static month table)
 ├── Umami analytics: event tracking (create/update/delete + custom)
 ├── Offline detection: OfflineBanner + navigator.onLine
 └── Skeleton loading: barcha sahifalarda loading states
```

***

*Ushbu hujjat AutoDrive CRM frontendining barcha funksional imkoniyatlarini o'z ichiga oladi. Har bir bo'lim alohida `docs/` faylida batafsil yoritilgan.*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.automaktab.uz/toliq-funksional-xarita/mindmap.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
