https://github.com/mhashim6/federated-quran
POC microservice-based federated GrapghQL API for Quran metadata with user Authentication and Authorisation
https://github.com/mhashim6/federated-quran
apollographql bcrypt docker docker-compose federation graphql jest jwt microservices postgresql
Last synced: 3 months ago
JSON representation
POC microservice-based federated GrapghQL API for Quran metadata with user Authentication and Authorisation
- Host: GitHub
- URL: https://github.com/mhashim6/federated-quran
- Owner: mhashim6
- Created: 2023-03-24T22:01:11.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-25T01:25:33.000Z (over 3 years ago)
- Last Synced: 2025-10-16T13:47:07.016Z (8 months ago)
- Topics: apollographql, bcrypt, docker, docker-compose, federation, graphql, jest, jwt, microservices, postgresql
- Language: JavaScript
- Homepage:
- Size: 29.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# federated-quran
POC microservice-based federated GrapghQL API for Quran metadata with user Authentication and Authorisation. _(all the buzz words in one sentence, but it's actually true ¯\\_(ツ)_/¯)_
## Architecture
This is a POC, it exposes a GQL api to retrive quran metadata like "Juz'" and "Surah". We can also use the `users` service to create and auth users.

## API
Here I'll discuss the overall api specs. For details regarding other services, you can read their docs here:
- [users](https://github.com/mhashim6/federated-quran/tree/master/users#readme)
- [juz](https://github.com/mhashim6/federated-quran/tree/master/juz#readme)
- [surah](https://github.com/mhashim6/federated-quran/tree/master/surah#readme)
- [gateway](https://github.com/mhashim6/federated-quran/tree/master/gateway#readme)
### Juz
``` graphql
type Juz {
number: Int!
surahIndex: Int!
ayah: Int!
}
```
### Surah
``` graphql
type Surah {
index: Int!
name: String!
numberOfAyahs: Int!
revelationType: String!
}
```
### Federation
In `Juz`, we can fetch the entire `surah` instead of its index. This is one benifit of federation
``` graphql
extend type Surah @key(fields: "index") {
index: Int!
}
type Juz {
number: Int!
surahIndex: Int!
surah: Surah!
ayah: Int!
}
```
This allows us to write such query normally to get a "Juz'" and the full "Surah" details of it
``` graphql
query getJuzStartSurah {
getJuz (index: 3){
number
ayah
surah {
name
revelationType
}
}
}
```
Output:
``` json
{
"number": 3,
"ayah": 253,
"surah": {
"name": "Al-Baqara",
"revelationType": "Medinan"
}
}
```
## Installation
``` shell
git clone https://github.com/mhashim6/federated-quran.git && cd federated-quran
```
## Run
``` shell
docker compose up -d
```
Then head to `http://localhost` and go to the Apollo Sandbox to play with the API