Building an E-Commerce Marketplace Middleware in Clojure

Building an E-Commerce Marketplace Middleware in Clojure

Have you ever wondered how we can build a real-world, production-ready, end-to-end application using the functional programming principles? Immutability, Pure Functions and all other functional programming things sound good on paper but How can we build something useful by applying it?

At Ajira, We recently built an e-commerce marketplace middleware in Clojure for a leading retail chain to sell their products on multiple e-commerce sites seamlessly. In this case study, we are going to build a minimal version of this project using which I will be sharing how we implemented it.

C6dbbb399f7658917f60bd1e2a2663ed?s=128

Tamizhvendan S

November 15, 2019
Tweet

Transcript

  1. Lead Consultant www.ajira.tech Tamizhvendan S Passionate, Pragmatic and Polyglot Programmer

    https://www.demystifyfp.com tamizhvendan Building an E-Commerce Marketplace Middleware in Clojure
  2. OMS Back office Cromā

  3. Back office Cromā

  4. Cromā

  5. Marketplace Middleware Cromā

  6. The System Requirement OMS Back office

  7. The System Requirement OMS … IBMMQ Back office

  8. The System Requirement OMS … IBMMQ Marketplace Middleware Back office

  9. The System Requirement OMS … IBMMQ Marketplace Middleware HTTP Back

    office
  10. The System Requirement OMS … IBMMQ Marketplace Middleware HTTP Back

    office
  11. The System Requirement OMS … IBMMQ Marketplace Middleware HTTP Back

    office PostgreSQL Back office
  12. OMS … IBMMQ Marketplace Middleware HTTP Back office

  13. OMS … IBMMQ Marketplace Middleware HTTP Back office Twelve Different

    Types Of Messages Ranging, Deranging, Pricing, Confirming Order, etc.,
  14. OMS … IBMMQ Marketplace Middleware HTTP Back office Twelve Different

    Types Of Messages Ranging, Deranging, Pricing, Confirming Order, etc., Three Different Target Systems Tata-CliQ, Flipkart, Amazon
  15. OMS … IBMMQ Marketplace Middleware HTTP Back office Twelve Different

    Types Of Messages Ranging, Deranging, Pricing, Confirming Order, etc., Three Different Target Systems Tata-CliQ, Flipkart, Amazon Four Different Data Representations OMS, Tata-CliQ, Flipkart, Amazon
  16. OMS … IBMMQ Marketplace Middleware HTTP Back office Twelve Different

    Types Of Messages Ranging, Deranging, Pricing, Confirming Order, etc., Three Different Target Systems Tata-CliQ, Flipkart, Amazon Four Different Data Representations OMS, Tata-CliQ, Flipkart, Amazon Error Handling Invalid Message, Invalid Channel Configuration, Processing Failure, etc.,
  17. How to implement Marketplace Middleware ?

  18. Lifecycle of an OMS Message

  19. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Processing the message Logging the events OMS … IBMMQ Marketplace Middleware HTTPS Back office Handling the message
  20. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message Polymorphic) Logging the events PostgreSQL, Slack) OMS … IBMMQ Marketplace Middleware HTTPS Back office Handling the message
  21. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message Polymorphic) Handling the message Logging the events PostgreSQL, Slack) Separate Application Boundaries
  22. Parsing The Message

  23. A Sample Ranging Message <EXTNChannelList> <EXTNChannelItemList> <EXTNChannelItem ChannelID="UA" EAN="EAN_1" ItemID="SKU1"

    RangeFlag="Y"AB <EXTNChannelItem ChannelID="UA" EAN="EAN_2" ItemID=“SKU2" RangeFlag="Y"AB AEEXTNChannelItemList> <EXTNChannelItemList> <EXTNChannelItem ChannelID="UB" EAN="EAN_3" ItemID="SKU3" RangeFlag="Y"AB AEEXTNChannelItemList> AEEXTNChannelList>
  24. Parsed Ranging Message

  25. A Sample Pricing Message <EXTNChannelList> <EXTNChannelItemList ChannelID="UA"> <EXTNChannelItem ItemID="194521"> <VKP0PriceLine

    VKP0Price="999.1292"AB <OfferPriceLine OfferPrice="999"AB <ZMRPPriceLine ZMRPPrice="1000"AB AEEXTNChannelItem> <EXTNChannelItem ItemID="185027"> <VKP0PriceLine VKP0Price="650"AB <OfferPriceLine OfferPrice="650"AB <ZMRPPriceLine ZMRPPrice="700"AB AEEXTNChannelItem> AEEXTNChannelItemList> AEEXTNChannelList>
  26. Parsed Pricing Message

  27. Parsing The Message

  28. None
  29. None
  30. None
  31. None
  32. None
  33. None
  34. None
  35. None
  36. None
  37. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message Polymorphic) Handling the message Logging the events PostgreSQL, Slack) Progress …
  38. Processing The Message

  39. Ranging on Tata-CliQ Channel

  40. Pricing on Tata-CliQ Channel

  41. Ranging on Flipkart Channel

  42. Pricing on Flipkart Channel

  43. Processing The Message

  44. None
  45. None
  46. None
  47. None
  48. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message (ranging) Handling the message Logging the events PostgreSQL, Slack) Progress … Getting the channel config Polymorphic) Updating the channel
  49. Getting Channel Configuration

  50. Getting Channel Configuration

  51. Getting Channel Configuration

  52. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message (ranging) Handling the message Logging the events PostgreSQL, Slack) Progress … Getting the channel config Polymorphic) Updating the channel
  53. Processing Ranging on Channels

  54. None
  55. None
  56. None
  57. None
  58. None
  59. None
  60. None
  61. None
  62. None
  63. Ranging on Tata-CliQ Channel

  64. Transforming Ranging Items

  65. Transforming Ranging Items

  66. Transforming Ranging Items

  67. Tata-CliQ API Client

  68. Tata-CliQ API Client

  69. Tata-CliQ API Client

  70. None
  71. None
  72. Ranging on Flipkart Channel

  73. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message (ranging) Handling the message Logging the events PostgreSQL, Slack) Progress … Getting the channel config Polymorphic) Updating the channel
  74. Processing the Ranging Message

  75. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message (pricing) Handling the message Logging the events PostgreSQL, Slack) Pricing - Repeat Yourself Getting the channel config Polymorphic) Updating the channel
  76. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message Polymorphic) Handling the message Logging the events PostgreSQL, Slack) Progress …
  77. Handling the OMS Message

  78. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message Polymorphic) Handling the message Logging the events PostgreSQL, Slack) Progress …
  79. Message Handling 10,000 ft View

  80. Integration Operation Segregation Principle (IOSP) A module should either contain

    business logic or integrate other modules but not both.
  81. None
  82. Polymorphic) Polymorphic) Processing the message Getting the channel config Transforming

    the message Performing the action Reading messages from IBMMQ and dispatching them to handler Parsing the message Handling the message Polymorphic) Logging the event PostgreSQL, Slack) Progress … Getting the channel config
  83. Reading Messages from IBM-MQ

  84. Reading Messages from IBM-MQ

  85. Reading messages from IBMMQ and dispatching them to handler Parsing

    the message Polymorphic) Processing the message Polymorphic) Handling the message Logging the events PostgreSQL, Slack) Progress …
  86. … IBMMQ Logging The Events OMS Marketplace Middleware HTTP Back

    office
  87. … IBMMQ Logging The Events OMS Marketplace Middleware HTTP Back

    office PostgreSQL Back office
  88. https://www.youtube.com/watch?v=yTkzNHF6rMs … functional core is surrounded by a shell of

    imperative code: it manipulates stdin, stdout, the database, and the network, all based on values produced by the functional core.
  89. https://www.youtube.com/watch?v=yTkzNHF6rMs … functional core is surrounded by a shell of

    imperative code: it manipulates stdin, stdout, the database, and the network, all based on values produced by the functional core.
  90. Marketplace Middleware PostgreSQL Back office

  91. Don’t Do! Express!!

  92. None
  93. Log Appenders

  94. Imperative Shell

  95. Functional Core

  96. Imperative Shell

  97. Imperative Shell

  98. Imperative Shell

  99. Imperative Shell

  100. Imperative Shell

  101. None
  102. Error Handling

  103. Don’t Do! Express!!

  104. Don’t Do! Express!!

  105. Don’t Do! Express!!

  106. handling with care :)

  107. Error Handling

  108. processing with care :)

  109. Error Handling

  110. Inspired By