Existing Heroku Link
https://pure-lowlands-90270.herokuapp.com/
Agendasync - A calendar application that has a day-to-day task-based agenda system. The application uses a combination of Google calendar and custom methods to combine a calendar and todolist into one intuitive application. Using twilio, we also bring forth a mobile bot that allows a user to update their daily todolist with commands outside of the web application and on the go.
This application uses several components to initialize the application. Starting from a fresh repository clone, you must perform several setup tasks to bring you up to a working repository.
cd ~/environment && git clone https://github.com/NJIT-CS490/project3-agendasync && cd project3-agendasync
- Install your stuff!
a)npm install && npm install -g webpack && npm install --save-dev webpack && npm install socket.io-client --save
b)pip install flask-socketio
c)pip install eventlet
d)pip install twilio
e)pip install google_auth_oauthlib
f)pip install python-dotenv
g)pip install --upgrade google-api-python-client
⚠️ ⚠️ ⚠️ If you see any error messages, make sure you usesudo pip
orsudo npm
. If it says "pip cannot be found", runwhich pip
and usesudo [path to pip from which pip] install
⚠️ ⚠️ ⚠️
- Update yum:
sudo yum update
, and enter yes to all prompts - Upgrade pip:
sudo pip install --upgrade pip
- Get psycopg2:
sudo pip install psycopg2-binary
- Get SQLAlchemy:
sudo pip install Flask-SQLAlchemy==2.1
- Install PostGreSQL:
sudo yum install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs
Enter yes to all prompts. - Initialize PSQL database:
sudo service postgresql initdb
- Start PSQL:
sudo service postgresql start
- Make a new superuser:
sudo -u postgres createuser --superuser $USER
⚠️ ⚠️ If you get an error saying "could not change directory", that's okay! It worked! - Make a new database:
sudo -u postgres createdb $USER
⚠️ ⚠️ If you get an error saying "could not change directory", that's okay! It worked! - Make sure your user shows up:
a)psql
b)\du
look for ec2-user as a user
c)\l
look for ec2-user as a database - Make a new user:
a)psql
(if you already quit out of psql) b) I recommend 4-5 characters - it doesn't have to be very secure. Remember this password!
create user [some_username_here] superuser password '[some_unique_new_password_here]';
⚠️ this should look likecreate user sresht superuser password 'mypass';
⚠️
c)\q
to quit out of sql cd
intoproject3-agendasync
and make a new file calledsql.env
and addSQL_USER=
andSQL_PASSWORD=
in it- Fill in those values with the values you put in 7. b)
The app uses Google to initialize and authenticate a client.
- Create a Google API account at https://console.developers.google.com/apis/dashboard
- On your developer console, search
Google Calendar API
in the top search bar and enable it for your account - Return to the console UI and click the APIs and Services Tab, click on
Credentials
- Click
Create OAuth client ID
- Create a web application as well as give it a name
- Insert the a uri link from your AWS preview
- Download a credentials file from your web application and rename it
client_secret.json
, insert it into your directory - Create two files,
react.env
andredirect.env
, and insertREACT_APP_GOOGLE_CLIENT_ID='[Google clientId]'
into the former andexport GOOGLE_URI='[local web browser]'
into the latter.
The app uses Twilio to create a mobile bot that allows interaction outside of the application.
- Sign up for a free trial account at https://www.twilio.com/try-twilio
- Verify your email and phone number. The questions that follow are incosequential but it's suggested you answer those related to the purpose of sending and recieving a message on python.
- Copy your twilio account credentials into a file called
twilio.env
and create two export variablesexport TWILIO_ACCOUNT_SID=''
andexport TWILIO_AUTH_TOKEN=''
- Open up your twilio dashboard and open up the side panel labeled
...
and click onphone numbers
. - Click the automatically generated number and scroll down to the messaging section.
- Beside the webhook, replace the url with
[your heroku url]/bot/
- Your twilio application should be ready to go after you save.
There's a special file that you need to enable your db admin password to work for:
- Open the file in vim:
sudo vim /var/lib/pgsql9/data/pg_hba.conf
⚠️ ⚠️ ⚠️ If that doesn't work:sudo vim $(psql -c "show hba_file;" | grep pg_hba.conf)
⚠️ ⚠️ ⚠️ - Replace all values of
ident
withmd5
in Vim::%s/ident/md5/g
- After changing those lines, run
sudo service postgresql restart
- Ensure that your
sql.env
has the username/password of the superuser you created; make sure you source the rest of your.env
files! - Run your code!
a)npm run watch
. If prompted to install webpack-cli, type "yes"
b) In a new terminal,python app.py
c) Preview Running Application (might have to clear your cache by doing a hard refresh)
d) To communicate with the twilio component, message the phone number16506676737
- You should just see the same random number as lect10's socket demo.
To instead deploy the app on Heroku, there are a few additional steps needed.
- Sign up for heroku at https://www.heroku.com/
- Install heroku by running
npm install -g heroku
- Login by running
heroku login -i
- Create the heroku application
heroku create
- Create a
.profile
and insertecho ${CLIENT_SECRET} > /app/client_secret.json
- Create heroku database with
heroku addons:create heroku-postgresql:hobby-dev
and then runheroku pg:wait
- Open
psql
and change database ownership withALTER DATABASE Postgres OWNER TO [database username];
- Return to the console and push database with
PGUSER=[database owner] heroku pg:push postgres DATABASE_URL
(PGUSER=""
can be removed if not working) - Optionally check for your databases with
heroku pg:psql
- Push database information to heroku
heroku pg:push postgres DATABASE_URL
- Ensure all files are synced with master branch and run
git push heroku master
- Return to your config var variables in your heroku settings and add a key that corresponds to every environment variable you have created prior
- Add a new config variable called
CLIENT_SECRET
insert the contents ofclient_secret.json
into it. - After restarting all dynos, the application should load but it's likely you won't be able to make it through authorization. Return to your google account and insert the heroku web address into your existing clientID
- After saving, the application should successfully deploy from the resulting url! It can also be reached and deployed from your heroku account!
Jason Eccles - For this MVP I worked mostly with the initial setup and organization and the backed. I was the first project manager so I was responsible for the initial setup and organization of the project. I created and set up the trello board, the repository, the boilerplate code to get started, and updated the final proposal. I set up the database and the server. I created the text bot using twilio and the queries to pull/update information from the database. I used eslint on the front end code.
Zaafira Hasan - For this MVP, I worked mostly on the frontend to have much of the UI design deployed. I designed the login page with Surindra and helped the google credentials to be sent to the backend. I helped to design the main page and had the personalized Google calendar to show up with the logged-in user. I designed the to-do list interface and using flask-socket allowed the information to be sent to the interface. Along with Surindra, I helped with unit-testing.
Surindra Boodhoo - I created the frontend login page. I setup the add calendar and the add todo item forms. I worked with Andre to get the users information on login Andre,Zaafira, and I worked together to deploy to Heroku. Zaafira and I worked together on the unit tests.
Andre Pugliese - For this MVP I was able to complete several connective pieces of code within the application. I used google calendar API and worked with Surindra to connect the frontend and backend using authentication tokens. I sorted out textbot logic and responses prior to database implementation. Worked with Zaafira and Surindra to deploy the application to Heroku. Used pyLint to lint the backend python code and enforce code style. Updated and expanded readme to include new instructions for application deployment.
Functionalities that still need to be sorted out on the backend. These include: Allowing the server to handle and separate multiple clients during use, separating the textbot into its own class, creating textbot logic for updating the calendar using the API, the textbot needs to delete todos, fix the socket emit issue (need to update with multiple clients), update todos with the bot.
Functionalities that still need to be sorted out on the frontend. These include: We have to create the landing page, have a more aesthetic login page, the calendar interface with buttons need to be more aesthetic.