Skip to content

Commit

Permalink
Merge pull request #1 from A7med3bdulBaset/by_book
Browse files Browse the repository at this point in the history
Deviding hadiths by book
  • Loading branch information
AhmedBaset authored May 6, 2023
2 parents 8cffd9c + 85f09dd commit b579f41
Show file tree
Hide file tree
Showing 631 changed files with 819 additions and 664 deletions.
95 changes: 55 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Hadith-json Database (Hadith of the Prophet Muhammad (PBUH))
# Hadith-json Database [1.1.0]

Hadith is the second source of Islamic law after the Quran. It is the sayings and actions of Prophet Muhammed (PBUH).

An extensive JSON-formatted database is available, containing the Hadiths - Prophet Muhammed's (PBUH) sayings and actions - in both Arabic and English. The database encompasses 17 books of Hadiths.

Expand Down Expand Up @@ -26,73 +28,86 @@ An extensive JSON-formatted database is available, containing the Hadiths - Prop

## Stack:

- Node.js
- TypeScript
- Cheerio.js
- Node.js
- TypeScript
- Cheerio.js
- Axios
- cli-progress

## Data Source:
## Data Source:

The data was scrapped from [Sunnah.com](https://sunnah.com/), and was converted to JSON format using a custom script. All scripts are available in the `src` folder.

## Data Format:

Every `*.json` file is typed as `BookData` interface, which is defined as follows:
The data is available in two formats:

```typescript
interface BookData {
metadata: Prettify<Metadata>;
hadiths: Hadith[];
chapter: Chapter | undefined;
}
1. By Book: The Hadiths are grouped by book. See all Books in the [`db/by_book`](./db/by_book) folder.
1. By Chapter: The Hadiths are grouped by chapter. See all Chapters in the [`db/by_chapter`](./db/by_chapter) folder.
1. Next INSHALLAH will add more formats.

See all Types in the [`types/index.d.ts`](./types/index.d.ts) file.

Every Hadih is an object with the following format:

```typescript
interface Hadith {
id: number;
chapterId: number;
bookId: number;
arabic: string;
english: {
narrator: string;
text: string;
};
chapterId: number;
}
```

See more information in the [`types/index.d.ts`](./types/index.d.ts) file.

## Commands:
## Commands:

- `npm install` - Installs the dependencies.
- `npm run build` - Compiles the TypeScript files to JavaScript.
- `npm run start` - Starts the script that scrapes the data from Sunnah.com.
- `npm run dev:build` - Compiles the TypeScript files to JavaScript in watch mode.
- `npm run dev:start` - Starts the script that scrapes the data from Sunnah.com in watch mode.
- `npm install` - Installs the dependencies.
- `npm run build` - Compiles the TypeScript files to JavaScript.
- `npm run start` - Starts the script that scrapes the data from Sunnah.com.
- `npm run dev:build` - Compiles the TypeScript files to JavaScript in watch mode.
- `npm run dev:start` - Starts the script that scrapes the data from Sunnah.com in watch mode.

## Project Structure:

```
.
├── db
│   ├── by_book
│   │   │   ├── the_9_books
│   │   │   │   ├── bukhari.json
│   │   │   │   ├── muslim.json
│   │   │   │   ├── ...
│   │   │   ├── forties
│   │   │   │   ├── nawawi40.json
│   │   │   │   ├── ...
│   │   │   ├── ...
│   ├── by_chapter
│   │   ├── the_9_books
| | | ├── bukhari
| | | | ├── 1.json
| | | | ├── 2.json
| | | | ├── ...
| | | ├── muslim
| | | | ├── ...
| | | ├── ...
│   │ │ ├── bukhari
│   │ │ │ ├── 1.json
│   │ │ │ ├── 2.json
│   │ │ │ ├── ...
│   │ │ ├── muslim
│   │ │ │ ├── ...
│   │ │ ├── ...
│   │   ├── forties
| | | ├── nawawi40
| | | | ├── 1.json
| | | | ...
| | | other_books
| | | | RyadSalihin
| | | | | ├── 1.json
| | ...
| src
| | ├── index.ts
| | ├── types
| | ├── helpers
| ...
│   │ │ ├── nawawi40
│   │ │ │ ├── 1.json
│   │ │ │ ...
│   │ │ other_books
│   │ │ │ RyadSalihin
│   │ │ │ │ ├── 1.json
│   │ ...
│   ├── by_book
│ src
│ │ ├── index.ts
│ │ ├── types
│ │ ├── helpers
│ ...
```

## Contributing:
Expand Down
1 change: 1 addition & 0 deletions db/by_book/forties/nawawi40.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/forties/qudsi40.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/forties/shahwaliullah40.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":12,"metadata":{"length":40,"arabic":{"title":"أربعون ولي الله الدهلوي","author":"الشاه ولي الدين الدهلوي","introduction":""},"english":{"title":"The Forty Hadith of Shah Waliullah","author":"Shah Waliullah Dahlawi","introduction":""}},"chapters":[{"id":1,"bookId":12,"arabic":"أربعون شاه ولي الله الدهلوي","english":"Forty Hadith of Shah Waliullah Dehlawi"}],"hadiths":[{"id":1,"arabic":"لَیْسَ الْخَبَرُ کَالْمُعَایَنَةِ","english":{"narrator":"","text":"The report is not like witnessing."},"chapterId":1,"bookId":12},{"id":2,"arabic":"الْحَرْبُ خُدَعَةٌ","english":{"narrator":"","text":"War is deception."},"chapterId":1,"bookId":12},{"id":3,"arabic":"الْمُسْلِمُ مِرْآةُ الْمُسْلِمِ","english":{"narrator":"","text":"A Muslim is a mirror of the Muslim."},"chapterId":1,"bookId":12},{"id":4,"arabic":"الْمُسْتَشَارُ مُؤتَمَنٌ","english":{"narrator":"","text":"Someone whose advice is sought is in a position of trust."},"chapterId":1,"bookId":12},{"id":5,"arabic":"الدَّالُّ عَلَی الْخَیْرِ کَفَاعِلِهِ","english":{"narrator":"","text":"The person guiding (someone) to do a good deed, is like the one performing the good deed."},"chapterId":1,"bookId":12},{"id":6,"arabic":"إِسْتَعِیْنُوْا عَلَی الْحَوَائِجِ بِالْکِتْمَانِ","english":{"narrator":"","text":"Seek help for any needs discreetly."},"chapterId":1,"bookId":12},{"id":7,"arabic":"إِتَّقُوْا النَّارَ وَلَوْ بِشِقِّ تَمْرَةٍ","english":{"narrator":"","text":"Protect yourself from the fire even with a part of a date."},"chapterId":1,"bookId":12},{"id":8,"arabic":"الدُّنْیَا سِجْنُ الْمُؤمِنِ وَ جَنَّةُ الْکَافِرِ","english":{"narrator":"","text":"The world is the believer’s prison and the disbeliever’s paradise."},"chapterId":1,"bookId":12},{"id":9,"arabic":"الْحَیَاءُ خَیْرٌ کُلُّهُ","english":{"narrator":"","text":"Modesty is entirely good."},"chapterId":1,"bookId":12},{"id":10,"arabic":"عِدَةُ الْمُؤمِنِ کَاَخْذِ الْکَفِّ","english":{"narrator":"","text":"The word of the believer is like seizing of the hand."},"chapterId":1,"bookId":12},{"id":11,"arabic":"لَا یَحِلُّ لِمُؤمِنٍ اَنْ یَّجُهْرَ أخَاهُ فَوقَ ثَلَاثَةِ أیَّامٍ","english":{"narrator":"","text":"It is unlawful for a believer to sever relations with his brother for more than three days."},"chapterId":1,"bookId":12},{"id":12,"arabic":"لَیْسَ مِنَّا مَنْ غَشَّنَا","english":{"narrator":"","text":"He is not one of us who cheats us."},"chapterId":1,"bookId":12},{"id":13,"arabic":"مَا قَلَّ وَكَفَى خَيْرٌ مِمَّا كَثُرَ وَأَلْهَى","english":{"narrator":"","text":"A little that suffices is better than an abundance that distracts."},"chapterId":1,"bookId":12},{"id":14,"arabic":"الرَّاجِعُ فِيْ هِبَتِهِ کَالرَّاجِعِ فِيْ قَیْئِهِ","english":{"narrator":"","text":"Someone who takes back his gift is like someone who eats his vomit."},"chapterId":1,"bookId":12},{"id":15,"arabic":"الْبَلَاءُ مُوَکِّلٌ بِالْمَنْطِقِ","english":{"narrator":"","text":"Affliction comes from (loose) talk."},"chapterId":1,"bookId":12},{"id":16,"arabic":"النَّاسُ کَأسْنَانِ الْمُشْطِ","english":{"narrator":"","text":"People are like the teeth of a comb."},"chapterId":1,"bookId":12},{"id":17,"arabic":"الْغِنَى غِنَى النَّفْسِ","english":{"narrator":"","text":"Richness lies in the richness of the soul."},"chapterId":1,"bookId":12},{"id":18,"arabic":"الْسَّعِیْدُ مَنْ وُّعِظَ بِغَیْرِهِ","english":{"narrator":"","text":"The felicitous person takes lessons from (the actions of) others."},"chapterId":1,"bookId":12},{"id":19,"arabic":"وَ إِنَّ مِنَ الشِّعْرِ لَحِکْمَةً وَاِنَّ مِنَ الْبَیَانِ لَسِحْرًا","english":{"narrator":"","text":"Indeed, in poetry there is wisdom and in eloquence there is magic."},"chapterId":1,"bookId":12},{"id":20,"arabic":"عَفْوُ الْمُلُوْكِ إِبْقَاءٌ لِلْمُلْكِ","english":{"narrator":"","text":"The king’s pardon preserves the kingdom."},"chapterId":1,"bookId":12},{"id":21,"arabic":"اَلْمَرْءُ مَعَ مَنْ أَحَبَّ","english":{"narrator":"","text":"A man will be with whom he loves."},"chapterId":1,"bookId":12},{"id":22,"arabic":"مَا هَلَكَ إمْرُؤٌ عَرَفَ قَدْرَهُ","english":{"narrator":"","text":"A man who knows his worth will not be ruined."},"chapterId":1,"bookId":12},{"id":23,"arabic":"اَلْوَلَدُ لِلْفِرَاشِ وَ لِلْعَاهِرِ الْحَجَرُ","english":{"narrator":"","text":"The child belongs to the bed and stoning is for the adulterer."},"chapterId":1,"bookId":12},{"id":24,"arabic":"الْیَدُ الْعُلْیَا خَیْرٌ مِّنَ الْیَدِ السُّفْلَی","english":{"narrator":"","text":"The upper hand is superior to the lower hand."},"chapterId":1,"bookId":12},{"id":25,"arabic":"لَا شَکَرَ اللهَ مَنْ لَّا یَشْکُرُ النَّاسَ","english":{"narrator":"","text":"He does not thank Allah who does not thank people."},"chapterId":1,"bookId":12},{"id":26,"arabic":"حُبُّكَ الشَّيْءَ یُعْمِيْ وَ یُصِمُّ","english":{"narrator":"","text":"Your love of something can blind and deafen (you)."},"chapterId":1,"bookId":12},{"id":27,"arabic":"جُبِلَتِ الْقُلُوبُ عَلی حُبَّ مَنْ اَحْسَنَ اِلَیْهَا وَ بُغْضِ مَنْ اَسَاءَ اِلَیْهَا","english":{"narrator":"","text":"Hearts are predisposed to love someone who does them good and detest someone who does them harm."},"chapterId":1,"bookId":12},{"id":28,"arabic":"الْتَّائِبُ مِنَ الذَّنْبِ کَمَنْ لَا ذَنْبَ لَهُ","english":{"narrator":"","text":"One who repents from sin is like someone without sin."},"chapterId":1,"bookId":12},{"id":29,"arabic":"الشَّاهِدُ یَرَی مَا لَا یَرَاهُ الْغَائِبُ","english":{"narrator":"","text":"The person who actually witnesses an (event) sees that which one who is absent does not."},"chapterId":1,"bookId":12},{"id":30,"arabic":"اِذا جَاءَکُمْ کَرِیْمُ قَوْمٍ فَاَکْرِمُوهُ","english":{"narrator":"","text":"If the nobleman of a people comes to you, honour him."},"chapterId":1,"bookId":12},{"id":31,"arabic":"الْیَمِینُ الْفَاجِرَةُ تَدَعُ الدِّیَارَ الْبَلَاقِعَ","english":{"narrator":"","text":"False oaths lay waste to home (lands)."},"chapterId":1,"bookId":12},{"id":32,"arabic":"مَنْ قُتِلَ دُونَ مَالِهِ فَهُوَ شَهِیْدٌ","english":{"narrator":"","text":"Whoever is killed attempting to save his property is a martyr."},"chapterId":1,"bookId":12},{"id":33,"arabic":"الْاَعْمَالُ بِالنِّیَّةِ","english":{"narrator":"","text":"Actions are through intentions."},"chapterId":1,"bookId":12},{"id":34,"arabic":"سَیِّدُ الْقَوْمِ خَادِمُهُمْ","english":{"narrator":"","text":"The leader of a people is their servant."},"chapterId":1,"bookId":12},{"id":35,"arabic":"خَیْرُ الْأُمُوْرِ أَوْسَطُهَا","english":{"narrator":"","text":"The best of affairs is that which is balanced."},"chapterId":1,"bookId":12},{"id":36,"arabic":"اَللَّهُمَّ بَارِكْ فِیْ أُمَّتِیْ فِی بُکُوْرِهَا یَوْمَ الْخَمِیْسِ","english":{"narrator":"","text":"O Allah, bless my nation in its early rising on Thursdays!"},"chapterId":1,"bookId":12},{"id":37,"arabic":"کَادَ الْفَقْرُ أَنْ یَکُوْنَ کُفْرًا","english":{"narrator":"","text":"Poverty can almost turn into disbelief."},"chapterId":1,"bookId":12},{"id":38,"arabic":"الْسَّفَرُ قِطْعَةٌ مِّنَ الْعَذَابِ","english":{"narrator":"","text":"Travelling is a portion of punishment."},"chapterId":1,"bookId":12},{"id":39,"arabic":"خَیْرُ زَّادِ الْتَّقْوَی","english":{"narrator":"","text":"The best of provision is God-Consciousness (taqwa)."},"chapterId":1,"bookId":12},{"id":40,"arabic":"الْمَجَالِسُ بِالْاَمَانَةِ","english":{"narrator":"","text":"Meetings are under trust."},"chapterId":1,"bookId":12}]}
1 change: 1 addition & 0 deletions db/by_book/other_books/aladab_almufrad.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/other_books/bulugh_almaram.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/other_books/mishkat_almasabih.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/other_books/riyad_assalihin.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/other_books/shamail_muhammadiyah.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/abudawud.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/ahmed.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/bukhari.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/darimi.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/ibnmajah.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/malik.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/muslim.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/nasai.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/by_book/the_9_books/tirmidhi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion db/by_chapter/forties/nawawi40/1.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion db/by_chapter/forties/qudsi40/1.json

Large diffs are not rendered by default.

Loading

0 comments on commit b579f41

Please sign in to comment.