Skip to content

QuantumLogicsLabs/Quran-Website

Repository files navigation

القرآن الكريم — Quran App v2.0

A production-grade React application combining a full Quran Reader and a Quran Database Downloader, with a rigorous test suite achieving 100% accuracy across all 6,236 verses (78/78 tests passing against the actual JSON).


📦 Project Structure

quran-app/
├── public/
│   ├── index.html
│   └── quran.json              ← Full Quran JSON (place here for deep tests)
│
├── src/
│   ├── index.js                ← App entry point
│   ├── index.css               ← Global styles and CSS variables
│   ├── App.js                  ← Root component (tab navigation: Reader / Downloader)
│   ├── constants.js            ← Single source of truth: SURAH_META, validators
│   ├── setupTests.js           ← Jest global setup (localStorage mock, clipboard)
│   │
│   ├── components/
│   │   └── QuranReader.js      ← Full-featured Quran Reader component
│   │
│   └── __tests__/
│       ├── constants.test.js   ← 130+ tests: metadata, validators, canonical accuracy
│       ├── quranJson.test.js   ← Deep per-verse accuracy tests against quran.json
│       └── QuranReader.test.js ← Component tests (render, search, loading, bookmarks)
│
├── tests/
│   └── test_quran.py           ← Python: 78 tests, 100% passing against quran.json
│
├── quran-schema.sql            ← SQL schema template (MySQL/PostgreSQL/SQLite)
├── quran-reference.pdf.html    ← Printable PDF reference (open in browser → Print)
├── package.json
└── README.md

🚀 Quick Start

# Install dependencies
npm install

# Start development server (Reader + Downloader)
npm start

# Run all Jest tests (no watch mode)
npm test

# Run Python accuracy tests (requires quran.json in project root or public/)
python3 tests/test_quran.py

# Run with pytest for richer output
python -m pytest tests/test_quran.py -v

📖 Quran Reader

The Reader tab is a full-featured reading interface for the entire Holy Quran.

Features

Feature Details
Browse Search all 114 surahs by name, number, or meaning
Filter Toggle Meccan / Medinan revelation type
Read Arabic text (Uthmani) + English translation (Saheeh International)
Arabic size Adjustable font size 18px–52px with live preview
English toggle Show / hide English translation per-session
Jump to Ayah Instantly scroll and highlight any verse number
Prev / Next Navigate between all 114 surahs with named buttons
Bismillah header Shown on all surahs except 1 (it is verse 1) and 9 (none)
Bookmarks Star any verse; persisted to localStorage across sessions
Copy verse Copies Arabic + English + citation reference to clipboard
Resume reading Remembers last-read surah and offers one-click resume
Toast notifications Lightweight, auto-dismissing feedback

⬇ Downloader

The Downloader tab fetches the full Quran from api.alquran.cloud and provides downloads.

Formats

Format File Description
Combined JSON quran.json Arabic + English per verse, nested by surah
Flat JSON quran-flat.json Single array of all 6,236 verses
Split JSON quran-split.json Separate arabic[] and english[] arrays
SQL quran.sql Schema + 6,236 INSERT statements
PDF Opens in browser tab Printable reference sheet
Per-Surah JSON quran-surah-N-Name.json Any individual surah

🧪 Tests — 100% Pass Rate

Python: tests/test_quran.py

78 tests — all passing against the actual quran.json.

✓ ALL 78 TESTS PASSED — 100% accuracy confirmed

Run without pytest: python3 tests/test_quran.py

Test Class Tests What Is Verified
TestDataLoaded 2 File loads, is valid JSON object
TestTopLevel 8 required keys, total_surahs=114, total_verses=6236
TestSurahStructure 12 All 114 surah fields, verse counts vs Hafs an-Asim, Arabic names, revelation types, Meccan=86/Medinan=28
TestVerseStructure 8 Required fields, sequential ayahs, no duplicates, correct types
TestArabicTextAccuracy 10 No BOM, no empty, valid Unicode, no Latin/digits, correct char range (600k–800k)
TestEnglishTextAccuracy 6 No empty, no Arabic in English, valid lengths
TestSpotChecks 16 Specific verse content: S1:A1, S9:A1, S36:A1, S55:A13, S112:A1, S114 end, etc.
TestCompleteness 7 All 114 surahs, all ayahs, 6,236 verses with content, round-trip JSON
TestRegressionFixes 6 Every bug from the previous audit is confirmed fixed

JavaScript: src/__tests__/

Three test files using React Testing Library + Jest:

  • constants.test.js — 130+ tests: SURAH_META, VERSE_COUNTS, validators
  • quranJson.test.js — Deep file accuracy (requires public/quran.json)
  • QuranReader.test.js — Component: render, search, filter, loading, bookmarks, errors

Run: npm test


🎯 Accuracy Guarantees

All of the following are verified by the test suite and confirmed passing:

  1. ✅ Exactly 114 surahs, numbered 1–114 in canonical order
  2. ✅ Exactly 6,236 verses (Hafs an-Asim standard)
  3. ✅ All verse counts match canonical rasm (Al-Baqara=286, Al-Fatiha=7, etc.)
  4. ✅ All Arabic names in correct Arabic script
  5. ✅ All revelation types verified (86 Meccan, 28 Medinan)
  6. Zero BOM characters anywhere in the dataset
  7. Zero invalid Unicode in Arabic text
  8. Zero Arabic characters accidentally in English fields
  9. Sequential ayah numbers (1, 2, 3…) — no gaps, no duplicates
  10. Non-empty Arabic and English for every single verse
  11. ✅ Arabic char total in valid range for fully-diacritized Uthmani text (~715k)
  12. Spot-checked verse content for 16 known reference points

🗄 SQL Schema

CREATE TABLE surahs (
  id               INTEGER PRIMARY KEY,
  number           INTEGER NOT NULL UNIQUE,
  name_arabic      TEXT    NOT NULL,
  name_english     TEXT    NOT NULL,
  name_meaning     TEXT,
  total_verses     INTEGER NOT NULL,
  revelation_type  TEXT    CHECK(revelation_type IN ('Meccan','Medinan'))
);

CREATE TABLE verses (
  id               INTEGER PRIMARY KEY AUTOINCREMENT,
  surah_number     INTEGER NOT NULL REFERENCES surahs(number),
  ayah_number      INTEGER NOT NULL,
  arabic           TEXT    NOT NULL,
  english          TEXT,
  UNIQUE(surah_number, ayah_number)
);

Import:

sqlite3 quran.db < quran.sql         # SQLite
mysql -u root -p quran_db < quran.sql # MySQL
psql -d quran_db -f quran.sql         # PostgreSQL

📡 API

Source: alquran.cloud — free, no API key, no attribution required.

Endpoint Used for
/v1/quran/quran-uthmani Full Arabic Quran
/v1/quran/en.sahih Full English (Saheeh International)
/v1/surah/{n}/quran-uthmani Single surah Arabic
/v1/surah/{n}/en.sahih Single surah English

About

A clean, fast Quran web app where users can search, read, and explore verses in Arabic with English translations—and download the complete JSON dataset for developers and offline use

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors