# Project export: MindTrak

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: Mindtrak, 1 right step towards mental freedom.
- Devpost: https://devpost.com/software/mindtrak
- GitHub: https://github.com/WaterBongo/Mindtrak
- Team: 2 GitHub contributor(s) — Username1unavailable (13 commits), abeyahc (13 commits)

## Devpost submission (written by the team)

### Overview

1 step towards mental freedom Why this project? 63% of students in California has experienced some sort of emotional breakdown 63% of students in California has experienced some sort of emotional breakdown A whopping 45% has reported feeling depressive feelings A whopping 45% has reported feeling depressive feelings At Least 32% of teens have some sort of anxiety disorder At Least 32% of teens have some sort of anxiety disorder Features of Berry n Perry ⚡️ Sophisticated locally ran AI Sophisticated locally ran AI Trained on books of psychology Trained on books of psychology Automatically find optimized times to send you surveys! Automatically find optimized times to send you surveys! Tech Stack Frontend 🖥️ -Reactive Native Backend ⚙️ Python Flask, Ollama, Openchat Python Flask, Ollama, Openchat Impact on Users Reduce anxiety for students Increase Grades of Students Makes the school experience more enjoyable Reduce rates of Depression, Suicide and ETC. Glimpse In the Future More Effective DB: Currently, we only use Jsondb, in the future we can use POSTGRES to improve user data Hardware Integration : Add connection to watches and similar hardwares to

## README (from the GitHub repository)

# MindTrack


## Detected evidence (automated analysis)

Indexed codebase: 15 recognized source files, 46 KB.
- JavaScript (language) — detected in the code
- Python (language) — detected in the code
- React (technology) — detected in the code

## Codebase structure (from repository index)

### Files (22 of 22)

```
.gitattributes
.gitignore
AndroidManifest.xml
App.js
app.json
babel.config.js
backend/chees.py
backend/main.py
backend/replicate.py
backend/request_test.py
data.json
Info.plist
Mindtrak.code-workspace
nav/MainContainer.js
nav/pages/._Create.js
nav/pages/._Home.js
nav/pages/Create.js
nav/pages/Health.js
nav/pages/Home.js
nav/pages/Survey.js
package.json
README.md
```

### Dependencies

- package.json: @babel/core@^7.20.0, @expo-google-fonts/poppins@^0.2.3, @expo/config@^8.5.4, @react-native-community/cli-server-api@^12.3.3, @react-native-community/masked-view@^0.1.11, @react-navigation/bottom-tabs@^6.5.11, @react-navigation/native@^6.1.9, @react-navigation/native-stack@^6.9.17, @react-navigation/stack@^6.3.20, deprecated-react-native-prop-types@^5.0.0, expo@^50.0.2, expo-barcode-scanner@~12.9.2, expo-cli@^6.3.10, expo-file-system@~16.0.4, expo-font@^11.10.2, expo-status-bar@~1.11.1, react@18.2.0, react-native@0.73.2, react-native-camera@^4.2.1, react-native-fs@^2.20.0, react-native-gesture-handler@~2.14.0, react-native-qrcode-svg@^6.2.0, react-native-reanimated@~3.6.0, react-native-safe-area-context@4.8.2, react-native-screens@~3.29.0, react-native-svg@^13.2.0, react-native-vector-icons@^10.0.2, react-navigation@^4.4.4, react-navigation-stack@^2.10.4

### Recent commits (newest first)

- Merge pull request #1 from j-0928/main
- Merge branch 'main' of https://github.com/j-0928/Mindtrakhealth
- update?
- Merge branch 'WaterBongo:main' into main
- lol
- Merge branch 'WaterBongo:main' into main
- edits
- made the funny thing work
- Merge branch 'main' of https://github.com/j-0928/Mindtrakhealth
- scrolling
- Merge branch 'WaterBongo:main' into main
- Merge branch 'health'
- final push XD
- file picker broken
- added health page, import data coming soon
- wewwwwwww
- Merge branch 'main' of https://github.com/WaterBongo/Mindtrak
- made the thingy work lol
- ghjuio
- tested data output

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

### package.json

```
{
  "name": "cruzhacksmentalapp",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo-google-fonts/poppins": "^0.2.3",
    "@expo/config": "^8.5.4",
    "@react-native-community/cli-server-api": "^12.3.3",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/native-stack": "^6.9.17",
    "@react-navigation/stack": "^6.3.20",
    "deprecated-react-native-prop-types": "^5.0.0",
    "expo": "^50.0.2",
    "expo-barcode-scanner": "~12.9.2",
    "expo-cli": "^6.3.10",
    "expo-file-system": "~16.0.4",
    "expo-font": "^11.10.2",
    "expo-status-bar": "~1.11.1",
    "react": "18.2.0",
    "react-native": "0.73.2",
    "react-native-camera": "^4.2.1",
    "react-native-fs": "^2.20.0",
    "react-native-gesture-handler": "~2.14.0",
    "react-native-qrcode-svg": "^6.2.0",
    "react-native-reanimated": "~3.6.0",
    "react-native-safe-area-context": "4.8.2",
    "react-native-screens": "~3.29.0",
    "react-native-svg": "^13.2.0",
    "react-native-vector-icons": "^10.0.2",
    "react-navigation": "^4.4.4",
    "react-navigation-stack": "^2.10.4"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

```

### App.js

```javascript
import * as React from 'react';
import MainContainer from './nav/MainContainer';

function App() {
  return (
    MainContainer()
  );
}

export default App;
```

### backend/main.py

```python
from flask import Flask
from flask import request
import requests
import uuid
import openai
app = Flask(__name__)

@app.route('/')
def hello():
    return {"test":"yapping"}

user ={}
journals = {
}


        
print(journals)


def ask_ollama_engine(context):
    r = requests.post("http://100.111.60.93:11434/api/generate",json={"text":context})
    print(r.json())
    return r.json()

def ask_gpt(question):
    e =openai.ChatCompletion.create(
        model="gpt-4",
        messages=[{"role": "user", "content": f"{question} give positive reinforcment to the user! talk alittle about the current scores"}])
    return e['choices'][0]['message']['content']

@app.route('/examine_results',methods=["POST"])
def examine_results():
    data = request.get_json()
    #sample data {"answers":[0,2,3,4,5]}
    answers = data["answers"]
    total = sum(answers)
    return {"score":total}+5
    #use the score list to return the score and what value it would be



@app.route("/journal_submisson",methods=["POST"])
def journal_submiss():
    #sample data {"text":"Amazing something about life"}
    req_json = request.get_json()
    
    journal_id = "0215-4381-5327-1564"
    stress_help = ask_gpt(req_json['text'])
    journals[journal_id] = {"text":"journal","advice" :stress_help}
    print(stress_help)
    return {"journal_id":journal_id,"advice":stress_help}
    #return the journal id


 
@app.route("/getadvice/<id>")
def get_advice(id):
    if id in journals:
        return {"advice": journals[id]['advice'], "ready": True}
    else:
        return {"ready": False}

@app.route("/get/<id>")
def get_journal(id):
    return journals[id]

@app.route("/getdata")
def get_data():
    return journals
    #return the advice and the journal text
#get ideas
#basically use the chat gpt api tpo get some ideas given the context yea ok




if __name__ == '__main__':
    app.run("0.0.0.0",port=8080)

```

### AndroidManifest.xml

```xml
<uses-permission android:name="android.permission.CAMERA" />
```

### babel.config.js

```javascript
module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
  };
};

```

### backend/request_test.py

```python
import requests
oegpwjegopew = {"text":"Today i was attending a math competition and someone that I thought was my friend started questing my abilities and it really annoyed me that i cried. "}
r = requests.post(" http://127.0.0.1:8080/journal_submisson",json=oegpwjegopew)
print(r.text)
```

### backend/chees.py

```python
"""
curl http://100.111.60.93:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openchat_3.5",
    "messages": [{"role": "user", "content": "You are a large language model named OpenChat. Write a poem to describe yourself"}]
  }'
"""


"""
curl -X POST http://100.111.60.93:11434/api/generate -d '{
  "model": "openchat",
  "prompt":"Why is the sky blue?"
 }'

"""
```

### nav/MainContainer.js

```javascript
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Image } from 'react-native';

import Home from './pages/Home';
import Create from './pages/Create';
import Survey from './pages/Survey';
import Health from './pages/Health';

const homeName = 'Home';
const createName = 'Create';
const surveyName = 'Survey';
const healthName = 'Health';

const Tab = createBottomTabNavigator();

export default function MainContainer() {
    return (
        <NavigationContainer>
            <Tab.Navigator
                initialRouteName={homeName}
                screenOptions={({ route }) => ({
                    headerShown: false, // Add this line to hide the header
                    tabBarIcon: ({ focused }) => {
                        let image;
                        let rn = route.name;

                        if (rn === homeName) {
                            image = focused ? require('./assets/homefocused.png') : require('./assets/home.png');
                        } else if (rn === createName) {
                            image = focused ? require('./assets/createfocused.png') : require('./assets/create.png');
                        }
                        else if (rn === surveyName) {
                            image = focused ? require('./assets/surveyfocused.png') : require('./assets/survey.png');
                        }
                        else if (rn === healthName) {
                            image = focused ? require('./assets/healthfocused.png') : require('./assets/health.png');
                        }

                        return <Image source={image} style={{ width: 50, height: 50 }} />;
                    },
                    tabBarShowLabel: false,
                    tabBarStyle: {
                        backgroundColor: '#689794',
                        borderTopRightRadius: 60,
                        borderTopLeftRadius: 60,
                        borderBottomLeftRadius: 60,
                        borderBottomRightRadius: 60,
                        position: 'absolute',
                        bottom: 10,
                        left: 10,
                        right: 10,
                        height: 60,
                        paddingTop: 10,
                        paddingBottom: 10,
                    }
                })}>
                 
                <Tab.Screen name={homeName} component={Home}/>
                <Tab.Screen name={createName} component={Create}/>
                <Tab.Screen name={surveyName} component={Survey}/>
                <Tab.Screen name={healthName} component={Health}/>

            </Tab.Navigator>
        </NavigationContainer>
    );
}

//#689794
```

### backend/replicate.py

```python
from flask import Flask
from flask import request
import uuid
import openai
app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, World!'

user ={}
journals = {
    "0ce7af1e-a335-4d6a-b2c7-e2c8c61e1a1e": {
        "advice": "Immediate Recommendations:\n1. Maintain Composure: First, remind yourself that failing or being questioned doesn't define your abilities. Everyone has their strengths and weaknesses. Take deep breathes, drink some water, and try to calm your nerves.\n2. Talk About it: If you feel comfortable, talk to someone who can comfort you, such as a teacher, coach, or different friend. They could offer advice or a shoulder to lean on.\n3. Give Space to Your Emotions: It's normal to feel upset, but remember not to let it consume you. Allow yourself some time alone to process your feelings. \n\nFuture Recommendations:\n1. Build Confidence: Confidence will help you handle such situations better. Regular practice especially in math as it is your area, will help you gain more confidence.\n2. Find a Support System: Surround yourself with individuals who motivate you, believe in you and bring positive energy. They will help you stay resilient in challenging situations.\n3. Self Affirmations: Regularly affirm yourself about your abilities. Self-love and self-validation are fundamental in building your confidence and resilience.\n\nStress-Reduction Tips:\n1. Regular Exercise: Regular physical activity helps in managing stress. Find a type of exercise you enjoy, and engage in it regularly.\n2. Meditation and Mindfulness: Practice focusing on your breath and being present in the moment without worrying about the past or future. \n3. Balanced Diet: Good nutrition has a profound effect on your mood and energy. So, eat a healthy balanced diet.\n4. Quality Sleep: Ensure you are getting enough quality sleep. It can improve your mood, productivity, and overall health.\n5. Socializing: Spend time with your loved ones. It can help you to reduce stress significantly.\n6. Hobbies: Engage in activities that make you happy and relaxed.",
        "text": "Today i was attending a math competition and someone that I thought was my friend started questing my abilities and it really annoyed me that. "
    },
    "xxxx-xxxx-xxxx-xxxx": {
        "advice": "somthing yada",
        "text": "Amazing something about life"
    }
}
@app.route("/signup",methods=["POST"])
def fake_register():
    #get json
    data = request.get_json()
    user = data
    return {"status":True}
    {
        "username":"glizzy",
        "password":"passe",
        "name":"",
        "email":"",

    }

def ask_gpt(feeling):
    r = request.post("http://100.111.60.93:11434/api/generate",json={"text":feeling})
    return r.text

@app.route('/examine_results',methods=["POST"])
def examine_results():
    data = request.get_json()
    #sample data {"answers":[0,2,3,4,5]}
    answers = data["answers"]
    total = sum(answers)
    return {"score":total}+5
    #use the score list to return the score and what value it would be



@app.route("/journal_submisson",methods=["POST"])
def journal_submiss():
    data = request.get_json()
    #sample data {"text":"Amazing something about life"}
    journal = data["text"]
    journal_id = str(uuid.uuid4())
    stress_help=  ask_gpt(journal)
    journals[journal_id] = {"text":journal,"advice" :stress_help}
    print(stress_help)
    return {"journal_id":journal_id}
    #return the journal id



@app.route("/getadvice/<id>")
def get_advice(id):
    return journals[id]['advice']

@app.route("/get/<id>")
def get_journal(id):
    return journals[id]

@app.route("/getdata")
def get_data():
    return journals
    #return the advice and the journal text
#get ideas
#basically use the chat gpt api tpo get some ideas given the context yea ok




if __name__ == '__main__':
    app.run("0.0.0.0",port=11434)

```

### nav/pages/._Create.js

```javascript
    Mac OS X            	   2  �     �                                    ATTR;���  �   �                     �     com.apple.provenance   ��^hp��                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            This resource fork intentionally left blank                                                                                                                                                                                                                            ��
```

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