Distributed microservice architecture for high scalability.
Build on three services - Payments , Customer , Frontend .
All microserives are highly decoupled.
This app follows the Event driven architecture.
Frontend is made using React JS using the functional components.
For Database MongoDB is used .
RazorPay is used for doing payments .
RabbitMq is used as Message Queue for triggering events.
NGINX is used as reverse proxy for directing the requests over to the services.
ENV files: https://drive.google.com/drive/folders/1BH_2ZdRQfTeSWWMI-kf7HIR3_seh5pCQ?usp=sharing
S1 Clone the project.
S2 Create a file .env in the root folder in the given 2 services.ie ./Payments/.env , ./Customer/.env (Env files are provided in the above link on google drive).
S3 Make sure that docker is installed in the system.
S3 Make sure that PORT 5000 , 5001 , 5002 , 3000 , 27017 are free in the system .
S4 Open terminal in root folder of the project where docker-compose.yml file is present and run following commands.
To verify that all four services are running properly open the following four links in the browser
Each of them would give a message like : Customer service running properly , Payments service running properly
To access frontend UI open the following link in the browser.
# To close application
docker compose down
Architecture of the whole application
The Project is microservice based .
It is based on 3 service : Frontend , Customer , Payments
Payments and Customer services have their own databases which remain in sync with the help of a message queue.
Rabbit Mq is used as a message queue with direct exchange .
Both services Payment and Customer are using MongoDb databases .
Each request to Backend is Redirected using the NGINX as the gateway.
Below is the ER diagram model of the Customer and the Payments Services
Parameter
Type
Description
email
string
Required . email-id
password
string
Required . password
phone
string
Required . phone
name
string
Required . Name
{
"success" : true ,
"data" : {
"_id" : " 63962ab2cb6ff70012a59ce9" ,
"token" : " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFiaGk3N0BnbWFpbC5jb20iLCJfaWQiOiI2Mzk2MmFiMmNiNmZmNzAwMTJhNTljZTkiLCJpYXQiOjE2NzA3ODU3MTQsImV4cCI6MTY3MDg3MjExNH0.zSp4ZYbSvR3bUsD6C_QobVpSCl-gWPx8G6eJQIo0unE" ,
"name" : " Abhinav Singh" ,
"phone" : " 8284927525" ,
"email" : " abhi77@gmail.com"
}
}
{
"success" : false ,
"error" : " Error on creating customer MongoError" ,
"description" : " E11000 duplicate key error collection"
}
Header
Description
Authorization
Required . Bearer Token
Parameter
Type
Description
slot
string
Required . Slot time (Eample: 6-7AM)
{
"success" : true ,
"data" : {
"data" : {
"razorpay_order_id" : " order_KqiNyjAQIZqycz" ,
"customerId" : " 63962ab2cb6ff70012a59ce9" ,
"completed" : false ,
"verified" : false ,
"amount" : 500 ,
"slot" : " 6-7AM" ,
"startDate" : " 2022-12-01T12:00:00.000Z" ,
"endDate" : " 2022-12-31T11:59:00.000Z" ,
"_id" : " 63962c518bed86be92bd3c12" ,
"createdAt" : " 2022-12-11T19:15:29.576Z" ,
"updatedAt" : " 2022-12-11T19:15:29.576Z"
}
}
}
Header
Description
Authorization
Required . Bearer Token
Parameter
Type
Description
razorpay_payment_id
string
Required . Razerpay Payment ID
razorpay_signature
string
Required . Razerpay Signature
razorpay_order_id
string
Required . Razerpay Order ID
{
"success" : true ,
"data" : {
"data" : {
"_id" : " 6394852a0ec8e40f4ede1381" ,
"razorpay_order_id" : " order_KqDcoTx1JF2MEu" ,
"customerId" : " 63942e7248f70d0012c2ea9c" ,
"completed" : true ,
"verified" : false ,
"amount" : 500 ,
"slot" : " 6-7AM" ,
"startDate" : " 2022-12-01T12:00:00.000Z" ,
"endDate" : " 2022-12-31T11:59:00.000Z" ,
"createdAt" : " 2022-12-10T13:10:02.194Z" ,
"updatedAt" : " 2022-12-10T13:10:09.473Z" ,
"razorpay_payment_id" : " pay_29QQoUBi66xm2f" ,
"razorpay_signature" : " 9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
}
}