# muhammed-sherif/manhaj architecture

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

- Interactive diagram: https://gitdiagram.com/muhammed-sherif/manhaj
- Repository: https://github.com/muhammed-sherif/manhaj

## Overview

Manhaj is an offline-first study and question-bank product: students sync learning content to a mobile app, study and record work locally, then synchronize activity; administrators manage academic content and users through a dashboard. The graph retains the documented auth, content, question, task, review, and media capabilities. Source excerpts establish only some internal calls; README statements support the broader documented flows, while unsampled subsystem links are omitted where ownership is not clear.

Main entry points: [`apps/api/src/index.ts`](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/index.ts) (Express API), [`apps/mobile/services/database.ts`](https://github.com/muhammed-sherif/manhaj/blob/master/apps/mobile/services/database.ts) (SQLite database), [`packages/db/schema.ts`](https://github.com/muhammed-sherif/manhaj/blob/master/packages/db/schema.ts) (PostgreSQL schema), [`apps/mobile/app`](https://github.com/muhammed-sherif/manhaj/tree/master/apps/mobile/app) (Study screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_student["Student mobile"]
  node_mobile_app["Study screens"]
  node_mobile_tasks["Tasks and review"]
  node_local_services["Offline services"]
  node_content_sync["Content sync"]
  node_srs["Spaced repetition<br/>[anki.ts]"]
end

subgraph group_admin["Admin dashboard"]
  node_dashboard["Admin dashboard<br/>[AppRoutes.tsx]"]
  node_dashboard_client["Dashboard API client<br/>[client.ts]"]
end

subgraph group_backend["API services"]
  node_api["Express API<br/>[index.ts]"]
  node_auth_routes["Authentication<br/>[authController.ts]"]
  node_auth_service["Auth service<br/>[authService.ts]"]
  node_admin_controller["Admin endpoints<br/>[adminController.ts]"]
  node_admin_service["Admin content service<br/>[adminService.ts]"]
  node_student_controller["Student endpoints"]
  node_student_service["Student service<br/>[studentService.ts]"]
  node_content_controller["Content endpoints"]
  node_media_service["Image and video uploads"]
  node_storage["Object storage"]
  node_telegram_worker["Telegram question import<br/>[run.ts]"]
end

subgraph group_data["Persistence and contract"]
  node_local_db[("SQLite database<br/>[database.ts]")]
  node_local_schema["Mobile schema<br/>[schema.ts]"]
  node_server_db[("PostgreSQL schema<br/>[schema.ts]")]
  node_api_client["Typed API client<br/>[mutator.ts]"]
end

node_student_actor(("Student"))
node_admin_actor(("Administrator"))

node_student_actor -->|"studies with"| node_mobile_app
node_mobile_app -->|"requests sync"| node_content_sync
node_content_sync -->|"fetches content"| node_api_client
node_content_sync -->|"writes synced data"| node_local_db
node_local_db -->|"uses schema"| node_local_schema
node_mobile_tasks -->|"reads tasks"| node_local_db
node_local_services -->|"stores offline work"| node_local_db
node_student_actor -->|"manages content"| node_dashboard
node_dashboard -.->|"calls API"| node_dashboard_client
node_dashboard_client -.->|"sends requests"| node_api
node_api -.->|"routes auth"| node_auth_routes
node_auth_routes -->|"delegates auth"| node_auth_service
node_auth_service -->|"reads and writes"| node_server_db
node_api -.->|"routes admin"| node_admin_controller
node_admin_controller -->|"delegates management"| node_admin_service
node_admin_service -->|"reads and writes"| node_server_db
node_admin_controller -->|"uploads video chunks"| node_media_service
node_admin_service -.->|"uses storage"| node_storage
node_api -.->|"routes student"| node_student_controller
node_student_controller -->|"delegates student work"| node_student_service
node_student_service -->|"reads and writes"| node_server_db
node_api -.->|"routes content"| node_content_controller
node_student_actor -->|"records study"| node_mobile_tasks
node_mobile_app -.->|"uses offline features"| node_local_services
node_telegram_worker -.->|"imports questions"| node_server_db
node_mobile_tasks -.->|"reviews questions"| node_srs

click node_mobile_app "https://github.com/muhammed-sherif/manhaj/tree/master/apps/mobile/app"
click node_mobile_tasks "https://github.com/muhammed-sherif/manhaj/tree/master/apps/mobile/app/(tabs)"
click node_local_services "https://github.com/muhammed-sherif/manhaj/tree/master/apps/mobile/services"
click node_local_db "https://github.com/muhammed-sherif/manhaj/blob/master/apps/mobile/services/database.ts"
click node_local_schema "https://github.com/muhammed-sherif/manhaj/blob/master/apps/mobile/db/schema.ts"
click node_content_sync "https://github.com/muhammed-sherif/manhaj/blob/master/apps/mobile/services/contentSyncService.ts"
click node_dashboard "https://github.com/muhammed-sherif/manhaj/blob/master/apps/dashboard/src/routes/AppRoutes.tsx"
click node_dashboard_client "https://github.com/muhammed-sherif/manhaj/blob/master/apps/dashboard/src/api/client.ts"
click node_api "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/index.ts"
click node_auth_routes "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/controllers/authController.ts"
click node_auth_service "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/services/authService.ts"
click node_admin_controller "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/controllers/adminController.ts"
click node_admin_service "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/services/adminService.ts"
click node_student_controller "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/controllers/studentController.ts"
click node_student_service "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/services/studentService.ts"
click node_content_controller "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/controllers/contentController.ts"
click node_media_service "https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/services/videoUploadService.ts"
click node_storage "https://github.com/muhammed-sherif/manhaj/tree/master/apps/api/src/services/storage"
click node_server_db "https://github.com/muhammed-sherif/manhaj/blob/master/packages/db/schema.ts"
click node_api_client "https://github.com/muhammed-sherif/manhaj/blob/master/packages/api-client/src/mutator.ts"
click node_telegram_worker "https://github.com/muhammed-sherif/manhaj/blob/master/apps/telegram-worker/run.ts"
click node_srs "https://github.com/muhammed-sherif/manhaj/blob/master/packages/srs/src/anki.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_mobile_app,node_mobile_tasks,node_local_services,node_content_sync,node_srs toneBlue
class node_dashboard,node_dashboard_client toneAmber
class node_api,node_auth_routes,node_auth_service,node_admin_controller,node_admin_service,node_student_controller,node_student_service,node_content_controller,node_media_service,node_storage,node_telegram_worker toneMint
class node_local_db,node_local_schema,node_server_db,node_api_client toneRose
class node_student_actor,node_admin_actor toneIndigo
```

## Components

### Student mobile

- [Study screens](https://github.com/muhammed-sherif/manhaj/tree/master/apps/mobile/app): `apps/mobile/app`
- [Tasks and review](https://github.com/muhammed-sherif/manhaj/tree/master/apps/mobile/app/(tabs)): `apps/mobile/app/(tabs)`
- [Offline services](https://github.com/muhammed-sherif/manhaj/tree/master/apps/mobile/services): `apps/mobile/services`
- [Content sync](https://github.com/muhammed-sherif/manhaj/blob/master/apps/mobile/services/contentSyncService.ts): `apps/mobile/services/contentSyncService.ts`
- [Spaced repetition](https://github.com/muhammed-sherif/manhaj/blob/master/packages/srs/src/anki.ts): `packages/srs/src/anki.ts`

### Admin dashboard

- [Admin dashboard](https://github.com/muhammed-sherif/manhaj/blob/master/apps/dashboard/src/routes/AppRoutes.tsx): `apps/dashboard/src/routes/AppRoutes.tsx`
- [Dashboard API client](https://github.com/muhammed-sherif/manhaj/blob/master/apps/dashboard/src/api/client.ts): `apps/dashboard/src/api/client.ts`

### API services

- [Express API](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/index.ts): `apps/api/src/index.ts`
- [Authentication](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/controllers/authController.ts): `apps/api/src/controllers/authController.ts`
- [Auth service](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/services/authService.ts): `apps/api/src/services/authService.ts`
- [Admin endpoints](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/controllers/adminController.ts): `apps/api/src/controllers/adminController.ts`
- [Admin content service](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/services/adminService.ts): `apps/api/src/services/adminService.ts`
- [Student endpoints](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/controllers/studentController.ts): `apps/api/src/controllers/studentController.ts`
- [Student service](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/services/studentService.ts): `apps/api/src/services/studentService.ts`
- [Content endpoints](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/controllers/contentController.ts): `apps/api/src/controllers/contentController.ts`
- [Image and video uploads](https://github.com/muhammed-sherif/manhaj/blob/master/apps/api/src/services/videoUploadService.ts): `apps/api/src/services/videoUploadService.ts`
- [Object storage](https://github.com/muhammed-sherif/manhaj/tree/master/apps/api/src/services/storage): `apps/api/src/services/storage`
- [Telegram question import](https://github.com/muhammed-sherif/manhaj/blob/master/apps/telegram-worker/run.ts): `apps/telegram-worker/run.ts`

### Persistence and contract

- [SQLite database](https://github.com/muhammed-sherif/manhaj/blob/master/apps/mobile/services/database.ts): `apps/mobile/services/database.ts`
- [Mobile schema](https://github.com/muhammed-sherif/manhaj/blob/master/apps/mobile/db/schema.ts): `apps/mobile/db/schema.ts`
- [PostgreSQL schema](https://github.com/muhammed-sherif/manhaj/blob/master/packages/db/schema.ts): `packages/db/schema.ts`
- [Typed API client](https://github.com/muhammed-sherif/manhaj/blob/master/packages/api-client/src/mutator.ts): `packages/api-client/src/mutator.ts`

### Other components

- **Student**
- **Administrator**

## Connections

- Student → Study screens: studies with
- Study screens → Content sync: requests sync (evidence: `apps/mobile/services/contentSyncService.ts`)
- Content sync → Typed API client: fetches content (evidence: `apps/mobile/services/contentSyncService.ts`)
- Content sync → SQLite database: writes synced data (evidence: `apps/mobile/services/contentSyncService.ts`)
- SQLite database → Mobile schema: uses schema (evidence: `apps/mobile/services/database.ts`)
- Tasks and review → SQLite database: reads tasks (evidence: `apps/mobile/app/(tabs)/tasks.tsx`)
- Offline services → SQLite database: stores offline work (evidence: `apps/mobile/services/contentSyncService.ts`)
- Student → Admin dashboard: manages content
- Admin dashboard → Dashboard API client: calls API
- Dashboard API client → Express API: sends requests
- Express API → Authentication: routes auth
- Authentication → Auth service: delegates auth (evidence: `apps/api/src/controllers/authController.ts`)
- Auth service → PostgreSQL schema: reads and writes (evidence: `apps/api/src/services/authService.ts`)
- Express API → Admin endpoints: routes admin
- Admin endpoints → Admin content service: delegates management (evidence: `apps/api/src/controllers/adminController.ts`)
- Admin content service → PostgreSQL schema: reads and writes (evidence: `apps/api/src/services/adminService.ts`)
- Admin endpoints → Image and video uploads: uploads video chunks (evidence: `apps/api/src/controllers/adminController.ts`)
- Admin content service → Object storage: uses storage (evidence: `apps/api/src/services/adminService.ts`)
- Express API → Student endpoints: routes student
- Student endpoints → Student service: delegates student work (evidence: `apps/api/src/controllers/studentController.ts`)
- Student service → PostgreSQL schema: reads and writes (evidence: `apps/api/src/services/studentService.ts`)
- Express API → Content endpoints: routes content
- Student → Tasks and review: records study
- Study screens → Offline services: uses offline features (evidence: `apps/mobile/app/(tabs)/tasks.tsx`)
- Telegram question import → PostgreSQL schema: imports questions
- Tasks and review → Spaced repetition: reviews questions
