Environment Setup - maayanzahavi/YouTubeProject-CppServer GitHub Wiki

C++ Server

Relevant riposetory

Find the C++ server repository here under branch main.

Run the Server

  1. Clone the repository to your local machine.
  2. Open a terminal in the cloned folder.
  3. In src/main.cpp, change the server port number if needed.
  4. Execute the following command to start the server:
    ./server
    

Node js

Relevant repotitory

The Node js server can be found here under branch mainPart4.

Run the server

  1. Make sure the C++ server is up and running (see here).
  2. Clone the relevant repository to your computer.
  3. Open terminal in the cloned folder.
  4. Run npm install to install dependencies.

Create a config folder

  1. Create a new folder in the repository named config.
  2. Inside the config folder create the file .env.
  3. Add the following content to the .env file:
CONNECTION_STRING="{your_mongoDB_connection_string}/YouTube_101"
PORT={port_number}
TCP_SERVER_PORT={cpp_server_port_numer}
TCP_SERVER_IP=127.0.0.1

For example:

CONNECTION_STRING="mongodb://localhost:27017/YouTube_101"
PORT=8200
TCP_SERVER_PORT=5556
TCP_SERVER_IP=127.0.0.1
  • Open MongoDB on your computer.
  • Note that a JavaScript script will automatically run and initialize a YouTube_101 database when you run the server. Please make sure you don't have a DB with that called YouTube_101.

Srart the web application

  • Run the server using npm start (if you're using unix, run npm run startUnix instead).
  • On your browser search for: http://localhost:{port_number} (the same port number you chose earlier).

MongoDB

Create a YouTube database

  1. Make sure you have MongoDB Compass installed on your computer. If not, you can download it here.
  2. Follow here to initialize the database (see branch mainPart4).

React App

Relevant repository

the React application is available here under branch mainPart4.

Start the web application

Follow here to start the web application.

Android App

Relevant repository

You can find the relevant repository here under branch mainPart4.

Run the app

Run the relevant beckend servers

  1. Make sure your Node js server is up and running (see here).
  2. Make sure your C++ server is up and running (see here).

Run the Android Application

  1. Clone the relevant repository to Android Studio
  2. Ensure your Android device is connected, or start an emulator.
  3. Configure the Base URL (detailed below).
  4. Run the project by clicking the run button in Android Studio.

Configuring the Base URL

The project is currently configured to run on port 8200. If you choose a different port, you need to update the BaseUrl in the Android project:

  1. Go to res/values/strings.xml.
  2. Update the BaseUrl string to the new port:
    <string name="BaseUrl">http://10.0.2.2:{new_port_number}</string>

For example:

<string name="BaseUrl">http://10.0.2.2:8200</string>

Run on a physical device

If you want to run the application on a physical device, change the IP address to your computer's IP address:

  1. Connect your phone to the same WiFi network as your computer.
  2. Update the BaseUrl in res/values/strings.xml:
    <string name="BaseUrl">http://{your_computer_ip}:{port_number}</string>

For example:

<string name="BaseUrl">http://192.168.1.10:8200</string>
⚠️ **GitHub.com Fallback** ⚠️