thecodingaviator / coasttocow

MIT License
1 stars 1 forks source link

CoastCowConsumer Data Repository

This repository contains the source code for the CoastCowConsumer Data Repository. Created by @thecodingaviator and @gordoncd.

Table of Contents

Acknowledgements

We use state-of-the-art equipment and high-throughput protocols in our research. In the Bigelow Laboratory Analytical Facilities, we’ve developed in vitro batch assays that mimic a rumen for rapid comparisons of algal candidates and use mass spectrometry to look for promising compounds. Members of our team at the University of Vermont conduct further testing in continuous fermenters to understand how algae-based additives impact the dynamic rumen microbiome, which is responsible for the methane production. The best algal candidates, some of which come from Bigelow Laboratory’s National Center for Marine Microbiota and Algae collection, are being developed as additives to be used in holistic animal feeding trials with dairy cows at partnering research farms at University of New Hampshire, Wolfe’s Neck Center for Agriculture and the Environment, and William H. Miner Agricultural Research Institute. These studies explore the supplements’ nutritional value and subsequent effects on methane burps, milk quality, and milk yields of individual cows, as well as the implications to manure and soil health for grazing and conventional herds.

We are also conducting economic analyses with partners at Colby College, Syracuse University, and University of Vermont to explore pragmatic entry points into the supply chain and cost-benefits of using seaweed feed supplements for organic and conventional dairy in New England. In parallel, Clarkson University is using life cycle assessments to evaluate the cradle-to-grave impact on greenhouse gas emissions of the most promising seaweed additive candidates, including impacts to manure quality and utility in anaerobic digestion or as fertilizer – to ensure the final products represent a net greenhouse gas reduction and true seafood-based solution.

The Coast to Cow to Consumer Project is Funded By:

Description

The CoastCowConsumer Data Repository is a web application designed to provide users with various features and functionality. It allows users to perform tasks such as data exploration, dataset submission, account registration, password reset, and more.

File List

confirmation.php

confirmation.php is responsible for displaying a confirmation page on the Coast to Cow Consumer Data Repository website. It provides feedback to the user based on certain conditions and includes HTML rendering and PHP logic.

The main features of the confirmation.php file are as follows:

Developers working on the confirmation.php file should consider the following:


dashboard.php

dashboard.php represents the dashboard page of the Coast to Cow Consumer Data Repository website. It provides an interface for logged-in users to access various features and functionalities.

The file structure follows the standard PHP file format, starting with the <?php opening tag. It includes a combination of PHP statements and HTML markup, with PHP code enclosed within <?php and ?> tags.

The main functionalities of the dashboard.php file include:

Important considerations for future developers working on the dashboard page:


download.php

download.php is responsible for downloading files from Google Drive using a service account defined in the credentials.php file. This file should not be modified unless you understand its intricacies.

Here's an overview of the download.php file:

Important notes:


explore_dash.php

explore_dash.php represents the explore page of the Coast to Cow Consumer Data Repository website. It allows users to explore and visualize data from the MySQL database.

The file structure follows the standard PHP file format, starting with the <?php opening tag. It includes a combination of PHP statements and HTML markup, with PHP code enclosed within <?php and ?> tags.

The main functionalities of the explore_dash.php file include:

Important considerations for future developers working on the explore page:


explore.js

explore.js provides JavaScript functionality for the explore page (explore_DO.php) of the Coast to Cow Consumer Data Repository website. It handles data retrieval, display, and downloading using the ag-Grid library.

Here's an overview of the explore.js file:

Important considerations for future developers working on the explore.js file:


explore_DO.php

explore_DO.php is used for exploring data related to the Dairy One trials on the Coast to Cow Consumer Data Repository website. It provides a user interface to search and view data stored in the database.

Here's an overview of the explore_DO.php file:

Important considerations for future developers working on the explore_DO.php file:


explore_RD.php

explore_RD.php serves the same function as explore_DO.php but is designed for exploring all other submitted data, not just Dairy One trials, on the Coast to Cow Consumer Data Repository website.

Here's an overview of the explore_RD.php file:

Important considerations for future developers working on the explore_RD.php file:


download.php

download.php handles the download of files from Google Drive using a service account defined in credentials.php. It is responsible for retrieving file metadata, setting appropriate headers for the file download, and downloading the file content.

The file structure follows the standard PHP file format, starting with the <?php opening tag. It includes the necessary dependencies, such as the Google API client library, and includes the utils/config.php file.

The main functionalities of the download.php file include:

Important considerations for future developers working on the download functionality:


index.php

index.php serves as the homepage for the Coast to Cow Consumer Data Repository website. It handles user authentication and login functionality, allowing users to sign in to access their data.

The file structure follows the standard PHP file format, starting with the <?php opening tag. It includes a combination of PHP statements and HTML markup, with PHP code enclosed within <?php and ?> tags.

The main functionalities of the index.php file include:

Important considerations for future developers working on the login page:


mail.php

mail.php handles sending emails using PHPMailer and SMTP.

It includes the database config file utils/config.php and starts the session.

The main features are:

The file depends on:

Considerations:

Overall, mail.php provides a simple API to send transactional emails from PHP applications. Further improvements can be made to handle edge cases, retries, HTML formatting, etc.


modify.php

modify.php is responsible for handling the editing of user profiles. It allows users to update their profile information, including email, phone number, job title, institution, and password. The file also handles the verification of the current password before allowing changes to be made.

The file structure follows the standard PHP file format, starting with the <?php opening tag. It includes the necessary dependencies, such as the utils/config.php file, and starts the session.

The main functionalities of the modify.php file include:

Important considerations for future developers working on the profile editing functionality:


navbar.php

navbar.php is responsible for rendering the navigation bar at the top of the web application. It includes links to different pages and provides user-related options, such as accessing the user's profile and logging out.

The file starts with the <?php opening tag and includes the necessary dependencies, such as the utils/config.php file. It also starts the session.

The main functionalities of the navbar.php file include:

Important considerations for future developers working on the navigation bar:


record_dash.php

record_dash.php is a dashboard page for recording data. It allows users to select what kind of data they will submit and then redirects users to the appropriate submission page.


record_DO.php

record_DO.php is the dedicated page for user submission of DairyOne data. This is separate because metadata extraction has been automated elsewhere in the workflow, and allows a more simple upload process compared to the research data workflow.

The file has functionality as follows:

The record_DO.php file relies on:

Overall, record_DO.php provides the frontend and infrastructure to allow file uploads. The backend accesses the database through the called handleFileUpload() function in submit.js which relies on upload.php.


record_RD.php

record_RD.php allows users to submit research dataset metadata and upload files.

It includes the database config file utils/config.php and initializes the user session.

The main features are:

The file relies on:

Considerations:

Overall, record_RD.php provides the ability to collect metadata and files for research datasets. Further work needed to integrate file processing and access control for sharing the datasets/versioning.


resetpassword.php

resetpassword.php handles the logic for resetting a user's password. It provides a form where users can enter their user ID and email to initiate the password reset process.

The file starts with the <?php opening tag and includes the necessary dependencies, such as the utils/config.php file. It also starts the session.

The main functionalities of the resetpassword.php file include:

Important considerations for future developers working on the password reset functionality:


seaweed.php

Under construction, will incorporate a new seaweed id so a user can track the flow of a seaweed sample within the C3 project.


signup.php

signup.php handles the logic for user registration. It provides a form where users can enter their information to create a new account.

The file starts with the <?php opening tag and includes the necessary dependencies, such as the utils/config.php file. It also starts the session.

The main functionalities of the signup.php file include:

Important considerations for future developers working on the registration functionality:


submit.php

submit.php handles the submission of a dataset by the user. It provides a form where users can enter metadata related to the dataset they want to submit.

The file starts with the <?php opening tag and includes the necessary dependencies, such as the utils/config.php file. It also starts the session.

The main functionalities of the submit.php file include:

Important considerations for future developers working on the dataset submission functionality:


templates.php

templates.php displays a list of templates available for download. It includes HTML markup to create a page layout with a header, content section, and a card container to display the templates.

The file starts with the <?php opening tag and includes the necessary dependencies, such as the utils/config.php file.

The main functionalities of the templates.php file include:

Important considerations for future developers working on the templates functionality:


upload.php

upload.php handles the file upload functionality to Google Drive using a service account defined in the credentials.php file.

The file starts with the <?php opening tag and includes the necessary dependencies, such as the Google Drive client library (autoload.php) and the utils/config.php file.

The main functionalities of the upload.php file include:

Important considerations for future developers working on the file upload functionality:


Usage

To use the CoastCowConsumer Data Repository:

  1. Ensure that the necessary dependencies are available and properly configured (see Dependencies).
  2. Set up the application by following the installation instructions (see Installation).
  3. Access the application by navigating to the appropriate URLs for each page, such as dashboard.php for the main dashboard page, explore.php for the explore page, and so on.
  4. Follow the user interface and functionality provided by each page to interact with the application.

Dependencies

The CoastCowConsumer Data Repository has the following dependencies:

Installation

To install and set up the CoastCowConsumer Data Repository:

  1. Clone this repository to your local machine.
  2. Configure the necessary dependencies such as the PHP environment and database connection details.
  3. Ensure that the file permissions are correctly set to allow the application to run.
  4. Set up the database and import any required schema or sample data if provided.
  5. Once the environment is properly set up, access the application by running a local server and navigating to the appropriate URL.

    Configuring Composer

    If one plans to localhost the repository, the user is responsible for managing their own packages to confirm proper functionality

    We recommend the user uses composer for their file management. Composer is a dependency management tool for PHP programming. It is designed to simplify the process of managing dependencies, libraries, and packages in PHP projects. Composer allows developers to easily declare the libraries and dependencies their project requires and handles the installation and management of those dependencies. This way, we can confirm that libaries are all compatible and do not need to worry about managing this. Here's a quick tutorial on how and where to install composer

    Once one has composer installed, they should create or update their composer.json file to include: "phpmailer/phpmailer": ^6.8 and "google/apiclient": ^2.0 as well as any additional non-native installations (libraries, APIs, other software). Now, the user just needs to run php composer update and/or composer install. If any of those commands fail, add .phar to composer to make the commands php composer.phar update and/or composer.phar install More about this is included in the composer tutorial.

    Google Drive API

    Google Drive API relies upon service accounts. We create a service account attached to the project, and then we use the google drive api to tell that service account to do actions on the operational database. This mostly involves file creation and movement. We use fileID's to give the service account / API the direct location of the files to be operated on. If the service account associated with the project fails, and Gordon or Parth are not available, here are the steps to making a new account and integrating it with the given codebase.

    1. Set up a Google Cloud Project:

      • Go to the Google Cloud Console and create a new project.
      • Enable the Google Drive API for your project.
      • Create credentials for the project, selecting "Service Account" as the account type.
    2. Create a Service Account:

      • In the Cloud Console, go to the "IAM & Admin" -> "Service Accounts" section.
      • Click on "Create Service Account" and provide a name, ID, and description for the service account.
      • Choose the appropriate role for the service account (e.g., Project Editor, Drive API access, etc.).
      • Generate a new private key for the service account and download the JSON file containing the credentials. Keep this file secure.
    3. Set up the Development Environment:

      • Install the required libraries or SDKs for your programming language (e.g., Google Client Library for Python).
      • Import the necessary dependencies in your code.
    4. Authenticate the Service Account:

      • Load the service account JSON file and create a client object using the provided credentials.
      • Use the client object to authenticate requests made to the Google Drive API.
      • replace the service account credentials in credentials.php with this new service account information.

    Congrats! You should be good to go!

License

The CoastCowConsumer Data Repository is released under the MIT License. See the LICENSE file for more details.