Skip to content

Myco Matrix: An application where members can register for field trips, connect with others and access resources for safe foraging. Field trip is an automated lottery which chooses participants and sends emails based on status.

License

Notifications You must be signed in to change notification settings

kimmykokonut/Capstone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Myco Matrix

¨ ¨ ¨

See it live on Render (sign in required) || Learn more here via LinkedIn

Initiated April 15, 2024

sign in page
trip details page

Jump around!


About the Project

Description

Myco Matrix is an application where users can register for field trip lotteries, connect with other members and access resources to ensure their foraging experience is safe and permitted.

The Myco Matrix allows users to register, sign in, and edit their profile information. They can register for upcoming field trips with one button click and access resources such as packing lists and permits needed by location (in the Pacific Northwest). Administrators and users within the Coordinator and Leader groups can create, edit and delete field trips as well as manually run the lottery with one button click. The lottery randomizes registrants and assigns them their trip status (accepted, waitlisted, rejected). The automated lottery function emails the registrants their status once the lottery is complete and emails the trip leader the group's contact information. Stretch goals include incorporating the existing mushroom information in the database to attach mushrooms seen on field trips and have that data visible, as well as a fully functional comment thread on each field trip, for users to connect with other users. (See other stretch goals at bottom of Readme).

This project was inspired by my years spent as the volunteer field trip coordinator for the Oregon Mycological Society. I have a strong desire to streamline and automate the process while freeing up volunteer time for other efforts. My long-term goal is to integrate this project into their website to be used for future field trips and provide archival knowledge and encourage more member connection and community.

Built With

TypeScript React React Router MUI npm NodeJS Python Django DjangoREST Postgres HTML5 Markdown Git Visual Studio Code

Known Bugs

  • POST /trips/10/register HTTP/1.1" 400 Once a user registers for a trip, the page disables the register button and lets then know they have registered for the trip. If they navigate away from the page and back, it is the same. If they refresh the page /trips/{id} right after they register, they are offered the registration button again and can sign up for the trip. I have error handling in the api endpoint that won't allow the user to register twice and in react, an error message has been created to address this error. (if the user leaves the page and comes back, it is functional.)
  • MushroomList: issue displaying image-console log says the cookie will expire. The issue is not related to storing the URLs, but to the same-origin policy of the browser, which restricts how resources loaded from different origins can interact. Look into GoogleCloud Storage and django-storages library
  • Issue with state updating: after lottery closes, can navigate to dashboard but trip status is not updated unless I refresh the page, then it is fine.
  • Chrome console warning: Reading cookie in cross-site context will be blocked in future Chrome versions. Once deployed in https, try: cookie = "name=value; SameSite=None; Secure"; (currently: response.set_cookie('auth_token', token.key, httponly=True, samesite='None', secure=True))
  • There is an issue when entering the lat/long in create trip form, the default is set regardless if something is entered. Would prefer a more user-friendly way to get location than form input (Take location name and input gps coordinates on backend?)

Please report any issues or bugs


Getting Started

Prerequisites

Code Editor

To view or edit the code, you will need a code editor or text editor. The open-source code editor we used is VisualStudio Code.

  1. Code Editor Download: VisualStudio Code
  2. Click the download most applicable to your OS and system.
  3. Wait for download to complete, then install -- Windows will run the setup exe and macOS will drag and drop into applications.

Install RestClient Extension for Visual Studio Code

(Optional) Download and install VS Code RestClient extension

Install Postman

(Optional) Download and install [Postman] to test API calls(https://www.postman.com/downloads/).

Install Homebrew (macOS)

I highly recommend you download this package manager to install software.

In terminal: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Python via homebrew

In terminal: $ brew install python@3 (Note: pip is included with Python-it is the standard package manager for Python)

Install PostgreSQL via homebrew

I used PostgreSQL database for this project and pgAdmin as my graphical interface. You are welcome to use the SQLite database that comes built into Django, but it is not as scalable as an option for a database. If you use a database other than PostgreSQL, you will need to update the database settings in settings.py

  • To install: $ brew install postgresql
  • To start the server: $ brew services start postgresql or $ brew services run postgresql to have it not restart at boot time`
  • To connect to the database: $ psql postgres pgAdmin(optional)
  • Install pgAdmin (Administration and development platform for PostgreSQL) brew install --cask pgadmin4

OpenWeather API

You will need your own API key if you want to have the weather report functionality that is present on the TripDetails page. Go to https://openweathermap.org/api, register for an API key and put it in the .env file you will create later on.

Setup

Clone repository

  1. Navigate to the repository.
  2. Click the Fork button and you will be taken to a new page where you can give your repository a new name and description. Choose "create fork".
  3. Click the Code button and copy the url for HTTPS.
  4. On your local computer, create a working directory of your choice.
  5. In this new directory, via the terminal, type $ git clone https://github.com/kimmykokonut/Capstone.
  6. Run the command cd Capstone to enter into the project directory.
  7. View or Edit: On your terminal, type $ code . to open the project in VS Code.

Install dependencies - Front/Client Side

  1. In VSCode Terminal: navigate to client directory
  2. Enter $ npm install to compile the application's code and install all needed dependencies.
  3. Run local server: $ npm run dev (This will be located at: http://localhost:5173/)

Install dependencies - Backend/WebAPI

  1. In VSCode Terminal: navigate to api directory.
  2. Make sure the .gitignore in the root directory has .venv in it.
  3. Create a virtual environment $ python3 -m venv .venv
  4. Enter the virtual environment $ . .venv/bin/activate
  5. Install packages and dependencies $ pip install -r requirements.txt
  1. Run backend server (http://127.0.0.1:8000) $ python manage.py runserver
  • To exit virtual environment: $ . deactivate

API .env

  1. Make sure the .gitignore has .env in it and is committed before step 2.
  2. Create .env file in the root directory for the backend api.
  3. Add in the following fields with your own personal information: (note host and port may differ depending on what service you are using)
SECRET_KEY = '{YOUR-KEY}'
DB_USER='{YOUR-USER-NAME}'
DB_PASSWORD='{YOUR-DATABASE-PASSWORD}'

EMAIL_HOST='smtp.gmail.com'
EMAIL_PORT=587
EMAIL_HOST_USER='{YOUR-SENDER-EMAIL}'
EMAIL_HOST_PASSWORD='{YOUR-SENDER-PASSWORD}'

Client .env

  1. Create a .env file in the same directory level as package.json (In my file structure this is Capstone/client)
  2. Add the following field with your personal API key VITE_WEATHER_API={YOUR-API-KEY}

Database

Django has built in migrations that make it easy to update database changes.

  1. Create a new database:
  • In pgAdmin: In the ObjectExplorer, right click on Databases and choose Create>Database. Give it a name and save the database.
  • or
  • In the terminal shell via psql: $ psql postgres postgres=# CREATE DATABASE <your_database_name>
  1. Navigate to Capstone/api in the terminal.
  2. Make migrations to update database schema $ python manage.py makemigrations
  3. Update database $ python manage.py migrate Now you should have your database schema all set!

Stretch Goals and Thoughts

  • Finish styling
  • Add listener to trigger lottery based on closing date to replace the current button to manually make the lottery happen
  • Enhance trip details page for trip leader to add mushroom species seen on trip (Mushroom component exists in database, currently seeded with 20 species)
  • Build out full CRUD for /mushrooms
  • Add a field to trip model for weather to save the day's weather to display in place of the forecast once the trip came comes (another listener to set the state). Then hide forecast.
  • Add cloud service where users can upload photos to be display on trip detail page, or embed instagram tagged-photos
  • Flag banned users to block from applying field trips for a set period of time (status?='blocked')
  • There might be a bug if there is more than 1 coordinator in database for auto-email? Untested.
  • 100% line coverage for testing. Haven't tested the actual lottery data because it is random-but testing passes for the right number of people chosen per category. Most endpoints and all business logic are tested with Django TestCase class
  • Make lottery weighted. Might need more dummy users and more trips to test.
  • Add chart.js for data visualization (for ? # people applied on trips over time...# species seen)
  • Integrate google calendar
  • Add google sign in functionality
  • Add functionality for forgot password link
  • Stricter password rules?
  • Have user do full registration at sign in for one less click?
  • Integrate into OMS existing website, wildmushrooms.org

Contact and Support

If you have any feedback or concerns, Report Bug Request Feature

License

GNU General Public License v3.0, See license.md for more information

Acknowledgements

Thank you to the Oregon Mycological Society, a volunteer based nonprofit group in Portland Oregon that I am proud to be a member of. I am grateful for the community I am part of with them.


Notes to self

  • in deploy mode: change views-/signin & /signup: secure=False to TRUE once in https
  • may need to rewrite tests now that i've switched from Token header auth to Cookie holding token in browser

About

Myco Matrix: An application where members can register for field trips, connect with others and access resources for safe foraging. Field trip is an automated lottery which chooses participants and sends emails based on status.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published