You are on page 1of 10

Incentive Automation System Design

Architecture

Sequence Diagram

Metadata

Messaging Payload

Database Design
Architecture
https://app.diagrams.net/#G1kIxUNtTD74hW5-ol_XwDmM7pOh--Yh5f
Flow Diagrams

Incentive Scheme creation


In Phase 1, schemes are created and persisted in incentive scheme repo against triggers.
Schemes and rules are mapped by triggers which are configured in the .drl file.

Rules Configuration
For phase 1, rules will be configured in excel as decision tables and as precompiled rules are
uploaded to git repo.

Item category incentive scheme


https://app.diagrams.net/#G1g6Ku_K7hmTW0O1kpQ5Fv-sU3ULI7z0u4
Games And Contest

KickStarter
1. Create schedules with start date as mitra joining date and end date as mitra joining date
+ 7 days.
2. Flow will continue as per games and contest flow configured.

Mitra Referral
While updating the incentive transaction table, publish an incentive_update event for the
referred mitra if exists.

Metadata
Incentive Type: Cash , Coins
Incentive Scheme Status: Active, Inactive, Completed, Deleted.
Incentive Category: Games And Contest, Mitra Referral, Kick Starter, Item Category Incentive.
Incentive Event Types: ORDER_CREATED, ORDER_DELIVERED, GAME_COMPLETED,
INCENTIVE_UPDATED
Incentive Transaction Status: CREDIT_ON_HOLD, CREDITED, REDEEMED,
CREDIT_EXPIRED, CREDIT_CANCELLED

API Contract

Http URL Request Payload Response Payload


Method

POST /api//v1.0/promotions/in {
centives "incentive_scheme_payload": {
"name": "Beauty 10% OFF",
"code":
"INCENTIVE_BEAUTY_001",
"description": "10% incentive
value on beauty products",
"type": "cash",
"category": "item_category",
"status": "ACTIVE, INACTIVE,
DELETED",
"run_schedule": {
"start_date": "123123",
"end_date": "123123",
"run_period_in_days": "1"
},
"trigger_on":
"ORDER_DELIVERED_EVENT,
INCENTIVE_UPDATE_EVENT,
GAMES_COMPLETED_EVENT
"
}
}

GET /api/v1.0/promotions/inc {
entives/{incentive_id}
"incentive_scheme_
payload": {
"name": "Beauty
10% OFF",
"code":
"INCENTIVE_BEA
UTY_001",
"description":
"10% incentive
value on beauty
products",
"type": "cash",
"category":
"item_category",
"status":
"ACTIVE,
INACTIVE,
DELETED",
"run_schedule": {
"start_date":
"123123",
"end_date":
"123123",

"run_period_in_day
s": "1"
},
"trigger_on":
"ORDER_DELIVER
ED_EVENT,
INCENTIVE_UPDA
TE_EVENT,
GAMES_COMPLE
TED_EVENT"
}
}

GET /api/v1.0/promotions/inc {
entives
“Incentive_schemes
”: [ {

"incentive_scheme_
payload": {
"name": "Beauty
10% OFF",
"code":
"INCENTIVE_BEA
UTY_001",
"description":
"10% incentive
value on beauty
products",
"type": "cash",
"category":
"item_category",
"status":
"ACTIVE,
INACTIVE,
DELETED",
"run_schedule": {
"start_date":
"123123",
"end_date":
"123123",

"run_period_in_day
s": "1"
},
"trigger_on":
"ORDER_DELIVER
ED_EVENT,
INCENTIVE_UPDA
TE_EVENT,
GAMES_COMPLE
TED_EVENT"
}
}

]
}

PATCH /api/v1.0/promotions/inc {
entives/{incentive_id}
"incentive_scheme_
payload": {
"name": "Beauty
10% OFF",
"code":
"INCENTIVE_BEA
UTY_001",
"description":
"10% incentive
value on beauty
products",
"type": "cash",
"category":
"item_category",
"status":
"ACTIVE,
INACTIVE,
DELETED",
"run_schedule": {
"start_date":
"123123",
"end_date":
"123123",
"run_period_in_day
s": "1"
},
"trigger_on":
"ORDER_DELIVER
ED_EVENT,
INCENTIVE_UPDA
TE_EVENT,
GAMES_COMPLE
TED_EVENT"
}
}

DELETE /api/v1.0/promotions/inc
entives/{incentive_id}

Messaging Payload

Event Payload Notes

ORDER_CREATED {
ORDER_DELIVERED "received_timestamp": "1660283945109",
"version": "v1.0",
"payload_unique_id":
"6de4e514-1bc2-4943-8f40-fea8056d7a9b",
"payload": {
"event_type":
"ORDER_CREATED,/ORDER_DELIVERED",
"incentive_payload": {
"order": {
"order_id": "1234",
"order_status":
"ORDER_CREATED/ORDER_DELIVERED",
"order_amount": "1234",
"created_on": "2342352352352",
"line_items": [
{
"item_id": "1245",
"item_category": "Mom&Beauty",
"item_price": "123"
}
]
},
"user": {
"user_id": "1234",
"is_first_transaction": "true"
},
"mitra": {
"user_id": "4312",
"created_on": "2342352352352"
}
}
}
}

GAME_COMPLETED {
"received_timestamp": "1660283945109",
"version": "v1.0",
"payload_unique_id":
"6de4e514-1bc2-4943-8f40-fea8056d7a9b",
"payload": {
"event_type": " GAME_COMPLETED",
"incentive_payload": {
"mitra": {
"user_id": "4312",
"created_on": "2342352352352",
"incentive_amount": "123"
},
"user_counters": {
"number_of_orders": "12",
"number_of_active_users": "13",
"total_order_amount": "123124"
}
}
}

INCENTIVE_UPDATED {
"received_timestamp": "1660283945109",
"version": "v1.0",
"payload_unique_id":
"6de4e514-1bc2-4943-8f40-fea8056d7a9b",
"payload": {
"event_type": " INCENTIVE_UPDATED",
"incentive_payload": {
"mitra": {
"user_id": "4312",
"created_on": "2342352352352",
"incentive_amount": "123",
“Referred_by_mitra_id”: “1234”
}
}
}
}

Database Design
https://app.diagrams.net/#G1Gpm38Cwm5i2UKnxyYqraanhSUwknSOWN

You might also like