GithubHelp home page GithubHelp logo

trentprynn / habitapper.com Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 0.0 615 KB

repository for habitapper.com -- feedback loop based habit tracking

Home Page: https://habitapper.com

JavaScript 0.24% TypeScript 97.85% Dockerfile 1.91%
habit-tracking typescript react nextjs prisma vercel postgresql react-bootstrap

habitapper.com's Introduction

HabiTapper.com

Repository for the source code of HabiTapper.com

Under Development

  • Please note that the following project is under active development and is subject to change

Run and develop locally

  1. clone the repository
  2. navigate into it
  3. use docker to spin up a postgres instance for our local application to connect to
    • docker run --name habitapper-db -e POSTGRES_USER=habitapper-user -e POSTGRES_PASSWORD=habitapper-pass -e POSTGRES_DB=habitapper -p 5432:5432 -v habitapper-data:/var/lib/postgresql/data -d postgres
  4. Create a .env file the defines the required runtime variables
    • cp .env.sample .env
  5. run yarn
    • installs dependencies
  6. run yarn prisma migrate dev
    • runs db migrations
  7. run yarn dev
    • runs application with hot reloading enabled

Useful commands during local development

  1. yarn prisma studio
    • runs a local website at localhost:5555 that allows for easy viewing and interaction with the local postgres database the application is using
  2. curl -I --request POST --url "http://localhost:3000/api/tasks/processExpiredHabits" --header "cron_key: local_key"
    • sends a HTTP POST request to the API route that resets habit streaks that were not claimed. In production you should setup automatic pinging of this end point so user habit streaks are reset after not being claimed.
  3. docker run --name pgadmin4 -e [email protected] -e PGADMIN_DEFAULT_PASSWORD=your_password -e PGADMIN_LISTEN_PORT=4000 -p 4000:4000 -v pgadmin_data:/var/lib/pgadmin -d dpage/pgadmin4
    • runs a pgadmin4 container that you can configure to connect to your local (or remote) postgres database, useful if you want to look into your database more deeply then yarn prisma studio offers
      • NOTE: if you're trying to connect to your local database from pgadmin4 running in a container use the host name host.docker.internal instead of localhost during initial server connection configuration

Deployment

  • On a push to master the website will be deployed automatically by Railway
  • The following commands can be used to locally build and run the Dockerfile that will be deployed
    • build image: docker build . -t habitapper.com
    • create container: docker run -d --name habitapper.com --env-file .env -p 3000:3000 habitapper.com
    • stop container: docker stop habitapper.com
    • delete container: docker rm habitapper.com
    • delete image: docker rmi habitapper.com

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.