Coder Social home page Coder Social logo

weedwarriors's Introduction

npm version code style: prettier

Weed Warriors

Frontend for a reporting system where users collaboratively map instances of local invasive plant species.

screenshot01

Prerequisites

  1. Node & npm - This project requires NodeJS and NPM. To make sure you have them available on your machine, try running the following command.
$ npm -v "&&" node -v
9.6.4
v20.1.0
  1. Google Cloud Storage - Follow the steps in this article to create a Google Cloud Storage account for uploading images: Image Upload With Google Cloud Storage and Node.js
  2. Postgres database - Download a database administration platform for Postgres like pgAdmin and create an empty database, then run the creation script to instantiate tables. Import catalog and severity data into respective tables.
  3. Create a .env file with the following variables (see Sequelize documentation on connecting to a database):
PG_URI='postgres://USERNAME:PASSWORD@HOST:PORT/DATABASE'
PROJECT_ID=Google Cloud project ID
STORAGE_BUCKET=Google Cloud bucket name
STORAGE_KEY=Path to Google Cloud .json service account key (ideally with key in the name for gitignore)

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Installation

Start with cloning this repo on your local machine:

$ git clone https://github.com/nurulhaya/weedwarriors.git
$ cd weedwarriors

To install and set up the library, run:

$ npm install

Serving the app

$ npm start

API

See: HTTP primer for frontend developers and primer on JavaScript fetch() method

Catalog

  • GET /api/catalog - Retrieve all data catalog entries in the database.

Media

  • GET /api/media - Retrieve all media entries in the database.
  • POST /api/media - Create a new media entry, example:
Example
await fetch("/api/media", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://site.com/example.png",
  }),
})
  .then((res) => res.json())
  .then((json) => console.log(json));

Reports

  • GET /api/reports - Retrieve all report entries in the database.
  • POST /api/reports - Create a new report entry. Example:
Example
await fetch("/api/reports", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    catalog_id: 1,
    latitude: "31.007027",
    longitude: "-73.922880",
    severity: "10%",
    media_id: 1,
    comments: "N/A",
    user_id: 1,
  }),
})
  .then((res) => res.json())
  .then((json) => console.log(json));

Severity

  • GET /api/severity - Retrieve all severity category entries in the database.

Tickets

  • GET /api/tickets - Retrieve all ticket entries in the database.
  • POST /api/tickets - Create a new ticket entry.
Example
await fetch("/api/tickets", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    title: 'New ticket',
    description: 'Ticket description',
    priority: 'High',
    status: "Not started",
    report_id: 1,
  }),
})
  .then((res) => res.json())
  .then((json) => console.log(json));

Users

  • GET /api/users - Retrieve all user entries in the database.
  • POST /api/users - Create a new user entry.
Example
await fetch("/api/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    first_name: "First",
    last_name: "Last",
    email: "[email protected]",
  }),
})
  .then((res) => res.json())
  .then((json) => console.log(json));

Hosting options

Both the database and live web application can be hosted for free on Render (see Configuring Environment Variables and Secrets).

weedwarriors's People

Contributors

nurulhaya avatar nowamey avatar bigpat05 avatar tmbumd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.