# abdelatifahmed/sanad architecture

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

- Interactive diagram: https://gitdiagram.com/abdelatifahmed/sanad
- Repository: https://github.com/abdelatifahmed/sanad

## Overview

Sanad is a web client connecting families who need care with professional companions. The principal journey is account creation, companion discovery, care-request or job-post creation, companion proposals, booking and payment, then ongoing coordination through schedules and chat. The client also provides AI search and care-plan assistance, support, notifications, profiles, and wallets. The graph reflects documented capabilities and shown imports/calls; unsampled page-level wiring is represented only by dashed, unverified links. Backend services are external to this repository.

Main entry points: [`lib/services/api.ts`](https://github.com/abdelatifahmed/sanad/blob/main/lib/services/api.ts) (API client), [`app/family/companions/ClientCompanionsView.tsx`](https://github.com/abdelatifahmed/sanad/blob/main/app/family/companions/ClientCompanionsView.tsx) (Companion discovery), [`app/(auth)/register/page.tsx`](https://github.com/abdelatifahmed/sanad/blob/main/app/(auth)/register/page.tsx) (Role registration), [`components/auth/ReviewStep.tsx`](https://github.com/abdelatifahmed/sanad/blob/main/components/auth/ReviewStep.tsx) (Registration submit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and identity"]
  node_landing["Landing page<br/>[page.tsx]"]
  node_registration["Role registration<br/>[page.tsx]"]
  node_registration_data["Registration state<br/>[registerStore.ts]"]
  node_registration_review["Registration submit<br/>[ReviewStep.tsx]"]
  node_auth_state["Auth state<br/>[authStore.ts]"]
  node_login["Login<br/>[page.tsx]"]
end

subgraph group_care["Care marketplace"]
  node_companion_discovery["Companion discovery"]
  node_companion_cards["Companion profiles<br/>[CaregiverCard.tsx]"]
  node_smart_search["AI smart search<br/>[SmartSearchBar.tsx]"]
  node_search_hook["Search request hook<br/>[useSmartSearch.ts]"]
  node_care_plan["Care plan assistant"]
  node_job_posts["Care requests<br/>[page.tsx]"]
  node_request_form["Direct care request"]
  node_proposals["Companion proposals<br/>[page.tsx]"]
end

subgraph group_engagement["Bookings and engagement"]
  node_bookings["Booking management<br/>[page.tsx]"]
  node_payments["Wallet and payments<br/>[page.tsx]"]
  node_schedules["Shift schedules<br/>[page.tsx]"]
  node_chat_ui["Chat experience<br/>[ChatContainer.tsx]"]
  node_chat_hook["Chat and messages<br/>[useChat.ts]"]
  node_support["Admin support<br/>[useAdminSupport.ts]"]
  node_notifications["Notifications"]
end

subgraph group_platform["Shared client services"]
  node_api_client["API client<br/>[api.ts]"]
  node_socket["Socket provider<br/>[SocketProvider.tsx]"]
  node_map["Interactive maps<br/>[LeafletMap.tsx]"]
end

node_visitor(("Family or companion"))
node_backend{{"Sanad API"}}
node_stripe{{"Stripe Elements"}}

node_visitor -->|"visits"| node_landing
node_visitor -.->|"registers"| node_registration
node_registration -->|"updates"| node_registration_data
node_registration -->|"renders"| node_registration_review
node_registration_review -.->|"registers account"| node_backend
node_registration_review -->|"sets session"| node_auth_state
node_visitor -.->|"signs in"| node_login
node_login -->|"uses API"| node_api_client
node_companion_discovery -->|"renders"| node_companion_cards
node_companion_discovery -->|"renders"| node_smart_search
node_smart_search -.->|"uses search"| node_search_hook
node_search_hook -->|"posts search"| node_api_client
node_api_client -->|"sends requests"| node_backend
node_visitor -.->|"browses care"| node_companion_discovery
node_visitor -.->|"creates request"| node_job_posts
node_job_posts -.->|"renders form"| node_request_form
node_job_posts -.->|"generates plan"| node_care_plan
node_visitor -.->|"applies to posts"| node_proposals
node_proposals -.->|"submits proposals"| node_backend
node_visitor -.->|"manages bookings"| node_bookings
node_bookings -.->|"pays for care"| node_payments
node_payments -.->|"processes payment"| node_stripe
node_visitor -.->|"coordinates shifts"| node_schedules
node_visitor -.->|"opens chat"| node_chat_ui
node_chat_ui -.->|"uses chat logic"| node_chat_hook
node_chat_hook -->|"loads and sends"| node_api_client
node_chat_hook -->|"receives realtime events"| node_socket
node_visitor -.->|"requests support"| node_support
node_support -.->|"loads and sends"| node_api_client
node_visitor -.->|"views updates"| node_notifications
node_map -.->|"shows locations"| node_companion_discovery
node_api_client -->|"reads and refreshes session"| node_auth_state

click node_landing "https://github.com/abdelatifahmed/sanad/blob/main/app/page.tsx"
click node_registration "https://github.com/abdelatifahmed/sanad/blob/main/app/(auth)/register/page.tsx"
click node_registration_data "https://github.com/abdelatifahmed/sanad/blob/main/store/registerStore.ts"
click node_registration_review "https://github.com/abdelatifahmed/sanad/blob/main/components/auth/ReviewStep.tsx"
click node_auth_state "https://github.com/abdelatifahmed/sanad/blob/main/store/authStore.ts"
click node_login "https://github.com/abdelatifahmed/sanad/blob/main/app/(auth)/login/page.tsx"
click node_companion_discovery "https://github.com/abdelatifahmed/sanad/blob/main/app/family/companions/ClientCompanionsView.tsx"
click node_companion_cards "https://github.com/abdelatifahmed/sanad/blob/main/components/companion/CaregiverCard.tsx"
click node_smart_search "https://github.com/abdelatifahmed/sanad/blob/main/components/ai/SmartSearchBar.tsx"
click node_search_hook "https://github.com/abdelatifahmed/sanad/blob/main/hooks/useSmartSearch.ts"
click node_care_plan "https://github.com/abdelatifahmed/sanad/blob/main/components/ai/CarePlanAssistant.tsx"
click node_job_posts "https://github.com/abdelatifahmed/sanad/blob/main/app/family/job-posts/new/page.tsx"
click node_request_form "https://github.com/abdelatifahmed/sanad/blob/main/components/care-request/DirectCareRequestForm.tsx"
click node_proposals "https://github.com/abdelatifahmed/sanad/blob/main/app/companion/requests/page.tsx"
click node_bookings "https://github.com/abdelatifahmed/sanad/blob/main/app/family/bookings/page.tsx"
click node_payments "https://github.com/abdelatifahmed/sanad/blob/main/app/family/wallet/page.tsx"
click node_schedules "https://github.com/abdelatifahmed/sanad/blob/main/app/companion/schedule/page.tsx"
click node_chat_ui "https://github.com/abdelatifahmed/sanad/blob/main/features/chat/components/ChatContainer.tsx"
click node_chat_hook "https://github.com/abdelatifahmed/sanad/blob/main/features/chat/hooks/useChat.ts"
click node_support "https://github.com/abdelatifahmed/sanad/blob/main/features/admin-support/hooks/useAdminSupport.ts"
click node_notifications "https://github.com/abdelatifahmed/sanad/blob/main/components/notifications/NotificationsDashboard.tsx"
click node_api_client "https://github.com/abdelatifahmed/sanad/blob/main/lib/services/api.ts"
click node_socket "https://github.com/abdelatifahmed/sanad/blob/main/components/providers/SocketProvider.tsx"
click node_map "https://github.com/abdelatifahmed/sanad/blob/main/components/shared/LeafletMap.tsx"

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_landing,node_registration,node_registration_data,node_registration_review,node_auth_state,node_login toneBlue
class node_companion_discovery,node_companion_cards,node_smart_search,node_search_hook,node_care_plan,node_job_posts,node_request_form,node_proposals toneAmber
class node_bookings,node_payments,node_schedules,node_chat_ui,node_chat_hook,node_support,node_notifications,node_backend toneMint
class node_api_client,node_socket,node_map toneRose
class node_visitor,node_stripe toneIndigo
```

## Components

### Entry and identity

- [Landing page](https://github.com/abdelatifahmed/sanad/blob/main/app/page.tsx): `app/page.tsx`
- [Role registration](https://github.com/abdelatifahmed/sanad/blob/main/app/(auth)/register/page.tsx): `app/(auth)/register/page.tsx`
- [Registration state](https://github.com/abdelatifahmed/sanad/blob/main/store/registerStore.ts): `store/registerStore.ts`
- [Registration submit](https://github.com/abdelatifahmed/sanad/blob/main/components/auth/ReviewStep.tsx): `components/auth/ReviewStep.tsx`
- [Auth state](https://github.com/abdelatifahmed/sanad/blob/main/store/authStore.ts): `store/authStore.ts`
- [Login](https://github.com/abdelatifahmed/sanad/blob/main/app/(auth)/login/page.tsx): `app/(auth)/login/page.tsx`

### Care marketplace

- [Companion discovery](https://github.com/abdelatifahmed/sanad/blob/main/app/family/companions/ClientCompanionsView.tsx): `app/family/companions/ClientCompanionsView.tsx`
- [Companion profiles](https://github.com/abdelatifahmed/sanad/blob/main/components/companion/CaregiverCard.tsx): `components/companion/CaregiverCard.tsx`
- [AI smart search](https://github.com/abdelatifahmed/sanad/blob/main/components/ai/SmartSearchBar.tsx): `components/ai/SmartSearchBar.tsx`
- [Search request hook](https://github.com/abdelatifahmed/sanad/blob/main/hooks/useSmartSearch.ts): `hooks/useSmartSearch.ts`
- [Care plan assistant](https://github.com/abdelatifahmed/sanad/blob/main/components/ai/CarePlanAssistant.tsx): `components/ai/CarePlanAssistant.tsx`
- [Care requests](https://github.com/abdelatifahmed/sanad/blob/main/app/family/job-posts/new/page.tsx): `app/family/job-posts/new/page.tsx`
- [Direct care request](https://github.com/abdelatifahmed/sanad/blob/main/components/care-request/DirectCareRequestForm.tsx): `components/care-request/DirectCareRequestForm.tsx`
- [Companion proposals](https://github.com/abdelatifahmed/sanad/blob/main/app/companion/requests/page.tsx): `app/companion/requests/page.tsx`

### Bookings and engagement

- [Booking management](https://github.com/abdelatifahmed/sanad/blob/main/app/family/bookings/page.tsx): `app/family/bookings/page.tsx`
- [Wallet and payments](https://github.com/abdelatifahmed/sanad/blob/main/app/family/wallet/page.tsx): `app/family/wallet/page.tsx`
- [Shift schedules](https://github.com/abdelatifahmed/sanad/blob/main/app/companion/schedule/page.tsx): `app/companion/schedule/page.tsx`
- [Chat experience](https://github.com/abdelatifahmed/sanad/blob/main/features/chat/components/ChatContainer.tsx): `features/chat/components/ChatContainer.tsx`
- [Chat and messages](https://github.com/abdelatifahmed/sanad/blob/main/features/chat/hooks/useChat.ts): `features/chat/hooks/useChat.ts`
- [Admin support](https://github.com/abdelatifahmed/sanad/blob/main/features/admin-support/hooks/useAdminSupport.ts): `features/admin-support/hooks/useAdminSupport.ts`
- [Notifications](https://github.com/abdelatifahmed/sanad/blob/main/components/notifications/NotificationsDashboard.tsx): `components/notifications/NotificationsDashboard.tsx`

### Shared client services

- [API client](https://github.com/abdelatifahmed/sanad/blob/main/lib/services/api.ts): `lib/services/api.ts`
- [Socket provider](https://github.com/abdelatifahmed/sanad/blob/main/components/providers/SocketProvider.tsx): `components/providers/SocketProvider.tsx`
- [Interactive maps](https://github.com/abdelatifahmed/sanad/blob/main/components/shared/LeafletMap.tsx): `components/shared/LeafletMap.tsx`

### Other components

- **Family or companion**
- **Sanad API**
- **Stripe Elements**

## Connections

- Family or companion → Landing page: visits (evidence: `app/page.tsx`)
- Family or companion → Role registration: registers
- Role registration → Registration state: updates (evidence: `app/(auth)/register/page.tsx`)
- Role registration → Registration submit: renders (evidence: `app/(auth)/register/page.tsx`)
- Registration submit → Sanad API: registers account
- Registration submit → Auth state: sets session (evidence: `components/auth/ReviewStep.tsx`)
- Family or companion → Login: signs in
- Login → API client: uses API (evidence: `app/(auth)/login/page.tsx`)
- Companion discovery → Companion profiles: renders (evidence: `app/family/companions/ClientCompanionsView.tsx`)
- Companion discovery → AI smart search: renders (evidence: `app/family/companions/ClientCompanionsView.tsx`)
- AI smart search → Search request hook: uses search
- Search request hook → API client: posts search (evidence: `hooks/useSmartSearch.ts`)
- API client → Sanad API: sends requests (evidence: `lib/services/api.ts`)
- Family or companion → Companion discovery: browses care
- Family or companion → Care requests: creates request
- Care requests → Direct care request: renders form
- Care requests → Care plan assistant: generates plan
- Family or companion → Companion proposals: applies to posts
- Companion proposals → Sanad API: submits proposals
- Family or companion → Booking management: manages bookings
- Booking management → Wallet and payments: pays for care
- Wallet and payments → Stripe Elements: processes payment
- Family or companion → Shift schedules: coordinates shifts
- Family or companion → Chat experience: opens chat
- Chat experience → Chat and messages: uses chat logic
- Chat and messages → API client: loads and sends (evidence: `features/chat/hooks/useChat.ts`)
- Chat and messages → Socket provider: receives realtime events (evidence: `features/chat/hooks/useChat.ts`)
- Family or companion → Admin support: requests support
- Admin support → API client: loads and sends (evidence: `features/admin-support/hooks/useAdminSupport.ts`)
- Family or companion → Notifications: views updates
- Interactive maps → Companion discovery: shows locations
- API client → Auth state: reads and refreshes session (evidence: `lib/services/api.ts`)
