A blazing-fast REST API for the Quran Web Application built with Hono + Bun + TypeScript.
- Overview
- Tech Stack
- Features
- Project Structure
- Getting Started
- API Reference
- Request & Response Examples
- Error Handling
- Deployment
- Contributing
- License
This is the backend service for the Quran Web Application — a full-stack platform to read, listen to, and search the Holy Quran. The API provides all 114 Surahs with Arabic text, English translations (Saheeh International), verse-level audio URLs, full-text search, and reciter management.
Built with Hono (ultra-fast web framework) running on Bun (fast JavaScript runtime), fully typed with TypeScript.
| Layer | Technology | Version |
|---|---|---|
| Runtime | Bun | 1.0+ |
| Framework | Hono | 4.0+ |
| Language | TypeScript | 5.0+ |
| Database | Quran JSON (local) | — |
| Audio CDN | Islamic Network CDN | — |
- ⚡ Ultra-fast responses powered by Bun runtime
- 🕌 All 114 Surahs with complete Arabic text and English translation
- 🔊 Audio URL generation for every Ayah with multiple reciters
- 🔍 Full-text search across Arabic and English translations with pagination
- 📖 Verse-level data — Surah number, Juz, Page, revelation type
- 🛡️ Type-safe — 100% TypeScript with strict mode
- 🌐 CORS-ready for frontend integration
- 📝 Request logging for debugging
- ❗ Structured error handling with meaningful messages
backend/
├── src/
│ ├── index.ts # Entry point — server setup & routes
│ ├── routes/
│ │ ├── surah.ts # Surah list & detail endpoints
│ │ ├── ayah.ts # Single ayah endpoint
│ │ ├── search.ts # Full-text search endpoint
│ │ ├── audio.ts # Audio URL endpoints
│ │ └── reciter.ts # Reciter list & detail endpoints
│ ├── middleware/
│ │ ├── cors.ts # CORS configuration
│ │ ├── logger.ts # Request logger
│ │ └── errorHandler.ts # Global error handler
│ ├── data/
│ │ └── quran.json # Quran data (Arabic + Translation)
│ ├── types/
│ │ └── index.ts # Shared TypeScript interfaces
│ └── utils/
│ ├── quranHelper.ts # Data access helper functions
│ └── audioHelper.ts # Audio URL builder & reciter list
├── package.json
├── tsconfig.json
├── bunfig.toml
└── README.md
Make sure you have the following installed:
# Check Bun version
bun --version
# Install Bun if not installed
curl -fsSL https://bun.sh/install | bash# 1. Clone the repository
git clone https://github.com/yourusername/quran-backend.git
# 2. Navigate to the backend directory
cd quran-backend
# 3. Install dependencies
bun installCreate a .env file in the root of the backend directory:
cp .env.example .envThen fill in the values:
# Server
PORT=3001
NODE_ENV=development
# CORS — comma-separated allowed origins
ALLOWED_ORIGINS=http://localhost:3000,https://your-frontend.vercel.app
# Audio CDN Base URL
AUDIO_CDN_BASE=https://cdn.islamic.network/quran/audio/128
⚠️ Never commit your.envfile. It is already in.gitignore.
# Development (with hot reload)
bun run dev
# Production
bun run startThe server will start at:
🚀 Server running at http://localhost:3001
Development: http://localhost:3001
Production: https://your-api.vercel.app
GET /api/surahReturns a list of all 114 Surahs with metadata (no ayahs).
| Parameter | Type | Required | Description |
|---|---|---|---|
| — | — | — | No parameters |
GET /api/surah/:idReturns metadata for a single Surah.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number |
✅ | Surah number (1–114) |
GET /api/surah/:id/ayahsReturns all verses of a Surah with Arabic text, English translation, and audio URL.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number |
✅ | Surah number (1–114) |
reciter |
string |
❌ | Reciter ID (default: alafasy) |
GET /api/ayah/:surahId/:ayahIdReturns a specific verse from a specific Surah.
| Parameter | Type | Required | Description |
|---|---|---|---|
surahId |
number |
✅ | Surah number (1–114) |
ayahId |
number |
✅ | Verse number within the Surah |
reciter |
string |
❌ | Reciter ID (default: alafasy) |
GET /api/search?q={keyword}&page={page}&limit={limit}Full-text search across Arabic and English translation of all Ayahs.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
q |
string |
✅ | — | Search keyword (Arabic or English) |
page |
number |
❌ | 1 |
Page number for pagination |
limit |
number |
❌ | 10 |
Results per page (max: 50) |
GET /api/audio/:ayahNumberReturns the CDN audio URL for a specific Ayah (global Ayah number, 1–6236).
| Parameter | Type | Required | Description |
|---|---|---|---|
ayahNumber |
number |
✅ | Global Ayah number (1–6236) |
reciter |
string |
❌ | Reciter ID (default: alafasy) |
GET /api/audio/surah/:idReturns an array of audio URLs for every verse in a Surah.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number |
✅ | Surah number (1–114) |
reciter |
string |
❌ | Reciter ID (default: alafasy) |
GET /api/recitersReturns a list of all available Quran reciters.
GET /api/reciters/:idReturns details of a specific reciter.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string |
✅ | Reciter ID (e.g. alafasy) |
Available Reciter IDs:
| ID | Name |
|---|---|
alafasy |
Mishary Al-Afasy |
sudais |
Abdur Rahman Al-Sudais |
husary |
Mahmoud Khalil Al-Husary |
minshawi |
Mohamed Siddiq Al-Minshawi |
ghamdi |
Saad Al-Ghamdi |
Request:
curl http://localhost:3001/api/surahResponse:
{
"success": true,
"total": 114,
"data": [
{
"number": 1,
"name": "سورة الفاتحة",
"englishName": "Al-Faatiha",
"englishNameTranslation": "The Opening",
"numberOfAyahs": 7,
"revelationType": "Meccan"
},
{
"number": 2,
"name": "سورة البقرة",
"englishName": "Al-Baqara",
"englishNameTranslation": "The Cow",
"numberOfAyahs": 286,
"revelationType": "Medinan"
}
]
}Request:
curl http://localhost:3001/api/surah/1/ayahs?reciter=alafasyResponse:
{
"success": true,
"surah": {
"number": 1,
"name": "سورة الفاتحة",
"englishName": "Al-Faatiha",
"englishNameTranslation": "The Opening",
"revelationType": "Meccan"
},
"total": 7,
"data": [
{
"number": 1,
"numberInSurah": 1,
"arabic": "بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ",
"translation": "In the name of Allah, the Entirely Merciful, the Especially Merciful.",
"juz": 1,
"page": 1,
"audioUrl": "https://cdn.islamic.network/quran/audio/128/ar.alafasy/1.mp3"
}
]
}Request:
curl "http://localhost:3001/api/search?q=mercy&page=1&limit=5"Response:
{
"success": true,
"query": "mercy",
"total": 45,
"page": 1,
"limit": 5,
"totalPages": 9,
"data": [
{
"surahNumber": 1,
"surahName": "سورة الفاتحة",
"surahEnglishName": "Al-Faatiha",
"ayahNumber": 1,
"numberInSurah": 1,
"arabic": "بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ",
"translation": "In the name of Allah, the Entirely Merciful..."
}
]
}All errors follow a consistent structure:
{
"success": false,
"message": "Human-readable error description"
}| HTTP Code | Meaning |
|---|---|
200 |
Success |
400 |
Bad Request — invalid parameters |
404 |
Not Found — resource does not exist |
500 |
Internal Server Error |
Example error response:
{
"success": false,
"message": "সূরা নম্বর ১ থেকে ১১৪ এর মধ্যে হতে হবে"
}# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prodAdd a vercel.json in the root:
{
"builds": [
{
"src": "src/index.ts",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "src/index.ts"
}
]
}# Build command
bun install
# Start command
bun run startSet the environment variables in the platform dashboard matching your .env file.
Contributions are welcome! Please follow these steps:
# 1. Fork the repository
# 2. Create a feature branch
git checkout -b feature/your-feature-name
# 3. Commit your changes (use conventional commits)
git commit -m "feat: add new reciter support"
# 4. Push to your fork
git push origin feature/your-feature-name
# 5. Open a Pull RequestCommit Message Convention:
| Prefix | Usage |
|---|---|
feat: |
New feature |
fix: |
Bug fix |
docs: |
Documentation update |
refactor: |
Code refactor |
chore: |
Dependency updates |
This project is licensed under the MIT License — see the LICENSE file for details.
- AlQuran Cloud API — Quran data source
- Islamic Network CDN — Free Quran audio CDN
- Hono — Lightweight web framework
- Bun — Fast JavaScript runtime
Made with ❤️ for the Muslim Ummah
⭐ Star this repo if you found it useful!