Name: Zhe Pang UNI: zp2249
Name: Jesse Chong UNI: JLC2332
Name: Jun Lin UNI: jal2330
Name: Run Guo UNI: rg3551
- git clone this app somewhere locally
git clone [email protected]:ZhePang/ArtTalkAI.git
- Change into the ArtTalkAI directory
cd ArtTalkAI
. - To setup the DB, we are using PostGreSQL for heroku deployment. We need to set this up locally.
- Install postgresql/psql locally. Run the following commands:
sudo apt-get install postgresql
sudo apt-get install libpq-dev ruby-dev
More info here: https://devcenter.heroku.com/articles/local-setup-heroku-postgres
- Run this command to get local dependencies installed:
bundle install --without production
- Run this command
sudo -u postgres psql
. in the command line it should saypostgres=#
which means your within the postgres interface. - If you are using virtual box and have errors like
psql: FATAL: role "vagrant" does not exist
, run this commandsudo -u postgres createuser vagrant -s && sudo -u postgres createdb vagrant
- Run all of these commands to set it up.
CREATE DATABASE app_devo1;
CREATE DATABASE app_test1;
CREATE DATABASE app_prod1;
CREATE USER username WITH PASSWORD 'password';
ALTER ROLE username WITH SUPERUSER;
GRANT ALL PRIVILEGES ON DATABASE app_devo1 TO username;
GRANT ALL PRIVILEGES ON DATABASE app_test1 TO username;
GRANT ALL PRIVILEGES ON DATABASE app_prod1 TO username;
EXIT
- Now run these commands to setup the DB:
rake db:migrate
. Then:rake db:seed
. - Now, run
rails server
. On your browser, go tolocalhost:3000
to view the page! - If you are seeing an error regarding a database not existing, or DB art objects not being present, then try to recreate the DB again with these commands:
rake db:drop
-->rake db:create
-->rake db:migrate
-->rake db:seed
. Now tryrails server
again the page should load now.
- Run
bundle exec cucumber && bundle exec rspec
- From the project root dir, go to the coverage folder and double click the on the
index.html
file. - You should see on the bottom right of the page that it says "using Cucumber Features, RSpec". That means you are seeing the full coverage report from both Cucumber and RSpec together.
- ArtTalkAI depends on the system time to show the art of the day.
- So, if you want to see the behavior for what art piece is shown per day you need to change your computer system time to a different day.
- After that refresh the page and you should see a different art-of-the-day!
- On local, you may get an error (401 unauth) due to the secrets not being available.
- Please refer to the submission text file for the chatGPT secret. For security reasons its not in the repo.
- And go to the
./.env
file. Paste that secret into that variable and rebuild the serverrails server
.
- Go to the detailed page of any art piece and click the button
Talk to our ArtGuide?
. You would be directed to the chatbot page. - The first time you open a conversation of a new art piece, the ArtGuide would already has the information of the art piece and would welcome you. You can directly ask questions like "What is the background of the painter?", "What does this painting represents for?", etc, without the need to intentionally specify the art piece
- You can go back to the specific art piece by clicking the
Back to Details
link. - Once you have a conversation of one art piece, next time you go to the ArtGuide from the detailed page of that art piece, you would automatically be at the previous conversation.
- The conversations on each art piece are stored in the database and you can select on the chat list at the left of the page to go to existing conversations.
- If you click the
New Chat
button, you would have a new conversation where the ArtGuide serves just like a chatbot without any information. You can go back to the gallery by clickingGo to Gallery
. - ArtGuide is powered by OpenAI API and sometimes has long respond times. Please wait for the response within 30 seconds.
- You can delete past conversations by going to past conversations and click the delete button in the chat history
- From the ArtTalkAI directory, go to the
db
folder. - Inside of
seeds.rb
, copy and paste one of the existing art objects and modify it accordingly. All the fields should be self-explanatory. - For the "link" field, note that this is just a photo file name. Any new pictures should be stored into
/app/assets/images
for the frontend to render it properly. - Run
rake db:reset
. It will delete all tables and all seeds, and then regen tables and add new seeds. That way the IDs will start from 1 again. - To confirm your object is actually added properly, run this command to print all the objects within the DB to console:
rake custom:list_all_arts
.
- Change into the ArtTalk AI directory.
cd ArtTalkAI
. - Run the command, with a useful migration name
rails generate migration <TYPE_IN_A_MIGRATION_NAME_HERE>
- Now, your migration with the given name will appear in
db/migrate
. It has the current timestamp prepended to the name. - Inside your newly created
migration.rb
file, make the needed modifications. - Save the file, now from the ArttalkAI directory, run the command to complete the migration
rails db:migrate
. - To note, all migrations are stored and logged forever in that migrate folder. You can't modify an existing migration, you have to create a new one!
- After everything is set up from above...
bundle exec cucumber
for cucumber testsbundle exec rspec
for rspec tests
For building
- bundle install --without production
- bundle exec cucumber
- bundle exec rspec
DB related
- rake db:migrate
- rake db:seed
- rails generate migration
Checking what objects are inside art DB
- rake custom:list_all_arts
Running server
- rails server
View all possible routes
- rails routes
Heroku commands
- git push heroku master
- heroku run rake db:migrate
- heroku run rake db:seed
- heroku pg:reset postgresql-triangular-46610 --app enigmatic-shore-08561 --confirm enigmatic-shore-08561
Enabling copy and paste linux vm cmd
- sudo VBoxClient --clipboard
- Need to be using ruby 2.6.6
- Please refer to README.md in the git repo root directory.
- DB : postgresql-triangular-46610
- App : enigmatic-shore-08561
- Lucid chart (plans, division of work, app diagrams, etc): https://lucid.app/lucidspark/d9f17524-badb-411f-bb76-b369b13f4705/edit?invitationId=inv_de2c4178-d16f-414f-97ea-470f00e82bff&page=0_0
- Art source: https://www.brushwiz.com/most-famous-paintings
- App deployed here: https://enigmatic-shore-08561-5dc7372f350a.herokuapp.com/arts