# Project export: The Food Amendment

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: CruzHacks 2024
- Tagline: Losing weight can be tough, but it doesn't to be that way. The Food Amendment provides support for those struggling to find personal solutions in their weight loss journey.
- Devpost: https://devpost.com/software/frc-sucks-bye-bye-254-rahhhhhhhhhhhhhhhhhhhhhhhhhhhhh
- GitHub: https://github.com/nishantj2006/excersisehackathon
- Demo: https://thefoodamendment.us/
- Video: https://www.youtube.com/embed/OpdpGmDxQpU?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 3 GitHub contributor(s) — Brandon (41 commits), Benson Tran (21 commits), nishantj2006 (10 commits)

## Devpost submission (written by the team)

### Inspiration

During our lives, we have seen people struggling to lose weight and instead just accepted being overweight. We hate to see people unable to achieve their goals, so we hope to provide them with a new solution to their issues.

### What it does

A user fills out information regarding their personal details and their goals. Our program takes in these details and creates a recommended diet for them.

### How we built it

We build this project using React in Visual Studio Code. We also implemented the OpenAI and FireBase APIs in order to build this project.

### Challenges we ran into

While attempting in implement auth0, we discovered the fact that auth0 is very inconvenient to use. Through this, we decided to go all in with firebase for our backend. During the implementation of our project, we also ran into major problem with the OpenAI API as they required money. We tried to debug this issue, which took 4 hours, and ended up having to pay this fee anyways.

### Accomplishments we're proud of

We are happy to have gotten our AI model and database set up so we are able to store users data instead of them having to input their information every time they log in. This allows for them to have a personalized experience and does not require them to redundantly fill out the same information.

### What we learned

We learned that when using working with different API's, things break. This is fine, and a part of life and learning experience. It is important to learn to get past your issues. Hang your head high and move onwards!

### What's next

We will hope to continue developing our own model, trained on user data and thus will be more accurate. We also hope to integrate an exercise regiment to our program.

## README (from the GitHub repository)

# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)


## Detected evidence (automated analysis)

Indexed codebase: 21 recognized source files, 37 KB.
- CSS (language) — detected in the code
- Firebase (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- OpenAI (technology) — detected in the code
- React (technology) — detected in the code

## Codebase structure (from repository index)

### Files (26 of 26)

```
.gitignore
package.json
public/index.html
public/manifest.json
public/robots.txt
README.md
src/components/App.test.js
src/components/CreateGoal.js
src/components/Dashboard.js
src/components/Home.js
src/components/Login.js
src/components/LogMeals.js
src/components/ReportProgress.js
src/firebase-config.js
src/index.css
src/index.js
src/login.js
src/logout.js
src/openai.js
src/Pages/App.css
src/Pages/App.js
src/Pages/final.txt
src/Pages/login.css
src/profile.js
src/reportWebVitals.js
src/setupTests.js
```

### Dependencies

- package.json: @auth0/auth0-react@^2.2.4, @testing-library/jest-dom@^5.17.0, @testing-library/react@^13.4.0, @testing-library/user-event@^13.5.0, axios@^1.6.5, firebase@^9.23.0, openai@^4.24.7, react@^18.2.0, react-dom@^18.2.0, react-router-dom@^6.21.3, react-scripts@5.0.1, web-vitals@^2.1.4

### Recent commits (newest first)

- L 254 LLLLLLLLLL
- Merge branch 'main' of https://github.com/nishantj2006/excersisehackathon
- adf
- frc-sucks-bye-bye-254-rahhhhhhhhhhhhhhhhhhhhhhhhhh
- frc-sucks-bye-bye-254-rahhhhhhhhhhhhhhhhhhhhhhhhhh
- Revert "Merge branch 'main' of https://github.com/nishantj2006/excersisehackathon"
- Merge branch 'main' of https://github.com/nishantj2006/excersisehackathon
- frc-sucks-bye-bye-254-rahhhhhhhhhhhhhhhhhhhhhhhhhh
- Merge branch 'main' of https://github.com/nishantj2006/excersisehackathon
- Merge branch 'main' of https://github.com/nishantj2006/excersisehackathon
- Update CreateGoal.js
- Fixes to hide openapikey
- NAVBAR RAJDLKASDJKFASJDHGAIFAHJSPFIAWJRFUDAJLKASIH
- Added CSS
- Merge remote-tracking branch 'refs/remotes/origin/main'
- css is fun
- FIxed dayCounter
- Added thing for text
- fixed the import bugs
- Fixed import errors

## Key source files (fetched from GitHub, selected and truncated for size)

### package.json

```
{
  "name": "excersisehackathon",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@auth0/auth0-react": "^2.2.4",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.6.5",
    "firebase": "^9.23.0",
    "openai": "^4.24.7",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.21.3",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

```

### src/index.js

```javascript
import React from 'react';
import { createRoot } from 'react-dom/client';
import { Auth0Provider } from '@auth0/auth0-react';
import App from './Pages/App';

const root = createRoot(document.getElementById('root'));

root.render(
<Auth0Provider
    domain="dev-a6tpzpv7rao73mlp.us.auth0.com"
    clientId="8pgrQ9VQTlQKaKkSn4cQkg9HJ98lumnS"
    authorizationParams={{
      redirect_uri: "http://localhost:3000/"
    }}
  >
    <App />
  </Auth0Provider>,
);
```

### src/Pages/App.js

```javascript

import './App.css';
import LoginButton from '../login';
import LogoutButton from '../logout';
import Profile from '../profile';
import { useState } from 'react';
import { auth } from '../firebase-config';
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";

import Home from "../components/Home";
import CreateGoal from "../components/CreateGoal"
import Dashboard from '../components/Dashboard';
import ReportProgress from "../components/ReportProgress"
import LogMeals from '../components/LogMeals';
import { signOut } from 'firebase/auth';
import Login from '../components/Login';

function App() {
  let loggedIn = false;
  const [createdGoal, setCreatedGoal] = useState(false);
  const [isAuth, setIsAuth] = useState(localStorage.getItem("isAuth"));
  const signUserOut = () => {
    signOut(auth).then(() => {
      localStorage.clear();
      setIsAuth(false);
      window.location.pathname = "/login";
      loggedIn = false;
    });
  };
  return (
    <div className="App">
      {/*Routes*/}
      <Router>
        <nav class="navbar">
          <h1 class="logoText">The Food Amendment</h1>
          {!isAuth ? (
            // <Link to="/login"> Login </Link>
<Link></Link>
            ) : (
            <>
              <div class="dashboardLink"><Link to="/dashboard" class="dashboardLink"> Dashboard </Link></div>

              <div class="createLink"><Link to="/creategoal" className='createLink'> Create Goal </Link></div>
              {/* <Link to="/reportprogress"> Report Progress </Link> */}
              <button onClick={signUserOut}> Log Out</button>
            </>
          )}
        </nav>
        <Routes>
          <Route path="/" element={<Home />} />
          <Route path="/dashboard" element={<Dashboard/>} />
          <Route path="/creategoal" element={<CreateGoal createdGoal={setCreatedGoal}/>} />
          <Route path="/reportprogress" element={<ReportProgress />} />
          <Route path="/logmeal" element={<LogMeals />} />
          <Route path="/login" element={<Login setIsAuth={setIsAuth} createdGoal={createdGoal}/>} />
        </Routes>
      </Router>
    </div>
  );
}

export default App;

```

### src/openai.js

```javascript
const OPENAI_API_KEY = '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';
export default OPENAI_API_KEY;
```

### src/setupTests.js

```javascript
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

```

### src/login.js

```javascript
import { useAuth0 } from "@auth0/auth0-react";
import React from "react";

const LoginButton = () => {
  const { loginWithRedirect } = useAuth0();

  return <button onClick={() => loginWithRedirect()}>Log In</button>;
};

export default LoginButton;
```

### src/logout.js

```javascript
import { useAuth0 } from "@auth0/auth0-react";
import React from "react";

const LogoutButton = () => {
  const { logout } = useAuth0();

  return (
    <button onClick={() => logout({ logoutParams: { returnTo: "http://localhost:3000" } })}>
      Log Out
    </button>
  );
};

export default LogoutButton;
```

### src/reportWebVitals.js

```javascript
const reportWebVitals = onPerfEntry => {
  if (onPerfEntry && onPerfEntry instanceof Function) {
    import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
      getCLS(onPerfEntry);
      getFID(onPerfEntry);
      getFCP(onPerfEntry);
      getLCP(onPerfEntry);
      getTTFB(onPerfEntry);
    });
  }
};

export default reportWebVitals;

```

### src/index.css

```css
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
    monospace;
}

```

### src/profile.js

```javascript
import { useAuth0 } from "@auth0/auth0-react";
import React, { useEffect, useState } from "react";

const Profile = () => {
  const { user, isAuthenticated, isLoading } = useAuth0();
  if (isLoading) {
    return <div>Loading ...</div>;
  }
  if (isAuthenticated){
    console.log(String(user.email))
  }
  return (
    isAuthenticated && (
      <div>
        <img src={user.picture} alt={user.name} />
        <h2>{user.name}</h2>
        <p>{user.email}</p>
      </div>
    )
  );
}


export default Profile;
```

[11 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]