Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weekend project za delivereat with db #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DB_NAME=delivereat_db
DB_USERNAME=
DB_PASSWORD=

accountSid=ACabafbc79c1c76c070ea7300972ef7e05
authToken=d3e4758f3da08a0e569c8355712fd333
84 changes: 8 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,15 @@
# Delivereat

In this project we will create a database backed version of Delivereat. We will build it as a new project, but feel free to use your original Delivereat project as reference. Be aware that because the data structures we will be working with here are likely to be different, it may not be possible to directly re-use your UI components.

A few notes before we get started

* Fork and clone this repo
* Start by building the simplest thing that works. Add to it as you go along. Test your application as frequently as possible to make sure it does what you expect
* Commit frequently and push to Github
* Implement features one at a time
* Make sure your app is responsive
* You may want to design the API first, before implementing the UI that uses and API

## Features

**Database and API**

* Design a database that will allow you to store a menu and orders. Start out with pen and paper first sketching out the tables and columns you will need, as well as the relationships between the tables.
* The database will need to store a menu which will contain item name and price. We will also need to store orders. Each order can have multiple menu items and each menu item can appear in multiple orders. Each menu item ordered will also need to have a quantity.
* Store the SQL commands used to create database and populate with initial data in a `database.sql` file in your repo. It will allow us to review your database code and also make it easy for you to rebuild database.
* Create a RESTful API that will allow you to get the menu and save new orders
* Test the API using Postman

**Menu**
* Design and build a front end UI that will load the menu from the API and display it to the user

**Order**

* Update the menu page to make it an order page
* It should allow the user to specify quantities of items to order
* It should add a delivery charge and display the total order cost
* Create functionality to submit orders to the API and display a notification to the user with order id

## Stretch goals

**Own feature**

* Design and implement a feature of your choosing

**SMS notification**

* Add a phone number input to your UI and a column in orders table to store it.
* Update the API to receive the phone number as part of the order
* Sign up for an account with Twilio. It's an API that allows you to send SMS messages and do lots of other cool things with phones. Use the signup code WELOVECODE to receive $20 credit.
* Implement SMS notification using Twilio to send an SMS notification to a user letting them know that the order has been received.

**Unit tests**

* Add unit tests to your application where appropriate
## README

## Technical notes

* Run `npm install` after cloning to download all dependencies
* Use `npm run dev -- --watch` to build React
* You will need to create a `.env` file to store your database credentials. Make sure you add it to `.gitignore` file so that the credentials do not get commit to git and end up in public.
* Use `node server.js` to run the Node server in another tab
* Place all static files such as images and CSS in the `static` folder. When requesting those files from the server use `/static` at the beginning of the URL. For example `<link rel="stylesheet" type="text/css" href="/static/styles.css">`
* `bundle.js` produced by webpack will be output in the `static` folder
* To send data server using a POST, PUT or PATCH request you can do something the example below, where `order` is an object we want to send to the server and `http://localhost:8080/api/order` is URL we want to send it to.
* what the project does
This is a food order for delivery app. You Select cakes from a menu and submit the order to the restaurant

```js
fetch('http://localhost:8080/api/order', {
method: 'post',
body: JSON.stringify(order),
headers: {
'Content-Type': 'application/json'
}
}).then(function(response) {
return response.json();
}).then(data => {
// handle response
});
```
* what technologies it uses
React, postgres, APIs, SCSS, node

* Check out [Nodemon](https://nodemon.io/) to automatically rebuild and restart your server when changes are saved.
* how to build it and run it
npm run dev, pgweb, node - all through terminal

## README

* Produce a README.md which explains
* what the project does
* what technologies it uses
* how to build it and run it
* any unresolved issues the user should be aware of
lots of unfinished features. Styling is very poor.
59 changes: 59 additions & 0 deletions database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
CREATE DATABASE delivereat_db;

CREATE TABLE menu (
id serial PRIMARY KEY,
name varchar (100) NOT NULL,
price NUMERIC(5,2) NOT NULL,
description varchar (500) NOT NULL,
vegan BOOLEAN NOT NULL
)

INSERT INTO menu VALUES (1, 'Rainbow Cake', 4.99, 'Great for a party', FALSE);
INSERT INTO menu VALUES (2, 'New York Cheesecake', 3.99, 'Classic', FALSE);
INSERT INTO menu VALUES (3, 'Strawberry Cheesecake', 3.99, 'Classic with rich strawberry', FALSE);
INSERT INTO menu VALUES (4, 'Sticky Toffee Pudding', 5.99, 'Sweet and rich and served warm', FALSE);
INSERT INTO menu VALUES (5, 'Red Velvet', 4.50, 'Posher version of sponge', FALSE);
INSERT INTO menu VALUES (6, 'Victoria Sponge', 4.99, 'British Classic with cream and jam', FALSE);
INSERT INTO menu VALUES (7, 'Apple Pie', 4.00, 'American classic', FALSE);
INSERT INTO menu VALUES (8, 'Chocolate Tort', 5.00, 'Ultra rich for chocolate enthusiasts', FALSE);
INSERT INTO menu VALUES (9, 'Battenberg', 3.50, 'Great for kids', FALSE);
INSERT INTO menu VALUES (10, 'Lemon Cake', 3.25, 'Sweet and tart and indulgent', FALSE);
ALTER SEQUENCE menu_id_seq RESTART WITH 11 INCREMENT BY 1

CREATE TABLE order (
id serial PRIMARY KEY,
name varchar (100) NOT NULL,
address varchar (500) NOT NULL,
telephone varchar (15) NOT NULL
)

CREATE TABLE order_content (
id serial PRIMARY KEY,
quantity INT NOT NULL,
FOREIGN KEY (menu_id) REFERENCES menu (id),
FOREIGN KEY (order_id) REFERENCES order (id)
)


UPDATE menu SET photoUrl='rainbow.jpeg' WHERE id=1;
UPDATE menu SET photoUrl='blueberry.jpeg' WHERE id=2;
UPDATE menu SET photoUrl='strawberry.jpeg' WHERE id=3;
UPDATE menu SET photoUrl='toffee.jpeg' WHERE id=4;
UPDATE menu SET photoUrl='redvelvet.jpeg' WHERE id=5;
UPDATE menu SET photoUrl='banana.jpeg' WHERE id=6;
UPDATE menu SET photoUrl='apple.jpeg' WHERE id=7;
UPDATE menu SET photoUrl='tart.jpeg' WHERE id=8;
UPDATE menu SET photoUrl='battenberg.jpeg' WHERE id=9;
UPDATE menu SET photoUrl='fudge.jpeg' WHERE id=10;


ALTER TABLE menu
ADD photoUrl varchar(200);

-- CREATE TABLE delivery (
-- id serial PRIMARY KEY,
-- price_range
-- delivery_charge
-- FOREIGN KEY (menu_id) REFERENCES menu (id),
-- FOREIGN KEY (order_id) REFERENCES order (id),
-- )
Loading