Skip to content

andrewhojel/cs192

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Step #1: Clone the Repository

In a terminal, navigate to the directory where you would like to clone the repository. Then in your browser, navigate to the main page of the repository, press the green code button, and then copy the link under "Clone with HTTPS".

Go to this GitHub Tutorial to learn more about how to clone a repository.

Step #2: Download Dependencies

If you haven't installed npm, navigate to this download tutorial and do so before continuing.

Now, navigate to the view directory within the codebase and run the following command. (The commands below assume that the directory you cloned into is ~/farmlink. If it is not, replace ~/farmlink in all paths with the path to the directory):

~/farmlink/view npm install

Now repeat the process in the functions directory:

~/farmlink/functions npm install

Now you can test if the React application runs by running the following command in the view directory (if it doesn't run, you will likely need to download a missing dependency)

~/farmlink/functions npm start

If it runs, then you are good to go onto the next step!

Step #3: Setup Firebase

Create a project in Firebase (go to this tutorial to learn how) and run the following after doing so:

~/farmlink/functions npm install -g firebase-tools
firebase init

Once you have run firebase init, answer the prompts as follows:

Which Firebase CLI features do you want to set up for this folder? 
=> Functions: Configure and deploy Cloud Functions
First, let’s associate this project directory with a Firebase project...
=> Use an existing project
Select a default Firebase project for this directory
=> application_name 
Do you want to use ESLint to catch probable bugs and enforce style?
=> No
Do you want to install dependencies with npm now?
=> Yes

After this, you should see the following message:

✔ Firebase initialization complete!

Step #3: Setup Firebase Firestore

Go to the database tab in Firebase console and create a database set to test mode and choose your hosting location.

If you would like to test Firebase Firestore locally, run firebase serve in the functions directory. We recommend using Postman as a tool for testing the APIs.

If you get an error regarding credentials when you run firebase serve, then use the following steps to fix it:

  1. Go to the Project Settings tab in the Firebase Console

  2. Go to the Service Accounts tab

  3. There will be an option of Generating a New Key. Click on that option and it will download a file with a .json extension.

  4. Use the command below to connect these credentials

    export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json
    

And run: firebase login --reauth

Step #4: Setup Firebase Authentication

Go to the Project Settings > General in Firebase Console and select the web application icon (which should contain </> in the icon). Now follow the process for making the web application. At the end of the process you will click Continue to Console and see a .json with the firebase config. Paste the contents of this .json into the config.js file in the functions > util directory of the application repository.

Step #5: Setup Cloud Storage

Go to Firebase Console > Storage and click the Get Started button. Follow the directions to set up Cloud Storage.

Now go to the Rules tab and update the rules to the following:

rules_version = '2';
service firebase.storage {
    match /b/{bucket}/o {
	    match /{allPaths=**} {
		    allow read;
		}
	}
}

Finished!

At this point, the repository and Firebase should be set up. We hope you enjoy using our code and feel free to reach out to the contributors with any questions.

Appendix

Repository Structure

Here is a very basic description of the repository structure:

  • ~/farmlink/functions > contains all of the Cloud Functions (handle all of the CRUD operations / backend)
  • ~/farmlink/view > contains the React Application (handles all of the frontend of the application)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages