Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

submission-TeamCentennials #34

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 77 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,85 @@
# Gen-Ai-Rush-Buildathon

## Submission Instruction:
1. Fork this repository
2. Create a folder with your Team Name
3. Upload all the code and necessary files in the created folder
4. Upload a **README.md** file in your folder with the below mentioned informations.
5. Generate a Pull Request with your Team Name. (Example: submission-XYZ_team)
# Team Name - The Centennials
#### Problem Statement - Harnessing the Full Potential of Generative AI: Smartphone users face difficulties in effectively utilizing Generative AI for various tasks, hindering their productivity and creativity.
#### Team Leader Email - [email protected]

## README.md must consist of the following information:

#### Team Name -
#### Problem Statement -
#### Team Leader Email -
[PPT-Link](https://www.canva.com/design/DAFqCua3R_o/ckTBh-Gn4nHTESCmuWfe5A/edit?utm_content=DAFqCua3R_o&utm_campaign=designshare&utm_medium=link2&utm_source=sharebutton) <b>All Demo Videos are accessible here</b>

## A Brief of the Prototype:
This section must include UML Diagrams and prototype description
AI Everywhere on Your Smartphone: Our app brings the power of Generative AI to your fingertips, allowing you to access personalized productivity recommendations and mental health support anytime, anywhere.

<p align="center">
<a href="https://firebasestorage.googleapis.com/v0/b/palmapi-b548f.appspot.com/o/ggg.png?alt=media&token=f99af299-5506-44df-b1e2-3cc12912de6d">
<img src="https://firebasestorage.googleapis.com/v0/b/palmapi-b548f.appspot.com/o/ggg.png?alt=media&token=f99af299-5506-44df-b1e2-3cc12912de6d" border="0"></a>
</p>

<p align="center">
<a href="https://firebasestorage.googleapis.com/v0/b/palmapi-b548f.appspot.com/o/ggg2.png?alt=media&token=8416d2a6-fb27-4518-b2d1-ee660562c010">
<img src="https://firebasestorage.googleapis.com/v0/b/palmapi-b548f.appspot.com/o/ggg2.png?alt=media&token=8416d2a6-fb27-4518-b2d1-ee660562c010" border="0">
</a>
</p>


## Tech Stack:
List Down all technologies used to Build the prototype
## Tech Stack

Following latest Android Norms

- Kotlin DSl used (with version catalog .toml file)
- Ime Service in Jetpack Compose
- Accessibility service
- Ktor-Client used.
- Account Manager for Android.
- Node JS for Backend
- Llama Index
- MBTI Personality Prediction Model

### Android
| Name | Description |
| --- | --- |
| [`@compose`](https://developer.android.com/jetpack/compose) | Jetpack Compose |
| [`@materialUI`](https://m3.material.io/) | Material 3 |
| [`@ktor-client`](https://ktor.io/docs/create-client.html) | Ktor CLient |
| [`@navigation-compose`](https://developer.android.com/jetpack/compose/navigation) | Navigation Compose |
| [`@coil`](https://coil-kt.github.io/coil/compose/) | Coil-Compose |
| [`@ksp-room`](https://developer.android.com/build/migrate-to-ksp) | Room Android |
| [`@dagger-hilt`](https://developer.android.com/training/dependency-injection/hilt-android) | Dagger-hilt |
| [`@camera-x`](https://developer.android.com/training/camerax) | Camera-X |
| [`@mlkit`](https://developers.google.com/ml-kit) | MLKit-Google |
| [`@keyboard-compose`](https://kotlinlang.org/api/latest/jvm/stdlib/) | Kotlin-STDLIB |

### Manifest Overview

| Permissions | Required |
| --- | --- |
| Internet | Yes |
| Post Notifications (33+) | Optional |
| Accessibility Service | Optional (Required only when you want to use) |
| Read Accounts | Yes |
| Camera | Optional (For ML-KIT) |
| Record Audio | Optional (For Speech-to-text) |

## Services Used
| Name | Description |
| --- | --- |
| Accessibility | To call AI from Anywhere in Android. |
| IME SERVICE | To use inbuilt AI Keyboard |
| Authenticator | (Required) To manage Accounts on your Device |


## Step-by-Step Code Execution Instructions:
This Section must contain a set of instructions required to clone and run the prototype so that it can be tested and deeply analyzed
- The Following project was build using `AGP 8.1.0`
- Check your Android Studio's AGP.
- If it is `lower` than given AGP follow given steps :-
- - #### Go to gradle/libs.version.toml
- #### In [versions] change value of AGP as per requirement

- Node Js Backend
- run node app.js

## What I Learned:
Write about the biggest learning you had while developing the prototype

## Acknowledgements

- [Kotlin docs](https://kotlinlang.org/)
- [Developer Docs](https://developer.android.com/)


2 changes: 2 additions & 0 deletions The Centennials/Backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
node_modules/
103 changes: 103 additions & 0 deletions The Centennials/Backend/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
const debug = require("debug")("hackthethon:app");
const initDatabase = require("./config/mongo");
const express = require("express");
const app = express();
const personality = require("./data");
const userData = require("./userdata");
const axios = require("axios");
app.use(express.json());

initDatabase();

app.get("/", (req, res) => {
res.send("Server up and running!!");
});

var FormData = require("form-data");
var data = new FormData();
data.append("api_key", process.env.API_KEY);

app.post("/api", async (req, res) => {
console.log(req.body);
data.append("text", req.body.text);
var config = {
method: "post",
url: "https://apis.paralleldots.com/v4/emotion",
headers: {
...data.getHeaders(),
},
data: data,
};
try {
const response = await axios(config);
console.log(response);
if (response.status == 200) {
var emotion = Object.keys(response.data.emotion).reduce((a, b) =>
response.data.emotion[a] > response.data.emotion[b] ? a : b
);
var persona = {
method: "post",
url: process.env.PERSONALITY_API,
data: text,
};
const personalityTrait = axios(persona);
console.log(personality[personalityTrait][emotion]);
userData.create({
userId: req.body.userId,
text: req.body.text,
date: req.body.date,
prediction: emotion,
personality: personalityTrait,
});
res.send(emotion);
} else {
res.send("error");
}
} catch (error) {
res.send("error");
console.log(error);
}
});

app.get("/notify", (req, res) => {
var noti = {
method: "post",
url: "https://fcm.googleapis.com/fcm/send",
headers: {
"Content-Type": "application/json",
Authorization: `key=${process.env.FCM_KEY}`,
},
data: {
to: "/topics/all",
notification: {
title: "Let’s boosts your productivity by goal setting.",
body: "🎯 Set Goals: Define specific, measurable, achievable, relevant, and time-bound goals using our SMART Goal setting technique. \n 🌟 Stay Inspired: Create your personal Vision Board with images and quotes that represent your dreams and aspirations.",
},
data: {
emotion: "Happy",
prompt: "How can I stay inspired and motivated to reach my goals?",
url: "https://www.cim.co.uk/media/10562/content-hub_smart_homepage-banner.jpg?crop=0,0.15743501856612396,0,0.16410257783490428&cropmode=percentage&width=1280&height=380&rnd=133107526210000000",
},
},
};
axios(noti)
.then(function (response) {
console.log(JSON.stringify(response.data));
res.send(response.data);
})
.catch(function (error) {
console.log(error.response);
});
});

const PORT = process.env.PORT || 3000;

app.listen(PORT, () => {
debug(`Server listening on port ${PORT}`);
});

function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
38 changes: 38 additions & 0 deletions The Centennials/Backend/config/mongo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const debug = require("debug")("hackthethon:database");
const mongoose = require("mongoose");
const dotenv = require("dotenv");
dotenv.config();

module.exports = initDatabase = () => {
debug("Initializing database connection...");
let dbUri = process.env.MONGO_URI;
let options = {
autoIndex: false,
useNewUrlParser: true,
useUnifiedTopology: true,
};

/**
* Start MongoDB Connection
*/
mongoose
.connect(dbUri, options)
.catch((error) => debug(`Connection error: ${error}`));

/**
* Listeners on MongoDB Startup
*/
const connection = mongoose.connection;
connection.on("connected", () => {
debug("Connected to database");
});
connection.on("error", (err) => {
debug(`Database error: ${err}`);
});
connection.on("disconnected", () => {
debug("Disconnected from database");
});
connection.on("reconnected", () => {
debug("Reconnected to database");
});
};
49 changes: 49 additions & 0 deletions The Centennials/Backend/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const personalityMoodMapping = {
Openness: {
Happy: "Creative Expression",
Sad: "Self-Exploration",
Bored: "Novelty-seeking",
Excited: "Embrace New Experiences",
Angry: "Art Therapy",
Fearful: "Exposure Therapy",
},
Conscientiousness: {
Happy: "Goal Setting",
Sad: "Problem-Solving",
Bored: "Time Management",
Excited: "Achievement",
Angry: "Anger Management",
Fearful: "Cognitive Restructuring",
},
Extraversion: {
Happy: "Social Interaction",
Sad: "Social Support",
Bored: "Engaging Activities",
Excited: "Energetic Behaviors",
Angry: "Assertiveness Training",
Fearful: "Systematic Desensitization",
},
Agreeableness: {
Happy: "Empathy",
Sad: "Emotional Expression",
Bored: "Exploring Interests",
Excited: "Shared Excitement",
Angry: "Conflict Resolution",
Fearful: "Relaxation Techniques",
},
"Neuroticism (Emotional Stability)": {
Happy: "Positive Coping",
Sad: "Grief Counseling",
Bored: "Mindfulness",
Excited: "Mindful Excitement",
Angry: "Anger Management",
Fearful: "Exposure Therapy",
},
};

// Example usage:
const personalityTrait = "Openness";
const mood = "Happy";
const technique = personalityMoodMapping[personalityTrait][mood];
// console.log(`For ${personalityTrait} personality trait and ${mood} mood, use: ${technique}`);
module.exports = personalityMoodMapping;
Loading