sduale01 / Calorie-Tracker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Track My Calories

Prerequisites

Before you get started, make sure you have the following software installed on your computer:

Create database and table

Create a new database called prime_app and create a user table:

CREATE TABLE "user" (
    "id" SERIAL PRIMARY KEY,
    "username" VARCHAR (80) UNIQUE NOT NULL,
    "password" VARCHAR (1000) NOT NULL
);

CREATE TABLE "daily-calories" (
    "id" SERIAL PRIMARY KEY,
    "username-calories" INT REFERENCES "user"("id"),
    "date-calories" DATE,
    "total-calories" INTEGER,
    "allotted-calories" INTEGER
);

If you would like to name your database something else, you will need to change calorie_tracker to the name of your new database name in server/modules/pool.js

Development Setup Instructions

  • Run npm install
  • Create a .env file at the root of the project and paste this line into the file:
    SERVER_SESSION_SECRET=superDuperSecret
    
    While you're in your new .env file, take the time to replace superDuperSecret with some long random string like 25POUbVtx6RKVNWszd9ERB9Bb6 to keep your application secure. Here's a site that can help you: https://passwordsgenerator.net/. If you don't do this step, create a secret with less than eight characters, or leave it as superDuperSecret, you will get a warning.
  • Start postgres if not running already by using brew services start postgresql
  • Run npm run server
  • Run npm run client
  • Navigate to localhost:3000

Debugging

To debug, you will need to run the client-side separately from the server. Start the client by running the command npm run client. Start the debugging server by selecting the Debug button.

VSCode Toolbar

Then make sure Launch Program is selected from the dropdown, then click the green play arrow.

VSCode Debug Bar

Lay of the Land

  • src/ contains the React application
  • public/ contains static assets for the client-side
  • build/ after you build the project, contains the transpiled code from src/ and public/ that will be viewed on the production site
  • server/ contains the Express App

This code is also heavily commented. We recommend reading through the comments, getting a lay of the land, and becoming comfortable with how the code works before you start making too many changes. If you're wondering where to start, consider reading through component file comments in the following order:

  • src/components
    • App/App
    • Footer/Footer
    • Nav/Nav
    • AboutPage/AboutPage
    • InfoPage/InfoPage
    • UserPage/UserPage
    • LoginPage/LoginPage
    • RegisterPage/RegisterPage
    • LogOutButton/LogOutButton
    • ProtectedRoute/ProtectedRoute

About


Languages

Language:JavaScript 94.7%Language:CSS 4.2%Language:HTML 1.1%