edenia / proton-affiliate

On-Chain Affiliate System for the Proton Blockchain :mega:
https://earnproton.com
MIT License
14 stars 4 forks source link
affiliate-marketing blockchain eosio protonchain

Proton Affiliate Platform

An on-chain affiliate marketing platform, rewarding users in XPR for referring and registering on Proton.

Production Instance: earnproton.com

Proton mainnet instance deploys the main branch of this repository.

Development Instance: test.earnproton.com

Proton testnet instance deploys the dev branch of this repository.

Table of Contents

Tech Stack

This application features the following tech stack :

Smart Contract

The affiliate smart contract will store referral info, validation info, and issue rewards for a successfully validated referral.

Smart Contract Docs

For more information on the smart contract design for thi POC please see the smart contract readme.

Demux Pattern

Demux is a backend infrastructure pattern for sourcing blockchain events to deterministically update queryable datastores and trigger side effects.

We use the demux pattern's ability for blockchain events to trigger new transactions, as well as other side effects outside of the blockchain. The blockchain as the single source of truth for all application state

Services Using Demux

Backend services execute the following smart contract actions triggered by demux updaters. The custom permission affiliate@verify is created for the smart contract account so that keys stored in wallet service can can only call the following actions.

Demux Data Flow

  1. Client sends transaction to blockchain
  2. Action Watcher invokes Action Reader to check for new blocks
  3. Action Reader sees transaction in new block, parses actions
  4. Action Watcher sends actions to Action Handler
  5. Action Handler processes actions through Updaters and Effects
  6. Actions run their corresponding Updaters, updating the state of the Datastore
  7. Actions run their corresponding Effects, triggering external events
  8. Client queries API for updated data

Installation

Before you Start

Somethings you need before getting started:

First Time

Copy the .env.example then update the environment variables according to your needs.

cp .env.example .env

Quick Start

  1. Clone this repo using git clone --depth=1 https://github.com/edenia/proton-affiliate.git <YOUR_PROJECT_NAME>.
  2. Move to the appropriate directory: cd <YOUR_PROJECT_NAME>.
  3. Run make run in order to start the project using docker compose.

At this point you can navigate to http://localhost:3000.

File Structure

Within this repository you will find the following directories and files:

.
├── contracts ..................... EOSIO Smart Contracts
│   └── affiliate ................. Affiliate Platform Contract
├── docs .......................... Documentation
│   └── img ....................... Images and Diagrams
├── hapi .......................... Node JS backend & HTTP API
│   └── src
│       └── config ................ Backend Configurations
│       └── routes ................ HTTP routes
│       └── utils ................. Utilities and Libraries
│       └── services .............. Project Business Logic
|           └── hyperion .......... Demux Implementation
├── hasura ........................ Hasura GraphQL Engine
├── kubernetes .................... Kubernetes Manifests
├── utils ......................... Makefiles for project build
├── wallet ........................ EOSIO Wallet Service
└── webapp ........................ ReactJS Web Application

Technical Documentation

EOSIO Blockchain Integration

This project is being developed on the Proton Testnet using the affiliate smart contract account. The backend service is currently using EOS Costa Rica's testnet API Node

We use the EOS JS javascript API for integration with EOSIO-based blockchain networks using EOSIO RPC API.

EOS JS documentation can be found here

Web Application

This FullStack Template uses React.js as a Frontend Library which together with other tools like Apollo Client, GraphQL and Material UI brings a robust solution for building Single Page Applications out of the box.

Hasura GraphQL Engine

Hasura technology maps a PostgreSQL database and provides a reliable and easy-to-use API. This allow us to focus on critical features of our projects, delegating mechanic CRUD (Create, Read, Update, Delete) operations. Hasura also enables custom REST handling capabilities with the possibility to integrate a custom REST server, that way we can extend the base CRUD functionalities and build custom business logic.

Hapi REST Server

We need to handle REST custom requests coming from the Hasura GraphQL server. For this, we use hapi.dev, which is a simple and easy-to-use backend framework.

License

MIT © Sistemas Edenia Internacional S.A..

Contributing

Please read Edenia's Open Source Contributing Guidelines.

Please report bugs big and small by opening an issue

About Edenia


Edenia runs independent blockchain infrastructure and develops web3 solutions. Our team of technology-agnostic builders has been operating since 1987, leveraging the newest technologies to make the internet safer, more efficient, and more transparent.

edenia.com