# hashim-alsharif/rihlati architecture

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

- Interactive diagram: https://gitdiagram.com/hashim-alsharif/rihlati
- Repository: https://github.com/hashim-alsharif/rihlati

## Overview

Rihlati is an Arabic-first learning platform with a web interface and a mobile app sharing a server and accounts. Learners ask questions; the server routes them through conversation logic, which searches the reviewed reference library and may use a configured AI provider for source-grounded answers or escalate uncertain and sensitive questions to a specialist. Staff manage accounts, references, indexing, and review. The README also documents curriculum imports and mobile PDF viewing. Some subsystem links are documented rather than visible in sampled source; unsampled connections are omitted.

Main entry points: [`Rihlati/scripts/api_server.py`](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/api_server.py) (HTTP API), [`Rihlati/scripts/assistant_engine.py`](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/assistant_engine.py) (Conversation engine), [`rihlatiApp/src/mobile.js`](https://github.com/hashim-alsharif/rihlati/blob/main/rihlatiApp/src/mobile.js) (Mobile interface), [`Rihlati/scripts/knowledge.py`](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/knowledge.py) (Reference database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Learner clients"]
  node_web["Web interface<br/>[app.js]"]
  node_account_ui["Account interface<br/>[accounts.js]"]
  node_locales["Translations<br/>[i18n.js]"]
  node_mobile["Mobile interface<br/>[mobile.js]"]
  node_pdf_viewer["PDF viewer<br/>[pdf-viewer.js]"]
  node_ios_scene["iOS app scene"]
end

subgraph group_service["Learning service"]
  node_api["HTTP API<br/>[api_server.py]"]
  node_accounts["Accounts and sessions<br/>[accounts.py]"]
  node_conversation["Conversation engine"]
  node_ai["AI provider<br/>[ai_provider.py]"]
  node_settings["Server settings<br/>[server_settings.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_library["Knowledge library"]
  node_knowledge[("Reference database<br/>[knowledge.py]")]
  node_index_jobs["Indexing jobs<br/>[index_jobs.py]"]
  node_curriculum_import["Curriculum import"]
end

subgraph group_operations["Administration"]
end

node_learner(("Learner"))
node_specialist(("Specialist"))
node_external_ai(("AI service"))

node_learner -->|"uses"| node_web
node_learner -->|"uses"| node_mobile
node_mobile -.->|"shares server"| node_api
node_web -.->|"uses server"| node_api
node_api -->|"authenticates"| node_accounts
node_api -->|"routes questions"| node_conversation
node_api -->|"dispatches indexing"| node_index_jobs
node_api -->|"loads settings"| node_settings
node_settings -->|"reads configuration"| node_config
node_conversation -->|"searches references"| node_knowledge
node_conversation -->|"requests grounded answer"| node_ai
node_ai -->|"calls provider"| node_external_ai
node_conversation -.->|"escalates questions"| node_specialist
node_index_jobs -->|"indexes PDFs"| node_knowledge
node_curriculum_import -->|"imports references"| node_knowledge
node_mobile -.->|"opens documents"| node_pdf_viewer
node_ios_scene -.->|"hosts interface"| node_mobile

click node_web "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/app/app.js"
click node_account_ui "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/app/accounts.js"
click node_locales "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/app/i18n.js"
click node_mobile "https://github.com/hashim-alsharif/rihlati/blob/main/rihlatiApp/src/mobile.js"
click node_pdf_viewer "https://github.com/hashim-alsharif/rihlati/blob/main/rihlatiApp/src/pdf-viewer.js"
click node_ios_scene "https://github.com/hashim-alsharif/rihlati/blob/main/rihlatiApp/ios/App/App/SceneDelegate.swift"
click node_api "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/api_server.py"
click node_accounts "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/accounts.py"
click node_conversation "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/assistant_engine.py"
click node_ai "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/ai_provider.py"
click node_settings "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/server_settings.py"
click node_config "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/config.py"
click node_knowledge "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/knowledge.py"
click node_index_jobs "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/index_jobs.py"
click node_curriculum_import "https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/import_curricula.py"

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_account_ui,node_locales,node_mobile,node_pdf_viewer,node_ios_scene toneBlue
class node_api,node_accounts,node_conversation,node_ai,node_settings,node_config toneAmber
class node_knowledge,node_index_jobs,node_curriculum_import toneMint
class node_learner,node_specialist,node_external_ai toneIndigo
```

## Components

### Learner clients

- [Web interface](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/app/app.js): `Rihlati/app/app.js`
- [Account interface](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/app/accounts.js): `Rihlati/app/accounts.js`
- [Translations](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/app/i18n.js): `Rihlati/app/i18n.js`
- [Mobile interface](https://github.com/hashim-alsharif/rihlati/blob/main/rihlatiApp/src/mobile.js): `rihlatiApp/src/mobile.js`
- [PDF viewer](https://github.com/hashim-alsharif/rihlati/blob/main/rihlatiApp/src/pdf-viewer.js): `rihlatiApp/src/pdf-viewer.js`
- [iOS app scene](https://github.com/hashim-alsharif/rihlati/blob/main/rihlatiApp/ios/App/App/SceneDelegate.swift): `rihlatiApp/ios/App/App/SceneDelegate.swift`

### Learning service

- [HTTP API](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/api_server.py): `Rihlati/scripts/api_server.py`
- [Accounts and sessions](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/accounts.py): `Rihlati/scripts/accounts.py`
- [Conversation engine](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/assistant_engine.py): `Rihlati/scripts/assistant_engine.py`
- [AI provider](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/ai_provider.py): `Rihlati/scripts/ai_provider.py`
- [Server settings](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/server_settings.py): `Rihlati/scripts/server_settings.py`
- [Configuration](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/config.py): `Rihlati/scripts/config.py`

### Knowledge library

- [Reference database](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/knowledge.py): `Rihlati/scripts/knowledge.py`
- [Indexing jobs](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/index_jobs.py): `Rihlati/scripts/index_jobs.py`
- [Curriculum import](https://github.com/hashim-alsharif/rihlati/blob/main/Rihlati/scripts/import_curricula.py): `Rihlati/scripts/import_curricula.py`

### Other components

- **Learner**
- **Specialist**
- **AI service**

## Connections

- Learner → Web interface: uses (evidence: `README.md`)
- Learner → Mobile interface: uses (evidence: `README.md`)
- Mobile interface → HTTP API: shares server (evidence: `README.md`)
- Web interface → HTTP API: uses server (evidence: `README.md`)
- HTTP API → Accounts and sessions: authenticates (evidence: `Rihlati/scripts/api_server.py`)
- HTTP API → Conversation engine: routes questions (evidence: `Rihlati/scripts/api_server.py`)
- HTTP API → Indexing jobs: dispatches indexing (evidence: `Rihlati/scripts/api_server.py`)
- HTTP API → Server settings: loads settings (evidence: `Rihlati/scripts/api_server.py`)
- Server settings → Configuration: reads configuration (evidence: `Rihlati/scripts/server_settings.py`)
- Conversation engine → Reference database: searches references (evidence: `Rihlati/scripts/assistant_engine.py`)
- Conversation engine → AI provider: requests grounded answer (evidence: `Rihlati/scripts/assistant_engine.py`)
- AI provider → AI service: calls provider (evidence: `Rihlati/scripts/ai_provider.py`)
- Conversation engine → Specialist: escalates questions
- Indexing jobs → Reference database: indexes PDFs (evidence: `Rihlati/scripts/index_jobs.py`)
- Curriculum import → Reference database: imports references (evidence: `Rihlati/scripts/import_curricula.py`)
- Mobile interface → PDF viewer: opens documents
- iOS app scene → Mobile interface: hosts interface (evidence: `rihlatiApp/ios/App/App/SceneDelegate.swift`)
