Skip to content

πŸ‘½ πŸ‘€ [MySQL Web App] Minimal replica of core reddit functionality

Notifications You must be signed in to change notification settings

sterlinglaird/saiddit

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A minimal MySQL-based replica of core reddit functionality.


Saiddit is an online community forum that allows accounts to post text and links to a given "subsaiddit", and allows other accounts to upvote, downvote, and comment on the posts.

  • An account has:

    • username
    • salted hash password
    • reputation (upvotes minus downvotes).
  • An account can:

    • post to any subsaiddit
    • comment on any post
    • maintain a friend list of other accounts
    • maintain a list of favourite posts
    • subscribe to a subsaiddit
    • upvote or downvote (not both) once per post or comment
  • A post has:

    • author
    • date/time published
    • date/time edited (if applicable)
    • title
    • text (if it is a 'text' post)
    • URL (if it is a 'link' post)
    • upvotes
    • downvotes
    • subsaiddit it belongs to
  • A comment has:

    • author
    • date/time published
    • text
    • the post it belongs to
    • upvotes
    • downvotes
    • the comment it is replying to (if applicable)
  • A subsaiddit has:

    • title
    • description
    • author/creator
    • date/time created
    • default, or not default (whether it's shown on frontpage for unauthenticated user)

Table of Contents

  1. Installation & Setup
  2. MySQL
  1. Flask
  1. Saiddit Database
  2. Contributors

Installation and Setup

The following instructions are for Ubuntu 16.04 LTS.

Note: The chevrons (❯❯❯) represent the zsh shell command prompt.

1. Clone this repository:

❯❯❯ git clone https://github.com/stvhwrd/saiddit.git saiddit;
❯❯❯ cd saiddit;
❯❯❯ sudo apt update;
❯❯❯ sudo apt install mysql-server;
❯❯❯ sudo mysql_secure_installation;
❯❯❯ sudo mysql_install_db;

3. Launch MySQL and create our user with password secretpassword:

❯❯❯ mysql -u saiddituser -p

mysql> CREATE USER 'saiddituser'@'localhost' IDENTIFIED BY 'secretpassword';

mysql> GRANT ALL PRIVILEGES ON * . * TO 'saiddituser'@'localhost';

4. Create the database (will be required to enter the sudo password)

❯❯❯ cd ./sql;
❯❯❯ mysql -h localhost -u saiddituser -p < ./db_schema.sql;

Note: If you are working in a Cloud9 instance, you may simply use the setup script at this point.

5. Install Python 2.x and pip:

❯❯❯ sudo apt install python python-pip python-dev build-essential;

6. Then install python dependencies:

❯❯❯ sudo apt install libmysqlclient-dev;
❯❯❯ pip install flask flask-mysql;

7. Now start up your MySQL server, and use the saiddit database:

❯❯❯ mysql -u saiddituser -p;
❯❯❯ use saiddit;

8. Navigate to the app directory, and fire up the Flask app. These commands assume that your pwd is saiddit.

❯❯❯ cd ./app
❯❯❯ python app.py

9. Now open your browser to the port the app is running on: http://localhost:8080/


MySQL

"MySQL (officially pronounced as "My S-Q-L") is an open-source relational database management system... the world's second most widely used RDBMS, and the most widely used open-source client–server model RDBMS." - Wikipedia

Cheatsheet

Here's a handy cheat sheet for playing with MySQL: Sven Hofmann's MySQL Cheatsheet



Flask

Flask is a Python web framework built with a small core and easy-to-extend philosophy. We use it to interface between the HTML/CSS/JS frontend and the MySQL backend.


Resources:


Structure

The basic file structure of a small flask application is:

app/
β”œβ”€β”€ app.py
└── static/
    └── style.css
    templates/
    β”œβ”€β”€ layout.html
    β”œβ”€β”€ index.html
    └── login.html
        ...

Saiddit Database

Set up the database by running bash setup.sh from the sql directory. This runs all commands from db_schema.sql in MySQL, which creates and populates the saiddit database.

See the diagram below for an E/R diagram representation of the Saiddit DB.



Credit

All contributors are listed on this page.

About

πŸ‘½ πŸ‘€ [MySQL Web App] Minimal replica of core reddit functionality

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 39.4%
  • HTML 35.2%
  • Python 20.9%
  • CSS 3.8%
  • Shell 0.7%