CS2102 Database Systems: Introduction to Web Application Development
This is a project done by a group of students from the National University of Singapore for the module CS2102: Database Systems.
The following contains mainly setup instructions. Refer to our Project Report for more details.
Project Demo Video: https://www.youtube.com/watch?v=BZTjCrFfHSA&feature=youtu.be
Team Members:
- Caijie
- Michelle
- Phoebe
- Sheryl
- Wei Kiat
Tech Stack:
- Frontend: React, Material-UI
- Backend: Node.js, Express
- Database: PostgreSQL
We use Heroku to host both our Frontend and Backend.
Frontend: https://cs2102petlovers.herokuapp.com
To access pre-made users for trying purposes:
- Admin - Username: admin Password: admin
- PetOwner - Username: petowner Password: petowner
- Part Time Caretaker - Username: ptcaretaker Password: ptcaretaker
- Full Time Caretaker - Username: ftcaretaker Password: ftcaretaker
Backend: https://cs2102petloversapi.herokuapp.com
To access the hosted database:
- Install heroku-cli
heroku login
. Contact us for access rights!- If you want to run a single sql command:
echo "<sqlcommand>" | heroku pg:psql
- If you want to run a batch file:
cat <filepath> | heroku pg:psql
We use Travis to continuously integrate, test and deploy our Javascript changes.
- Make sure you have node and npm installed. The quickest way is to use homebrew and do
brew install node
. npm install
to install all dependencies- Create a local instance of postgreSQL database.
- Make sure you have postgres installed.
brew install postgresql
. - Start postgres server.
brew services start postgresql
orbrew services restart postgresql
- Create a database.
createdb <dbname>
(Drop database bydropdb <dbname>
) - Load the build schema.
psql -d <dbname> < build-schema.sql
- Load the dataset.
psql -d <dbname> < add-data.sql
- Make sure you have postgres installed.
- Create a
.env
file in the project root and specify theDATABASE_URL
like this:DATABASE_URL="postgresql://<dbuser>:<dbpassword>@localhost:5432/<dbname>"
. npm start
. This should run the api on port 8080 by default.
Tips:
- You can do
psql -d <dbname>
to enter into your database cmd and execute SQL queries directly there. - In your database cmd after you do step 1, you can do
\l
to see all your databases and\d
to see all your tables.
Do npm run prettier
in project root to auto format all your code nicely!
cd public
from project root. This is the folder containing the React app.- If you are running the API locally, you need to change the
API_HOST
inconsts.js
to your locally running API instance URL. - Refer to the README inside
public
for further instructions.
Note: We use different package managers: npm for back-end and yarn for front-end.
Don't do npm install
for front-end! Similarly, don't do yarn
for back-end!