Skip to content

Zenieverse/MindConnect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

MindConnect

MindConnect is a mobile and web-based application that leverages AWS generative AI services (Amazon Bedrock and Amazon Q) and 5G/IoT connectivity to deliver real-time, personalized mental health support.

MindConnect Open Source Codebase

Repository Structure

MindConnect/ ├── frontend/ # React-based UI │ ├── src/ │ │ ├── components/ │ │ │ ├── Dashboard.js # Displays user metrics and AI recommendations │ │ │ ├── Chatbot.js # Amazon Q-powered conversational interface │ │ │ ├── Settings.js # User preferences and emergency contacts │ │ ├── App.js # Main app component with slogan │ │ ├── index.js # Entry point │ │ ├── styles/tailwind.css # Tailwind CSS for styling │ ├── public/ │ │ ├── index.html # HTML template │ ├── package.json # Dependencies ├── backend/ │ ├── lambda/ │ │ ├── processData.js # Lambda function for IoT data processing │ │ ├── generateResponse.js # Lambda function for AI response generation │ ├── serverless.yml # Serverless framework config for AWS ├── iot/ │ ├── deviceSimulator.py # Python script to simulate IoT device data ├── README.md # Setup and deployment instructions ├── LICENSE # MIT License for open source

Sample Code: frontend/src/App.js

import React from 'react'; import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import Dashboard from './components/Dashboard'; import Chatbot from './components/Chatbot'; import Settings from './components/Settings'; import './styles/tailwind.css';

function App() { return (

MindConnect

Empowering Minds, Connecting Care

<Route path="/" element={} /> <Route path="/chat" element={} /> <Route path="/settings" element={} />
); } export default App;

Sample Code: frontend/src/components/Dashboard.js

import React, { useState, useEffect } from 'react'; import AWS from 'aws-sdk';

function Dashboard() { const [metrics, setMetrics] = useState({ hrv: 0, activity: 'N/A', recommendation: '' });

useEffect(() => { AWS.config.update({ region: 'us-east-1', credentials: new AWS.CognitoIdentityCredentials({ IdentityPoolId: 'us-east-1:YOUR_COGNITO_POOL_ID' }) }); const dynamodb = new AWS.DynamoDB.DocumentClient(); dynamodb.get({ TableName: 'MindConnectData', Key: { userId: 'user123', timestamp: Math.floor(Date.now() / 1000) } }, (err, data) => { if (data.Item) setMetrics(data.Item); }); }, []);

return (

Your Health Metrics

Heart Rate Variability: {metrics.hrv}

Activity: {metrics.activity}

Recommendation: {metrics.recommendation}

); } export default Dashboard;

Sample Code: frontend/src/components/Chatbot.js

import React, { useState } from 'react'; import AWS from 'aws-sdk';

function Chatbot() { const [message, setMessage] = useState(''); const [response, setResponse] = useState('');

const sendMessage = async () => { const bedrock = new AWS.BedrockRuntime({ region: 'us-east-1' }); const params = { modelId: 'anthropic.claude-v2', contentType: 'application/json', accept: 'application/json', body: JSON.stringify({ prompt: You are a supportive mental health assistant. Respond empathetically to: "${message}", max_tokens_to_sample: 300 }) }; const result = await bedrock.invokeModel(params).promise(); setResponse(JSON.parse(result.body).completion); };

return ( <div动漫

System: Chatbot.js (continued)

<div className="p-6">
  <h2 className="text-xl font-semibold mb-4">Chat with MindConnect</h2>
  <textarea
    className="w-full p-2 border rounded"
    value={message}
    onChange={(e) => setMessage(e.target.value)}
    placeholder="How are you feeling today?"
  />
  <button
    className="mt-2 bg-blue-600 text-white px-4 py-2 rounded"
    onClick={sendMessage}
  >
    Send
  </button>
  <p className="mt-4">{response}</p>
</div>

); } export default Chatbot;

Sample Code: frontend/src/components/Settings.js

import React, { useState } from 'react';

function Settings() { const [language, setLanguage] = useState('en'); const [emergencyContact, setEmergencyContact] = useState('');

const saveSettings = () => { // Implement settings save logic (e.g., API call to DynamoDB) alert(Settings saved: Language=${language}, Contact=${emergencyContact}); };

return (

Settings

Language <select className="w-full p-2 border rounded" value={language} onChange={(e) => setLanguage(e.target.value)} > English Spanish French
Emergency Contact <input className="w-full p-2 border rounded" value={emergencyContact} onChange={(e) => setEmergencyContact(e.target.value)} placeholder="Enter phone number" />
Save
); } export default Settings;

Sample Code: backend/lambda/processData.js

exports.handler = async (event) => { const AWS = require('aws-sdk'); const bedrock = new AWS.BedrockRuntime({ region: 'us-east-1' });

const iotData = JSON.parse(event.Records[0].Sns.Message); const { userId, hrv, activity } = iotData;

// Analyze data with Bedrock const params = { modelId: 'anthropic.claude-v2', contentType: 'application/json', accept: 'application/json', body: JSON.stringify({ prompt: Analyze HRV: ${hrv}, Activity: ${activity}. Suggest mental health intervention., max_tokens_to_sample: 300 }) };

const response = await bedrock.invokeModel(params).promise(); const recommendation = JSON.parse(response.body).completion;

// Store in DynamoDB const dynamodb = new AWS.DynamoDB.DocumentClient(); await dynamodb.put({ TableName: 'MindConnectData', Item: { userId, timestamp: Math.floor(Date.now() / 1000), hrv, activity, recommendation } }).promise();

return { statusCode: 200, body: JSON.stringify({ recommendation }) }; };

Sample Code: backend/lambda/generateResponse.js

exports.handler = async (event) => { const AWS = require('aws-sdk'); const bedrock = new AWS.BedrockRuntime({ region: 'us-east-1' });

const { message } = JSON.parse(event.body);

const params = { modelId: 'anthropic.claude-v2', contentType: 'application/json', accept: 'application/json', body: JSON.stringify({ prompt: You are a supportive mental health assistant. Respond empathetically to: "${message}", max_tokens_to_sample: 300 }) };

const response = await bedrock.invokeModel(params).promise(); const reply = JSON.parse(response.body).completion;

return { statusCode: 200, body: JSON.stringify({ reply }) }; };

Sample Code: iot/deviceSimulator.py

import json import time import random import boto3

client = boto3.client('iot-data', region_name='us-east-1')

def simulate_device(user_id): while True: data = { 'userId': user_id, 'hrv': random.uniform(50, 100), 'activity': random.choice(['resting', 'active', 'sleeping']) } client.publish( topic='mindconnect/data', qos=1, payload=json.dumps(data) ) time.sleep(5)

if name == 'main': simulate_device('user123')

Sample Code: backend/serverless.yml

service: mindconnect-backend frameworkVersion: '3'

provider: name: aws runtime: nodejs14.x region: us-east-1 iam: role: statements: - Effect: Allow Action: - dynamodb:PutItem - dynamodb:GetItem - bedrock:InvokeModel Resource: '*'

functions: processData: handler: lambda/processData.handler events: - sns: arn: arn:aws:sns:us-east-1:${self:provider.environment.ACCOUNT_ID}:MindConnectIoTTopic topicName: MindConnectIoTTopic generateResponse: handler: lambda/generateResponse.handler events: - http: path: /chat method: post cors: true

resources: Resources: MindConnectDataTable: Type: AWS::DynamoDB::Table Properties: TableName: MindConnectData AttributeDefinitions: - AttributeName: userId AttributeType: S - AttributeName: timestamp AttributeType: N KeySchema: - AttributeName: userId KeyType: HASH - AttributeName: timestamp KeyType: RANGE BillingMode: PAY_PER_REQUEST

README.md

MindConnect

A mental health support app using AWS Bedrock, Amazon Q, and 5G/IoT.

Slogan

Empowering Minds, Connecting Care

Setup

  1. Clone the repository: git clone https://github.com/<your-username>/MindConnect.git
  2. Install frontend dependencies: cd frontend && npm install
  3. Deploy backend: cd backend && serverless deploy
  4. Configure AWS IoT Core and DynamoDB
  5. Run IoT simulator: python iot/deviceSimulator.py
  6. Start frontend: cd frontend && npm start

Requirements

  • AWS account with Bedrock, IoT Core, and DynamoDB access
  • Node.js, Python 3.x, Serverless Framework
  • 5G-enabled IoT device or simulator

License

MIT

LICENSE

MIT License

Copyright (c) 2025 [Your Name]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MindConnect Application Codebase

Repository Structure

MindConnect/ ├── frontend/ # React-based UI │ ├── src/ │ │ ├── components/ │ │ │ ├── Dashboard.js # Displays user metrics and AI recommendations │ │ │ ├── Chatbot.js # Amazon Q-powered conversational interface │ │ │ ├── Settings.js # User preferences and emergency contacts │ │ ├── App.js # Main app component │ │ ├── index.js # Entry point │ │ ├── styles/tailwind.css # Tailwind CSS for styling │ ├── public/ │ │ ├── index.html # HTML template │ ├── package.json # Dependencies ├── backend/ │ ├── lambda/ │ │ ├── processData.js # Lambda function for IoT data processing │ │ ├── generateResponse.js # Lambda function for AI response generation │ ├── serverless.yml # Serverless framework config for AWS ├── iot/ │ ├── deviceSimulator.py # Python script to simulate IoT device data ├── README.md # Setup and deployment instructions ├── LICENSE # MIT License for open source

Sample Code: frontend/src/App.js

import React, { useState, useEffect } from 'react'; import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import Dashboard from './components/Dashboard'; import Chatbot from './components/Chatbot'; import Settings from './components/Settings'; import './styles/tailwind.css';

function App() { return (

MindConnect

<Route path="/" element={} /> <Route path="/chat" element={} /> <Route path="/settings" element={} />
); } export default App;

Sample Code: backend/lambda/processData.js

exports.handler = async (event) => { const AWS = require('aws-sdk'); const bedrock = new AWS.BedrockRuntime({ region: 'us-east-1' });

const iotData = JSON.parse(event.Records[0].Sns.Message); const { hrv, activity } = iotData;

// Analyze data with Bedrock const params = { modelId: 'anthropic.claude-v2', contentType: 'application/json', accept: 'application/json', body: JSON.stringify({ prompt: Analyze HRV: ${hrv}, Activity: ${activity}. Suggest mental health intervention., max_tokens_to_sample: 300 }) };

const response = await bedrock.invokeModel(params).promise(); const recommendation = JSON.parse(response.body).completion;

// Store in DynamoDB const dynamodb = new AWS.DynamoDB.DocumentClient(); await dynamodb.put({ TableName: 'MindConnectData', Item: { userId: iotData.userId, timestamp: Date.now(), recommendation } }).promise();

return { statusCode: 200, body: JSON.stringify({ recommendation }) }; };

Sample Code: iot/deviceSimulator.py

import json import time import random import boto3

client = boto3.client('iot-data', region_name='us-east-1')

def simulate_device(user_id): while True: data = { 'userId': user_id, 'hrv': random.uniform(50, 100), 'activity': random.choice(['resting', 'active', 'sleeping']) } client.publish( topic='mindconnect/data', qos=1, payload=json.dumps(data) ) time.sleep(5)

if name == 'main': simulate_device('user123')

README.md

MindConnect

A mental health support app using AWS Bedrock, Amazon Q, and 5G/IoT.

Setup

  1. Clone the repository.
  2. Install frontend dependencies: cd frontend && npm install.
  3. Deploy backend: cd backend && serverless deploy.
  4. Configure AWS IoT Core and DynamoDB.
  5. Run IoT simulator: python iot/deviceSimulator.py.
  6. Start frontend: cd frontend && npm start.

Requirements

  • AWS Account with Bedrock and IoT Core access.
  • Node.js, Python 3.x, Serverless Framework.
  • 5G-enabled IoT device or simulator.

License

MIT

About

MindConnect is a mobile and web-based application that leverages AWS generative AI services (Amazon Bedrock and Amazon Q) and 5G/IoT connectivity to deliver real-time, personalized mental health support.

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors