"The Quran is a guidance for humanity, with clear proofs of guidance and as a criterion between right and wrong."
β Surah Al-Baqarah (2:185)
Hidaya is an open-source, digital waqf (charitable endowment) designed to bridge the human condition directly to Quranic guidance.
Inspired by a Friday sermon in Gothenburg on placing the Quran at the center of daily human struggles, Hidaya guides users through their immediate feelings, critical life decisions, and existential questions with verified Medina Uthmani script, classical exegesis (Tafsir), multi-language human translations, and an actionable reflection framework:
- Zero Hallucination: AI models never generate, modify, or paraphrase Quranic Arabic text or Hadith citations.
- Strict 4-Level Content Hierarchy: Every screen preserves immutable boundaries:
- Level 1: Original Verified Quranic Arabic (Uthmani script)
- Level 2: Attributed Human Translations (Saheeh, BernstrΓΆm, Hamidullah)
- Level 3: Classical Tafsir (Ibn Kathir, Al-Sa'di, Al-Muyassar)
- Level 4: AI Synthesis / Reflection Prompts (Clearly tagged as AI / contemplation)
- Non-Fatwa Policy: Hidaya is an educational guide to Quranic sources, not a religious authority. It never issues legal rulings or personal life commands.
- Local-First Privacy: Personal reflection journals and situation narratives are stored client-side in the browser and never logged to remote databases.
- Daily North Star (Dagens LedstjΓ€rna): Synchronized daily contemplation pairing 1 verified passage with historical context, a heart-reflection question, and a practical daily micro-action.
-
3 Core Entry Modes:
- In This Moment: Acute stress, burnout, grief, workplace anger, loneliness.
- Big Questions: Suffering, cosmic justice, morality, purpose of existence.
- Character & Growth: Cultivating patience (Sabr), truthfulness (Sidq), humility (Tawadu'), and forgiveness ('Afw).
- "I Don't Know What I Need" Compass: Guided stepping-stone across 5 spiritual states of heart for users who feel overwhelmed.
- The 3 Human Spheres: Concentric categorization across Individual & Soul, Family & Home, and Society & Work.
- Continuous Hands-Free Audio Player: Murattal audio streams across 4 master reciters (Mishary Alafasy, Abdul Basit, Al-Husary, Saad Al-Ghamdi) with optional translation voiceover for walks and commutes.
-
Halaqah Circle Mode: Guided 5β10 minute family or study group sitting (Listen
$\rightarrow$ Read Aloud$\rightarrow$ Circle Discussion$\rightarrow$ Home Commitment). - Deep Tadabbur Linguistic Roots: Unveils the concrete desert metaphors behind Arabic terminology (e.g., k-dh-m = tying a bulging water-skin shut; sh-r-h = surgical expansion of a constricted chest).
-
Multi-Format Export: One-click slide decks (PowerPoint PPTX via
PptxGenJS), printable PDF study sheets, and shareable visual social cards. - Calm 5-Tab Zero-Popup Workspace: Dedicated full-page views for Guidance, Audio, North Star, Journal, and Preferencesβeliminating intrusive modal popups.
-
Complete 4-Language Localization (
EN,SV,FR,AR): Full localization of UI labels, Surah metadata, Classical Tafsir (Ibn Kathir,Al-Sa'di,Al-Muyassar), 4-step Reflection prompts, and Context explanations across English, Swedish, French, and Arabic. -
Multi-Tier Offline PWA & Per-Verse Audio Caching: Precaches all verified Quranic passages and multilingual translations (
hidaya-passages-v2) for offline reading, with optional one-tap per-verse MP3 audio caching (hidaya-audio-v2) and inline offline storage management. - Scholar Editorial Console: Theological review matrix verifying mapping confidence, Usul al-Din checklist, and reviewer attributions.
βββββββββββββββββββββββββββββββββββββββββββββββββ
β USER β
β (Text Query / Voice Input / Quick Choices) β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββ
β
βββββββββββββββββββββββ΄ββββββββββββββββββββββ
βΌ βΌ
[Stage 1: Direct Category Match] [Stage 2: Deterministic Cache]
(ayah_topic / curated graph) (SHA-256 queryHash lookup)
β β
βββββββββββββββββββββββ¬ββββββββββββββββββββββ
β (If cache miss & no direct match)
βΌ
[Stage 3: Semantic Retrieval]
(pgvector cosine similarity
/ tokenized scoring)
β
βΌ
[Stage 4: Sourced Synthesis]
(Gemini 2.5 Flash Bounded LLM
JSON Schema: 0 Hallucinations)
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββ
β 4-Level Presentation β
βββββββββββββββββββββββββββββββββββββββββββββββββ€
β Level 1: Verified Uthmani Arabic Script β
β Level 2: Human Translations (EN/SV/FR/AR) β
β Level 3: Classical Tafsir (Ibn Kathir, Sa'di) β
β Level 4: "From Quran to Life" Reflection β
βββββββββββββββββββββββββββββββββββββββββββββββββ
hidaya/
βββ .github/ # GitHub collaboration & CI/CD templates
β βββ ISSUE_TEMPLATE/ # Structured bug, feature & translation templates
β βββ workflows/ci.yml # Automated Typecheck, Lint & Build pipeline
β βββ pull_request_template.md # Mandatory theological & quality checklist
βββ docs/ # Deep architectural & milestone documentation
β βββ ARCHITECTURE.md # Technical architecture, 5-tab UX & offline flow
β βββ STATE.md # Milestone tracking & deployment status
βββ public/ # Static assets, PWA manifest & Service Worker
β βββ manifest.json # PWA configuration
β βββ sw.js # 3-bucket offline Service Worker (shell, passages, audio)
βββ src/
β βββ app/ # Next.js App Router entry points
β β βββ api/ # Serverless API endpoints
β β β βββ guidance/route.ts # 4-stage retrieval engine endpoint
β β β βββ offline-passages/route.ts # Precached verified passages & translations feed
β β β βββ tts/route.ts # Server-side native TTS synthesis endpoint
β β β βββ health/route.ts # Health check and environment probe
β β β βββ test-gemini/route.ts # Gemini integration verification
β β βββ globals.css # Global styles and Tailwind v4 imports
β β βββ layout.tsx # Root HTML shell and metadata
β β βββ page.tsx # 5-tab workspace orchestrator page
β βββ components/ # Single-responsibility UI components
β β βββ AudioPlayer.tsx # Verse audio player with per-verse offline audio caching
β β βββ BottomNav.tsx # 5-tab bottom navigation bar
β β βββ ContinuousSessionAudioPlayer.tsx # Hands-free multi-verse audio player
β β βββ CustomizationSheet.tsx # Preferences, depth & offline cache manager
β β βββ DailyNorthStar.tsx # Daily contemplation view
β β βββ EntryModeTabs.tsx # 3 guidance modes selector
β β βββ GuidanceSearchBar.tsx # Search input with voice recognition
β β βββ JournalDrawer.tsx # Saved verses, reflections & offline status badge
β β βββ QuickChoicePills.tsx # Filterable contemplation pill buttons
β β βββ OffTopicBanner.tsx # Courteous off-topic fallback banner
β β βββ VerseCard.tsx # 4-level passage card with 3-segment inline tabs
β β βββ Footer.tsx # Sacred scripture footer
β β βββ ... # Additional study components
β βββ config/
β β βββ appConfig.ts # Central constants, defaults, and storage keys
β βββ data/ # Verified fixtures and localized registries
β β βββ dailyNorthStar.ts # Rotating daily contemplation dataset
β β βββ localizedReflections.ts # 4-step reflection prompts in EN / SV / FR / AR
β β βββ localizedVerseContent.ts # Localized Surah metadata, Tafsir & Context (EN/SV/FR/AR)
β β βββ editorialReviews.ts # Scholar audit reviews dataset
β β βββ licenseRegistry.ts # Content licensing compliance matrix
β β βββ quranFixtures.ts # Verified passages across en/sv/fr/ar
β βββ hooks/ # Custom React hooks
β β βββ useGuidanceSearch.ts # Search, filter, and automatic passage caching
β β βββ useOfflineStatus.ts # Online/offline state, cache stats & PWA install hook
β β βββ useSpeechRecognition.ts # Web Speech API wrapper with fallback
β βββ lib/
β β βββ db/ # Database client and retrieval logic
β β β βββ retrievalService.ts # Categorical, vector & cached retrieval
β β β βββ schema.sql # PostgreSQL schema with pgvector
β β β βββ seedFullQuran.ts # 114 Surah seeder script
β β βββ export/pptxExporter.ts # PowerPoint presentation generator
β β βββ storage/journalStorage.ts# Backup and restore utilities
β βββ services/ # Business service modules
β β βββ audioReciters.ts # Murattal audio stream catalog
β β βββ exportService.ts # PPTX and PDF print orchestrator
β β βββ guidanceService.ts # API caller and client-side fallback matcher
β β βββ offlineCacheService.ts # CacheStorage & localStorage offline sync SDK
β β βββ storage.ts # LocalStorage wrapper
β βββ types.ts # Core TypeScript interfaces & enums
βββ .env.example # Fully documented environment template
βββ .gitignore # Clean Git exclusion rules
βββ AGENTS.md # Permanent rules for AI developers & reviewers
βββ CONTRIBUTING.md # Contributor onboarding & workflow guide
βββ package.json # Project scripts and dependencies
βββ tsconfig.json # Strict TypeScript configuration
βββ wrangler.jsonc # Cloudflare Workers configuration
Before setting up Hidaya locally, ensure you have:
- Node.js:
v20.xorv22.x(LTS recommended) - npm:
v9.xor higher (bundled with Node.js) - Git: Installed and configured on your machine
Follow these steps to get a local development instance running:
# 1. Clone the repository
git clone https://github.com/aomelander/hidaya.git
cd hidaya
# 2. Install dependencies
npm install
# 3. Create your local environment file
cp .env.example .env
# 4. Start the development server
npm run devOpen http://localhost:3000 in your browser.
π‘ Zero-Config Fallback: You do not need live Gemini or Supabase API keys to explore and develop. Hidaya defaults automatically to its verified local fixtures when environment keys are omitted.
Create a .env file in the project root. Refer to .env.example for details:
| Variable | Description | Required? | Default / Fallback |
|---|---|---|---|
GEMINI_API_KEY |
Google Gemini API key for Stage 4 bounded synthesis | Optional | In-memory verified fixtures |
SUPABASE_URL |
Supabase / PostgreSQL instance URL with pgvector |
Optional | In-memory verified fixtures |
SUPABASE_ANON_KEY |
Public client API key for Supabase | Optional | In-memory mock client |
SUPABASE_SERVICE_ROLE_KEY |
Admin role key (used for database seeding) | Optional | Dry-run validation |
NODE_ENV |
Application environment (development / production) |
Optional | development |
PORT |
Local dev server port | Optional | 3000 |
Every commit and pull request must pass the standard validation pipeline:
# 1. TypeScript compiler strict type checking
npm run typecheck
# 2. Lint validation
npm run lint
# 3. Production build compilation
npm run build
# 4. Optional: Run full Quran database seeder (dry-run mode validates data feeds)
npm run db:seedContributions are warmly welcomed from developers, scholars, translators, and designers.
- Fork the repository and create a branch from
main:git checkout -b feature/your-feature-name
- Follow Conventional Commits:
feat: add Spanish translation supportfix: correct typo in Swedish translation for Ayah 2:155docs: update retrieval engine flowchart
- Strict Boundaries: Ensure no AI-generated Arabic text or uncredited tafsir citations.
- Run Checks: Verify
npm run typecheckandnpm run lintpass with 0 errors. - Open a Pull Request: Fill out the pull request checklist.
For detailed guidelines, see CONTRIBUTING.md and AGENTS.md.
Hidaya is an educational guide to Quranic sources, not a religious authority or fatwa service.
It does not issue religious verdicts or personal legal decrees. For complex personal legal, medical, or spiritual verdicts, consult a qualified scholar.
Alhamdulillah. Built as an open-source digital waqf for humanity.