The Interledger Community 🌱

Gabriel Tomonari for PipeWebMonetization

Posted on

PipeWebMonetization: Back End

Building a back end and database for a modern web application is a complex task that requires careful planning and execution. The PipeWebMonetization platform is an example of this, as it offers a comprehensive solution for tracking website revenue. In this article, we will explore how we set up the back end and database for the PipeWebMonetization platform, and discuss the technology behind it.

Back End and Database Technology

To build a robust and scalable back end for Pipe, we chose to use AWS Lambda with Node serverless functions. AWS Lambda is a popular choice for building serverless back ends because it allows us to run code in response to events, without the need to manage server infrastructure. This makes it easy to scale the back end as our user base grows, and ensures that we only pay for the resources we use.
The database for the PipeWebMonetization platform is DynamoDB, which is a fully managed NoSQL database service offered by AWS. DynamoDB is a highly scalable and reliable database service that provides low-latency performance at any scale. This makes it an ideal choice for a platform like PipeWebMonetization, where we need to store and query large amounts of data in real-time.

The process

Our first set of Lambda functions handle various tasks, such as processing payment events, calculating revenue statistics, and storing data in DynamoDB. We used the AWS API Gateway to create a RESTful API that allows the front end of our platform to interact with the back end.
The API Gateway allows us to define API endpoints that map to our Lambda functions, and handles tasks such as authentication and rate limiting. This makes it easy to manage and monitor our API, and ensures that our back end is secure and scalable.

Setting up the Database

To set up the database, we used DynamoDB. We created several tables to store different types of data. The first table is called pluginIds and is used to store information about the unique IDs of the Wordpress plugins that are sending payment events.
The postInfos table is used to store information about the posts on the website, such as the post ID and the title. This table is used to join with the transactions table to calculate revenue per post.
The transactions table is used to store information about each payment event that is sent to the back end. This includes information about the payment pointer and the amount of the payment.
We also created three tables to store revenue data broken down by different time periods. The transactionsPerDayOfWeek table is used to store revenue data broken down by day of the week, while the transactionsPerDayOfYear table is used to store revenue data broken down by day of the year. The transactionsPerMonth table is used to store revenue data broken down by month.
Each of these tables has a similar schema, with columns for the post ID, the payment pointer, the revenue amount, and the respective time unit. By storing revenue data broken down by different time periods, we can provide website owners with valuable insights into how revenue is generated on their website.

Batching Payment Events

One of the key challenges we faced while setting up the back end and database for PipeWebMonetization was handling the large volume of payment events that are generated by the plugin. To handle this, we developed a custom batcher that groups payment events together and sends them to the back end in batches.
The batcher uses a sliding window algorithm to group payment events together based on their timestamp. This ensures that we can process large volumes of payment events without overwhelming the back end or database.
We hope you found this article informative and helpful in understanding how we set up the back end for PipeWebMonetization.
In our next article, we will be discussing our testing tool and how we ensure the reliability and accuracy of our platform. Stay tuned for more information. Thank you for reading and we hope to see you in the next article!

Top comments (0)