# Project export: Shoebill

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: Cal Hacks 10.0
- Tagline: Concentration, Mental Health and Analytics Tracker for Gaming and ESports
- Devpost: https://devpost.com/software/discovervoice
- GitHub: https://github.com/shendrew/calhack2023
- Video: https://www.youtube.com/embed/qP-S0vukCM4?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 4 GitHub contributor(s) — Cera (15 commits), shendrew (14 commits), FowlFarmer (7 commits), Vincent Chung (2 commits)

## Devpost submission (written by the team)

### Inspiration

Growing up, our team members struggled with gaming addictions and how games affected our mind. Solutions that could help detect, document, and provide solutions for how games affected our mental health were poorly designed and few and far between. We Created this app as an aide for our own struggles, and with the hope that it could help others who share the same struggles as we did. Building on top of that though, we also wanted to increase our performance in competitive games and taste more of that sweet, sweet victory, Managing your temper and mood is a large contributor to competitive game performance.

### What it does

Shoebill is a web application that tracks, detects, documents and provides solutions to gaming addiction. It's analytics are able to track your mental stability, mood and emotions while you game. It can help you discover trends in your temperament and learn what kind of gamer you are. Using Shoebill, we can learn what tilts you the most — and optimize and grow as a competitive gamer. How is it built React.js is the main framework on which we built our web application, supported by a Flask Python backend. We integrated Hume’s API to detect emotions related to game addiction and rage behaviour. We also tried integrating the Zepp watch to get user's health data for analysis.

### Challenges we ran into

Navigating the React.js framework was a challenge for us as most of our team was unfamiliar with the framework. Integrating Flask with React was also difficult, as these two frameworks are implemented fairly differently when together versus when separately implemented. More, initially, we experimented with pure HTML and CSS for the frontend, but then realized that React JS files would make the web app more dynamic and easier to integrate, so we had to switch halfway. We also had to pivot to Vite, since we ran into root bugs with the deprecated Create React App framework we initially used. Also, navigating through the APIs were more difficult than usual due to unclear documentation. Notably, since there are so many hackers in the same venue, the provided wifi speed was exceptionally slow which decelerated our progress.

### Accomplishments we're proud of

Despite the challenges, our APIs have seamlessly integrated and in the last few hours we were able to piece together the backend and frontend - that were once only working separately - and make it a functioning web app. Our logo is also sleek and minimalistic, reflecting the professional nature of Shoebill. Equally important, we've formed stronger bonds with our teammates through collaboration and support, reaching for success together.

### What we learned

We were able to learn how React.js and Flask worked together, and understand the fundamental functionalities of Git. We also learned the importance of optimizing our ideation phase. We learned that frequent contributions to GitHub is vital, in that it is a fundamental aspect of project management and version control. Furthermore, we understand the significance of collaboration among team members, especially constant and effective communication. Lastly, we gained a deeper understanding of API integration.

### What's next

Moving forward, we wish to integrate 3D graph visualizations with dynamic elements. We want to evolve from the hackathon project into a fully-fledged product, involving: the incorporation of user profiles, an integrated Discord bot, and extracting more health data from the Zepp watch (such as blood oxygen levels).

## 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: 25 recognized source files, 33 KB.
- CSS (language) — detected in the code
- Flask (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- Python (language) — detected in the code
- React (technology) — detected in the code
- SQL (language) — detected in the code
- Node.js (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (30 of 30)

```
.eslintrc.cjs
.gitignore
backend/.flaskenv.example
backend/base.py
backend/sound.py
backend/stats.sql
backend/test.py
index.html
package.json
README.md
requirements.txt
src/App.css
src/App.jsx
src/components/Frame.jsx
src/components/heartrate.jsx
src/components/line.jsx
src/components/navbar.jsx
src/components/NavbarElements.jsx
src/components/spider.jsx
src/components/zepposdata.jsx
src/index.css
src/main.jsx
src/pages/Graph.jsx
src/pages/Profile.jsx
src/pages/Stats.jsx
src/pages/Support.jsx
src/public/App.css
state.sql
stats.sql
vite.config.js
```

### Dependencies

- package.json: @testing-library/jest-dom@^5.17.0, @testing-library/react@^13.4.0, @testing-library/user-event@^13.5.0, @types/react@^18.2.15, @types/react@^18.2.15, @types/react-dom@^18.2.7, @types/react-dom@^18.2.7, @vitejs/plugin-react-swc@^3.3.2, @vitejs/plugin-react-swc@^3.3.2, axios@^1.6.0, eslint@^8.45.0, eslint@^8.45.0, eslint-plugin-react@^7.32.2, eslint-plugin-react@^7.32.2, eslint-plugin-react-hooks@^4.6.0, eslint-plugin-react-hooks@^4.6.0, eslint-plugin-react-refresh@^0.4.3, eslint-plugin-react-refresh@^0.4.3, react@^18.2.0, react-dom@^18.2.0, react-icons@^4.11.0, react-router-dom@^6.17.0, react-scripts@5.0.1, styled-components@^6.1.0, vite@^4.4.5, vite@^4.4.5, web-vitals@^2.1.4
- requirements.txt: flask@==3.0.0, hume[stream], opencv-contrib-python-headless, opencv-python-headless, python-dotenv@==1.0.0, scipy, sounddevice

### Recent commits (newest first)

- added graph grid lines
- updated graphs
- Merge branch 'main' of https://github.com/shendrew/calhack2023
- update spider graph
- prettified again
- interactive navbar!
- prettier again
- made prettier
- css prettier
- yeet
- implemented spider.jsx and line.jsx into stats page
- Merge branch 'main' of https://github.com/shendrew/calhack2023
- formatted stats page better
- Merge branch 'main' of https://github.com/shendrew/calhack2023
- heartrate
- deleted uneeded files
- got frame to work in app.jsx
- hhj
- hvjcgb
- merged frontend and backend

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

### requirements.txt

```
flask==3.0.0
python-dotenv==1.0.0
hume[stream]
opencv-python-headless
opencv-contrib-python-headless
scipy
sounddevice
```

### package.json

```
{
  "name": "calhack2023",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "proxy": "http://127.0.0.1:5000",
  "scripts": {
    "dev": "vite",
    "build": "react-scripts build",
    "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview",
    "start": "react-scripts start",
    "start-backend": "cd backend && flask run --no-debugger",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/react": "^18.2.15",
    "@types/react-dom": "^18.2.7",
    "@vitejs/plugin-react-swc": "^3.3.2",
    "axios": "^1.6.0",
    "eslint": "^8.45.0",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^4.11.0",
    "react-router-dom": "^6.17.0",
    "react-scripts": "5.0.1",
    "styled-components": "^6.1.0",
    "vite": "^4.4.5",
    "web-vitals": "^2.1.4"
  },
  "devDependencies": {
    "@types/react": "^18.2.15",
    "@types/react-dom": "^18.2.7",
    "@vitejs/plugin-react-swc": "^3.3.2",
    "eslint": "^8.45.0",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.3",
    "vite": "^4.4.5"
  },
  "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/main.jsx

```javascript
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
)

```

### src/App.jsx

```javascript
import './App.css';
import './index.css';
// import ReactDOM  from 'react-dom';
// import {render} from 'react-dom';
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
// import Frame from "./components/Frame"
import Graph from "./pages/Graph"

import Navbar from './components/navbar';
import Profile from "./pages/Profile";
import Stats from "./pages/Stats";
import Support from "./pages/Support";

function App() {
  return (
    <Router>
      <Navbar />
      <Routes> 
        <Route path="/" exact element={<Profile/>} />
        <Route path="/stats" element={<Stats/>} />
        <Route path="/support" element={<Support/>}/>
      </Routes>
      <div>
        <Graph />
    </div>
    </Router>
  );
}
export default App
```

### vite.config.js

```javascript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
})

```

### state.sql

```sql
CREATE TABLE users (
    username TEXT NOT NULL,
    password TEXT NOT NULL,
    userID INTEGER,
    PRIMARY KEY (userid)
);

CREATE TABLE timestats (
    userID INTEGER,
    startTime TIMESTAMP,
    endTime TIMESTAMP,
    avgFluc TIME, 
    duration TIME
);
```

### stats.sql

```sql
CREATE TABLE users (
    username TEXT NOT NULL,
    password TEXT NOT NULL,
    userID INTEGER,
    PRIMARY KEY (userid)
);

CREATE TABLE timestats (
    userID INTEGER,
    startTime TIMESTAMP,
    endTime TIMESTAMP,
    avgFluc TIME, 
    duration TIME
);
```

### index.html

```html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Shoebill</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.jsx"></script>
  </body>
</html>

```

### backend/stats.sql

```sql
CREATE TABLE users (
    username TEXT NOT NULL,
    password TEXT NOT NULL,
    userID INTEGER,
    PRIMARY KEY (userid)
);

CREATE TABLE timestats (
    userID INTEGER,
    startTime TIMESTAMP,
    endTime TIMESTAMP,
    avgFluc TIME, 
    duration TIME
);
```

### backend/test.py

```python
import asyncio
from hume import HumeStreamClient, StreamSocket
from hume.models.config import FaceConfig
from hume.models.config import LanguageConfig
import os

import cv2
camera = cv2.VideoCapture(0)
ret, frame = camera.read()
# Optionally encode the frame into a more readable format
# ret, encoded = cv2.imencode(".jpg", frame)

os.chdir(r'C:\Users\sandrew\Code\flaskHack\calhack2023\backend') 
cv2.imwrite('image.jpg', frame)

async def main():
    # client = HumeStreamClient(os.getenv('API_KEY'))
    config = FaceConfig(identify_faces=True)
    async with client.connect([config]) as socket:
        result = await socket.send_file('image.jpg')
        response_body = result["face"]["predictions"][0]["emotions"]
        print(response_body)        

asyncio.run(main())
```

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