Skip to content

bamlab/estimator

Repository files navigation

This is a Next.js project bootstrapped with create-next-app.

Getting Started

Installing the project

  • The project uses React 17 with Next.JS so make sure to have the current version of Node installed (18 when those lines are written). To do that you can use fnm with the following command : fnm install 18; fnm use 18;

  • You will need to setup a local environment with a postgresql database.

    • First, let's install Postgresql if you haven't installed it yet.
    • (Recommended) Install a postgreSQL client DB Lens or Postico
    • Add psql to your path by adding this line to your .zshrc or .bashrc (or whatever is your terminal config file) : export PATH=$PATH:/Library/PostgreSQL/14/bin(don't forget to change the 14 if the version of postgres you installed is not 14). If you have installed the PostgreSQL.app you should export export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/14/bin instead.
    • Either use source .zshrc or quit and relaunch your terminal
    • Now, you should create the Database. Choose one of the following methods.
    • Method 1 :
      • Connect with the postgres user by entering sudo -i -u postgresin your terminal.
      • From there, enter createdb estimator and enter the password you gave when you installed postgres (the one associated with the postgres user on MacOS)
      • Check that the estimator db exists (you can enter psql and then \l or use your db client)
    • Method 2 :
      • Login to psql using the postgres user : sudo psql -U postgres
      • From there, create the database by entering CREATE DATABASE estimator; (Do not forget the semicolon)
      • Check that the estimator db exists : enter \l in psql or use your db client.

  • Cool! We have a database setup but we need to tell the app how to connect to the database.

    • Please copy the .env.template file and rename it to .env
    • You'll need to update the DATABASE_URL= line with "postgresql://postgres:{your_postgres_password}@localhost/estimator" (don't worry, the .env file is ignored by git so your password will not be sent to git)

  • Now we need to copy the app schema to the estimator database

    • Open up a terminal in VS Code at the root of the project
    • Run yarn or npm install (from there I'm gonna assume that you're using yarn)
    • Run yarn prisma:generate
    • Run yarn prisma:push(Careful! Be sure that you're .env is setup to use the local database or you will erase the production database)

  • Okay we now have a database with the app schema, so let's run the app !

    • Run yarn dev and that's it!

Open http://localhost:3000 with your browser to see the result.

Using NextJS

To begin with, you can watch this video from Fireship that gives an overview of what NextJS is, what problem it solves and how it works in a nutshell. The project only uses the SSR strategy that builds pages at request time. So you'll see a lot of getServerSideProps being used.

Here are a few docs you may want to visit when you're stuck (or right now to discover NextJS):

Iterating from there :

  • Here is the project's notion, please ask one of the devs to give you access.
  • Here are the mock-ups, you also need a permission to access that
  • For contribution, please read the contribution guidelines.
  • Time to do your first ticket! Good luck and thank you for your contribution on this project.

NextJS autogenerated ReadME

API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.js.

The pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.