Nashville Software School Group Project for Indomitable Icicles
This server code pairs with the Rare Publishing Platform React App which can be found here https://github.com/nss-day-cohort-44/rare-indomitable-icicles
The Rare App allows users to login/logout, make, view, edit, and comment their own posts, as well as the posts of other users.
The following Entity Relationship Diagram details the layout of our data tables:
- Full CRUD endpoints for Users, Posts, Tags, Categories, Comments.
- Query endpoints to return data lists by various id categories.
- Access and control of database through SQLite statements.
Note: This project is meant to run simultaneously with the Client-Side Repo found here: https://github.com/nss-day-cohort-44/rare-rabid-sharks
Depending on which repo you start with, you may already have the following directories set up.
This project requires Python
- Create a directory from which to deploy the application.
mkdir RARE
- Within RARE, create two sub-directories, CLIENT and SERVER
mkdir CLIENT
mkdir SERVER
- Navigate into the SERVER sub-directory.
cd CLIENT
- Enter the following commands:
git clone git@github.com:nss-day-cohort-44/rare-rabid-sharks.git .
<-- note the single
dot preceded by a single space.
-
Create a virtual environment:
pipenv shell
-
Once the virtual environment is created, install the 3rd-party software.
pipenv install autopep8 watchgod
- Enter in the following command to start your new data server written in Python:
watchgod request_handler.main
If there are no errors in the code, you will see the following, terse output:
watchgod request_handler.main [09:34:37] watching "/Users/.../workspace/python-server" and reloading "request_handler.main" on changes…
We have provided an SQL script for you to run to build the database. There some INSERT statements they provided. You may create as many INSERT statements as needed to seed the database to your satisfaction.
CREATE TABLE "Users" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"first_name" varchar,
"last_name" varchar,
"email" varchar,
"bio" varchar,
"username" varchar,
"password" varchar,
"profile_image_url" varchar,
"created_on" date,
"active" bit
);
CREATE TABLE "DemotionQueue" (
"action" varchar,
"admin_id" INTEGER,
"approver_one_id" INTEGER,
FOREIGN KEY(`admin_id`) REFERENCES `Users`(`id`),
FOREIGN KEY(`approver_one_id`) REFERENCES `Users`(`id`),
PRIMARY KEY (action, admin_id, approver_one_id)
);
CREATE TABLE "Subscriptions" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"follower_id" INTEGER,
"author_id" INTEGER,
"created_on" date,
FOREIGN KEY(`follower_id`) REFERENCES `Users`(`id`),
FOREIGN KEY(`author_id`) REFERENCES `Users`(`id`)
);
CREATE TABLE "Posts" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"user_id" INTEGER,
"category_id" INTEGER,
"title" varchar,
"publication_date" date,
"image_url" varchar,
"content" varchar,
"approved" bit
);
CREATE TABLE "Comments" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"post_id" INTEGER,
"author_id" INTEGER,
"content" varchar,
FOREIGN KEY(`post_id`) REFERENCES `Posts`(`id`),
FOREIGN KEY(`author_id`) REFERENCES `Users`(`id`)
);
CREATE TABLE "Reactions" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"label" varchar,
"image_url" varchar
);
CREATE TABLE "PostReactions" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"user_id" INTEGER,
"reaction_id" INTEGER,
"post_id" INTEGER,
FOREIGN KEY(`user_id`) REFERENCES `Users`(`id`),
FOREIGN KEY(`reaction_id`) REFERENCES `Reactions`(`id`),
FOREIGN KEY(`post_id`) REFERENCES `Posts`(`id`)
);
CREATE TABLE "Tags" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"label" varchar
);
CREATE TABLE "PostTags" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"post_id" INTEGER,
"tag_id" INTEGER,
FOREIGN KEY(`post_id`) REFERENCES `Posts`(`id`),
FOREIGN KEY(`tag_id`) REFERENCES `Tags`(`id`)
);
CREATE TABLE "Categories" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"label" varchar
);
INSERT INTO Categories ('label') VALUES ('News');
INSERT INTO Tags ('label') VALUES ('JavaScript');
INSERT INTO Reactions ('label', 'image_url') VALUES ('happy', 'https://pngtree.com/so/happy');
- Register a new account. Do not use any sensitive credentials. This is not a secure application!
- Make a post of your own or view other users posts and comment on them.
- Edit or delete any of your own posts or comments.
- Add, edit, or delete Categories for your posts.
- Add, edit, or delete Tags for your posts.
This application was built using Python, Postman, and SQLite3
NSS Cohort 44 Indomitable Icicles Team (Jasmin Kaset, Matthew Machurek, Erica Phillips, Leo Rondeau, Benjamin Schweizer)