Skip to content

Popularity Contest: Learn TypeORM, AngularJS, KOA, and MySQL by finding the best website on the internet using Elo ranking.

Notifications You must be signed in to change notification settings

jake-billings/popularity-contest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

popularity-contest

Popularity contest is a side-project I completed to learn about blockchain-like proof-of-work algorithms and the TypeORM, KOA, Angular, NodeJS technology stack.

The goal of the application is to allow users to find the best page on the internet. Users can submit the page they are on to a central repository, then other users can view an vote on submissions.

Submissions are ranked using the Elo system, which is primarily used to rank chess players.

Since I want to allow anonymous users to submit data and vote on submissions, I implement multiple anti-spam measures.

Submissions that add to or modify the database require blockchain-like proof-of work calculations. I use an algorithm similar to scrypt proof-of-work but much simpler.

Each submission that modifies the database muse include a current timestamp and nonce that both sha256 hash with the data submitted to lead with a variable number 0's.

Example endpoints that use PoW validation are electionCreateAction and candidateCreateAction. UtilPow.ts contains the code that validates PoW on the server side.

Mining is performed by the frontend library in popularity-contest.js in src/frontend. See the function _mine().

Very little effort has been placed into design/user experience. This repository has mainly been an experiment into technology.

Structure

  • Chrome extension: The chrome extension in /chrome exists as an experiment into building chrome extensions. It allows users to submit content to the central repository as they browse.
  • Server: The server in /src serves the API backend and the angular frontend use to vote on content.

How to Develop the Chrome Extension

  1. Clone this repository
  2. cd chrome
  3. run yarn install
  4. Click the three dot menu in the upper right
  5. Navigate to More Tools > Extensions
  6. Check Developer Mode
  7. Click Load Unpacked Extension
  8. Navigate to the chrome directory in this repository

The spider menu now appears in the upper right and as a contextual menu when right-clicking images and links.

How to Develop the Frontend/Backend

Install MySql

  1. Use the MySql website
  2. Open the MySql console by running mysql
  3. Create the database using create database popularitycontest;
  4. Copy the example db config cp ormconfig.example.json ormconfig.json
  5. Edit the ormconfig.json to include your db credentials

Install TypeScript and Yarn with

  1. npm i -g yarn
  2. npm i -g typescript

Setup this project

  1. Clone this repository
  2. Run yarn install
  3. cd src/frontend
  4. Run yarn install again
  5. cd ../..
  6. Run tsc
  7. Run yarn start

About

Popularity Contest: Learn TypeORM, AngularJS, KOA, and MySQL by finding the best website on the internet using Elo ranking.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published