Giter Site home page Giter Site logo

shootismoke / webapp Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 7.0 15.22 MB

Sh**t! I Smoke web application

Home Page: https://shootismoke.app

License: GNU Affero General Public License v3.0

JavaScript 0.46% TypeScript 45.30% CSS 0.35% Shell 0.74% HTML 53.15%
cigarette pollution climate-change aqi air-quality air-pollution nextjs hacktoberfest

webapp's Introduction

oss image

Know how many cigarettes you smoke based on the pollution of your location.

Github Actions codeclimate spectrum


πŸš€ Website: https://shootismoke.app

πŸ”¨ Build it yourself

Run the following commands:

# Clone this repo
git clone https://github.com/shootismoke/webapp && cd webapp

# Install dependencies.
yarn install

# Fill in secret tokens.
cp .env.example .env.development

# Run the MongoDB daemon locally.
mongod --dbpath /path/to/my/db

# Run the app.
yarn dev

The webapp will launch at http://localhost:3000. It uses Next.js, you can check out their docs.

Note: A Docker images is in the works.

Use your own API tokens

For local development, all API secret tokens should live in the .env.development file for development, as described in the Next.js docs.

Env Variable Description Url Comments
NEXT_PUBLIC_AQICN_TOKEN World Air Quality Index, used in frontend. http://aqicn.org/api Required. You can use the public one in .env.example for development.
NEXT_PUBLIC_SENTRY_API_KEY Sentry bug tracking. https://sentry.io Optional.
NEXT_PUBLIC_AMPLITUDE_API_KEY Amplitude analytics https://amplitude.com Optional. Note: we respect DNT, and we never track PII.
BACKEND_SECRET Secret used in headers between frontend and backend API calls. Please note that CORS is also enabled. n/a Required. Defaults to ssshhh! .
BACKEND_AQICN_TOKEN World Air Quality Index, used in backend. http://aqicn.org/api Required. You can use the public one in .env.example for development.
BACKEND_MAILGUN_API_KEY and BACKEND_MAILGUN_DOMAIN Credentials used for sending emails with Mailgun. https://www.mailgun.com/ Optional. Only used in the script to send emails.
BACKEND_MONGODB_ATLAS_URI Connection string to MongoDB. https://www.mongodb.com/cloud/atlas Required. Defaults to mongodb://localhost/shootismoke.

πŸ™‹ Contribute

If you find a bug, or if you have an idea for this app, please file an issue here. We really appreciate feedback and inputs!

More information on contributing here.

πŸ”¬ Tests

The codebase is covered by different types of tests:

  • Unit tests: located in the src/ folder, next to the tested files, and end with .spec.ts{x}.
  • Backend E2E tests: located in test/e2e/backend.
  • Frontend E2E tests: located in test/cypress, using Cypress.

πŸ“° License

GPL-3.0. See LICENSE file for more information.

⭐ Credits

Created with pride by Marcelo & Amaury.

webapp's People

Contributors

amaury1093 avatar beret avatar dependabot-preview[bot] avatar dependabot[bot] avatar marceloscoelho avatar marvinody avatar mdshamoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

webapp's Issues

Create Dockerfile

The dockerfile could be:

  • based off node (probably the alpine one)
  • add mongodb inside, run it
  • set the correct ENV vars
  • run yarn install, next build, and next start
  • expose the next prot

Web application stucks when city switched

Steps to reproduce:

  1. Open https://shootismoke.app/city
  2. Open any place and see stats there
  3. Select another city

Finally everything stucks and page stopped to respond on any actions

Chrome Version 101.0.4951.64 (Official Build) (x86_64)

I checked Safari and everything works
I wanted to find root cause of this problem, but unfortunately the project doesn't starts in web env locally

Add more unit tests!

@mdshamoon laid out the tooling around unit tests in #69 πŸ’ͺ We need to add more unit tests though.

If you are an external contributor, please free to post a message here and choose a couple of components to add unit tests too.

Change logo size

oh, I forgot to mention another difference between desktop vs. mobile: the logo is slightly bigger (160px width) on desktop then mobile (128px). I think the equivalent is 10rem… do you think you could change this later?

Improve algorithm to find the N closest cities to current location

Summary

The current algorithm for find the N closest cities to the current location is very naive. We could optimize it.

Problem Definition

If you go to the page of a city (example here), there's a ranking section, which shows the 6 closest cities to the current location, and their cigarettes information.

Screenshot 2020-10-25 at 19 27 48

The current algorithm to calculate these closest cities is the following:

This algorithm is not optimal (O(n^2)). It's okay for 1000 cities, but there are surely better way to find the closest N cities around the current location.

Potential Solutions

  • data structures such as r-tree, quad-tree or k-d tree

Add more tests to Cypress 🌲

We use cypress to do e2e testing. We should add more tests.

Some ideas I have:

Components:

  • Search Bar
    • #43 Type inside search bar shows results from Algolia
    • #43 Click on a result takes to /city?lat=...&lng=...
  • Ranking
    • #38 Click on city card goes to /city/{slug}
  • AdSection
    • Can scroll right
  • BlogSection
    • Can scroll
  • Footer
    • #38 Correct link to FAQ

Home page:

  • Test "Use my location" button (might be hard)

City page:

  • Shows cigarettes after some time
  • Click on weekly shows cigs * 7
  • Click on monthly shows cigs * 30

Feel free to pick some tests, or add new ones you can think of!

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.