# 8.1 Web Application Manual
The following steps will allow you to install our application on your system.

# 8.1.1 Prerequisites
Install Git 1.8.3.1 or later. 
    Follow the instructions based on your OS: https://gitscm.com/downloads  
    Check git version ‘git --version’ 
Install Node.js v17.9.1 or later and npm 8.11.0 or later
    Follow the instructions based on your OS: https://nodejs.org/en/download
    Check version with ‘npm --version’ and ‘node --version’ 
Install Docker 26.1.4 version or later ( not needed for running locally) 
    Follow the instructions based on your OS: https://www.docker.com/get-started/ 
    Check version with ‘docker –version’ 

# 8.1.2 Clone Repository 
Navigate to the repository https://git.cs.vt.edu/quinnanderson/discovery-twitter-fall-2024
    On your device, navigate to the folder where you want to clone the repository 
Clone with HTTP: 
    ‘git clone https://git.cs.vt.edu/quinnanderson/discovery-twitter-fall-2024.git’

# 8.1.3 Install MongoDB Locally (running application locally)
Install MongoDB according to these instructions: https://www.prisma.io/dataguide/mongodb/setting-up-a-localmongodb-database 
    Ensure you install MongoDB compass as well
Run MongoDB
    Navigate to your local installation on your terminal: ie “C:\ProgramFiles\MongoDB\Server\[version]\bin”
    Run ‘mongod.exe’ on your terminal
Import data into MongoDB
    Open MongoDB Compass
    With the MongoDB server running, connect to the following URI: mongodb://localhost:27017
Create a new Database as follows: 
    Database: ‘twitterCollections’ 
    Collection: ‘tweets’
Click on the new collection, choose add Data
    Import JSON or CSV
    Upload ‘tweets.json’ (tweets.json can be found in git repository or on vtworks submission) 

# 8.1.4 Run Application Locally
Run backend server
    ‘cd back’
    ‘npm install’ (only for first time)
    ‘source .env’ 
    ‘npm start’
    Ensure you see ‘Connection with MongoDB was successful’
    If not ensure you have local MongoDB running locally correctly
Run frontend
    ‘cd portal’
    ‘npm install’ (only for first time)
    ‘PORT=5595 npm start’
    Due to cors configuration we must run it on port 5595, if you want to run it on a different port, change the cors requirements for that specific port in back/app.js
    Navigate to specific port in browser ie http://localhost:5595/ 

# 8.1.5 Run Application with Docker
Navigate to back/app.js
    Comment line 144: mongoose.connect("mongodb://127.0.0.1:27017/twitterCollections");
    Uncomment line 146: mongoose.connect("mongodb://discovery-twitter-fall-2024-mongo-1:27017/twitterCollections");
Use docker-compose
    ‘docker compose build’ (needed first time & when you make changes) 
    ‘docker compose up’ 
To stop application 
    ‘docker compose down’

# 8.1.6 Run Application on tml.cs.vt.edu
    ssh into tml.cs.vt.edu server
    Clone repository
    ‘git checkout run-tml-server’
    Branch with ‘localhost’ replaced with ‘tml.cs.vt.edu’ 
    Run application with docker 
