An image sharing website with image ranking
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
configs
migrations
scripts
src
.gitignore
.gitmodules
LICENSE
Procfile
README.md
alpha
coffeelint.json
package.json

README.md

Alpha

A simple image website using the Sequelize ORM for MySQL and Redis for sessions.

The Home View

Description

This site has a simple Bootstrap themed UI to allow users to log in, upload photos, view their own uploads, and view everyone's uploaded photos and vote on them. The image and user metadata is stored in MySQL while the image ranking is accomplished by a Redis sorted set.

The server uses the ImageMagick library to resize uploaded photos, clean them, and convert them to the .jpeg format.

The ranking algorithm works in the following way: Images are first sorted based on how many half days they were posted after some point in time. Upvotes then "give the image another half day" so that an image that is a half day older with 1 vote would be the same rank as a brand new image. This is implemented effeciently with the sorted set in Redis. Upvotes and Downvotes simply increment or decrement the "score" of the image's id. To display the number of votes on the site (without the time component) the same formula is applied in reverse.

Installation Instructions

Clone the repo and run npm install in the default directory.

After setting up Redis and MySQL on your machine (with the proper credentials in configs/config.json), you need to compile all the Coffeescript to run the script that builds the MySQL tables.

First run ./scripts/build.sh and then run node ./bin/oneoff/init_db.js until it says the initialization has finished.

Before you can upload or resize images, you will need to have ImageMagick and GraphicsMagick installed and you will need to create the following directories: ./image/{thumbnail, optimized, original}. I recommend setting up nginx to serve the image files. A simple example nginx config is below for serving the images and routing all other requests through the node server:

http {
  server {
    client_max_body_size 6M;
    
    location / {
      proxy_pass http://localhost:3000/;
    }

    location /image/thumbnail/ {
      root /Users/david/projects/alpha/;
    }

    location /image/optimized/ {
      root /Users/david/projects/alpha/;
    }
  }
}

npm start then starts the server.