# Project export: MemoryLane

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: TreeHacks 2024
- Tagline: Brighten your golden years with MemoryLane! Activate the mind, connect hearts, and revive cherished memories—all with just a tap. Bond over shared stories and sharpen your mind, effortlessly.
- Devpost: https://devpost.com/software/memorylane-5aon4r
- GitHub: https://github.com/gracelliu/TreeHacksX
- Video: https://www.youtube.com/embed/4ZuY4dxeFHg?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Result: winner (InterSystems: Best Use of GenAI using InterSystems IRIS Vector Search ($2k Cash [1st] & $1.5k Cash [2nd] & $1k Cash [3rd]))
- Team: 4 GitHub contributor(s) — Grace Liu (30 commits), SiddhBamb (11 commits), TevinWang (7 commits), Ayush Agarwal (3 commits)

## Devpost submission (written by the team)

### Inspiration

In many developed countries across the world, the population is rapidly aging. This poses a variety of issues to senior citizens, including social isolation, an overburdened healthcare system unable to meet their needs, and the widespread effects of neurodegenerative conditions. We aimed to build a solution which would address all three of these issues in a way which is easily accessible and empowering to senior citizens.

### What it does

MemoryLane allows senior citizens to relive and share their cherished memories. The web application combines three main functionalities, which include a journaling and recall feature for important memories, an AI-powered match and chat system for users to discuss their experiences which are shared with other users, and an analytics dashboard which can be used by healthcare professionals to track key indicators of neurodegenerative conditions. Overall, MemoryLane allows users to not only keep their memories fresh but also weave a tapestry of connections with others with similar life experiences.

### How we built it

In order to develop a clean and responsive front-end and versatile back-end, we used Reflex.dev to develop entirely in Python. We also used the InterSystems IRIS database to easily perform vector search as well as other database operations to support the backend functionalities required by MemoryLane. Additionally, we made use of the Together.AI inference API to generate embeddings to match users based on shared experiences, perform sentiment analysis to find trends within memory recall data, and to create sample data to test our web app with. Finally, we used Google Cloud to implement speech-to-text functionality to increase ease of access to our platform for senior citizens. The majority of our app was built with Python, with a little JavaScript.

### Challenges we ran into

As 2 of our team members had never done full-stack dev before and one was attending his first hackathon, learning the nuances of new frameworks was initially a challenge, especially getting our environments set up. We’re incredibly grateful to the supportive mentors and sponsors for helping us get unstuck when we ran into issues, which indubitably helped us build our final product.

### Accomplishments we're proud of

We’re very proud of our clean, intuitive UI which aims to make the product as accessible as possible to our target audience, senior citizens. Additionally, we believe that MemoryLane is a truly unique product which fills a niche which hasn’t been focused on before social media for the elderly, especially in combination with its potential benefits of improving the healthcare industry by aggregating data about the elderly. Also, half of our team was able to go from near-zero web dev knowledge to familiarity with important tools and techniques, which we thought was very representative of the spirit of hackathons – coming together to meet new people and learn new things in a fast-paced creative environment.

### What we learned

Our journey with MemoryLane has been an enlightening dive into several new technologies. We harnessed the power of Reflex.dev for frontend and full stack development, explored the nuances in our data with InterSystems IRIS’s vector search on text embeddings from TogetherAI, and learned how to bring text to life with Google Cloud. Together AI has also become our ally in understanding our users' needs and narratives with natural language processing.

### What's next

Looking to the horizon, we are definitely looking into expanding MemoryLane’s reach. Our roadmap includes scaling our solution and refining our data model to improve performance, and looking into business models which are sustainable and align with our mission. We envision forming partnerships with healthcare providers, memory care centers, and senior living communities. Integrating IoT could also redefine ease of use for seniors. Keeping innovation in mind, we'll dive deeper into Reflex's capabilities and explore bespoke AI models with Together AI. We aim to improve the technical aspects of our platform as well, including venturing into voice tone analysis to add another layer of emotional intelligence to our app. We believe that MemoryLane is not just a walk in the past – it's a stride into the future of senior healthcare.

## README (from the GitHub repository)

## Overview
MemoryLane is a groundbreaking web application designed to empower senior citizens by enabling them to relive and share cherished memories. Our platform addresses key issues faced by the aging population, such as social isolation, healthcare challenges, and neurodegenerative conditions, through a blend of technology and personal connection. With MemoryLane, users can journal important memories, connect with others through shared experiences, and provide valuable data for healthcare professionals to track and manage the signs of neurodegenerative conditions.

### Features
* __Journaling and Memory Recall__: A digital space for seniors to record, revisit, and share their life stories and cherished memories.
* __AI-Powered Match and Chat System__: Leveraging advanced AI algorithms, users can connect and engage in meaningful conversations with others who have similar life experiences.
* __Analytics Dashboard for Healthcare Professionals__: A comprehensive dashboard offering insights into key indicators of neurodegenerative conditions, aiding in early detection and intervention.

### Built With
* __Reflex.dev__: Utilized for its robust capabilities in full-stack development entirely in Python, ensuring a clean and responsive user interface.
*__InterSystems IRIS__: Employs vector search and other database functionalities to support the backend of MemoryLane.
* __Together.AI__: Provides AI-driven embeddings for user matching, sentiment analysis, and generation of sample data for testing.
* __Google Cloud__: Implements speech-to-text functionality to enhance accessibility for users, making the platform more user-friendly for senior citizens.
* __Python & JavaScript__: The core technologies behind the development of MemoryLane, with a focus on Python for its versatility and ease of use.


__Devpost:__ https://devpost.com/software/memorylane-5aon4r

__Demo:__ https://www.youtube.com/watch?v=4ZuY4dxeFHg


## Detected evidence (automated analysis)

Indexed codebase: 55 recognized source files, 123 KB.
- JavaScript (language) — detected in the code
- OpenAI (technology) — detected in the code
- Python (language) — detected in the code
- FastAPI (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (72 of 72)

```
.DS_Store
.gitignore
analytics_plotly/dynamic_graph_test.py
analytics_plotly/heatmap_test.py
analytics_plotly/linegraph_test.py
analytics_plotly/plotly_text.py
assets/.DS_Store
assets/transcription.js
dashboard-temp/.DS_Store
dashboard-temp/.gitignore
dashboard-temp/assets/transcription.js
dashboard-temp/dashboard/__init__.py
dashboard-temp/dashboard/.DS_Store
dashboard-temp/dashboard/back/data/photos.csv
dashboard-temp/dashboard/back/transcript_analysis/binary_classification.py
dashboard-temp/dashboard/back/transcript_analysis/cosine_similarity.py
dashboard-temp/dashboard/back/transcript_analysis/gcp_speech_to_text.py
dashboard-temp/dashboard/back/transcript_analysis/sentiment_analysis.py
dashboard-temp/dashboard/back/transcript_analysis/topic_classification.py
dashboard-temp/dashboard/back/vector.py
dashboard-temp/dashboard/components/__init__.py
dashboard-temp/dashboard/components/chat.py
dashboard-temp/dashboard/components/loading_icon.py
dashboard-temp/dashboard/components/modal.py
dashboard-temp/dashboard/components/navbar.py
dashboard-temp/dashboard/components/sidebar.py
dashboard-temp/dashboard/components/styles.py
dashboard-temp/dashboard/dashboard.py
dashboard-temp/dashboard/data.py
dashboard-temp/dashboard/graphs.py
dashboard-temp/dashboard/navigation.py
dashboard-temp/dashboard/pages/__init__.py
dashboard-temp/dashboard/pages/fletchat.py
dashboard-temp/dashboard/pages/friends.py
dashboard-temp/dashboard/pages/index.py
dashboard-temp/dashboard/pages/memory.py
dashboard-temp/dashboard/server.py
dashboard-temp/dashboard/state.py
dashboard-temp/dashboard/styles.py
dashboard-temp/LICENSE
dashboard-temp/README.md
dashboard-temp/requirements.txt
dashboard-temp/rxconfig.py
README.md
requirements.txt
rxconfig.py
scripts/ImageGen.ipynb
scripts/MemoryAbility.ipynb
sql_demo.ipynb
TreeHacksX/__init__.py
TreeHacksX/.DS_Store
TreeHacksX/.gitignore
TreeHacksX/back/data/photos.csv
TreeHacksX/back/transcript_analysis/binary_classification.py
TreeHacksX/back/transcript_analysis/cosine_similarity.py
TreeHacksX/back/transcript_analysis/gcp_speech_to_text.py
TreeHacksX/back/transcript_analysis/sentiment_analysis.py
TreeHacksX/back/transcript_analysis/topic_classification.py
TreeHacksX/back/vector.py
TreeHacksX/components/__init__.py
TreeHacksX/components/sidebar.py
TreeHacksX/components/ui/micicon.py
TreeHacksX/pages/__init__.py
TreeHacksX/pages/dashboard.py
TreeHacksX/pages/index.py
TreeHacksX/pages/settings.py
TreeHacksX/requirements.txt
TreeHacksX/rxconfig.py
TreeHacksX/styles.py
TreeHacksX/templates/__init__.py
TreeHacksX/templates/template.py
TreeHacksX/TreeHacksX.py
```

### Dependencies

- dashboard-temp/requirements.txt: flet@>=0.19.0, reflex@>=0.3.9
- requirements.txt: openai@==0.28, reflex@==0.4.0
- TreeHacksX/requirements.txt: reflex@==0.4.0

### Recent commits (newest first)

- Delete TreeHacksX/README.md
- Delete inner README.md
- Update README.md
- Update README.md
- Update README.md
- add friends to ui
- made chat look way better
- use friends 2
- use friends
- add dashboard prooog
- notebooks for inference and data generation
- load data
- delete reflex pt3
- delete reflex pt2
- delete reflex pt1
- Merge branch 'main' of https://github.com/gracelliu/TreeHacksX
- added fletchat
- Merge branch 'main' of https://github.com/gracelliu/TreeHacksX
- create dashboard ui
- added fletchat

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

### requirements.txt

```
reflex==0.4.0
openai==0.28
```

### TreeHacksX/requirements.txt

```
reflex==0.4.0

```

### dashboard-temp/requirements.txt

```
reflex>=0.3.9
flet>=0.19.0
```

### dashboard-temp/dashboard/server.py

```python
from fastapi import FastAPI, HTTPException, Form, UploadFile
from fastapi.responses import JSONResponse
from io import BytesIO

from back.transcript_analysis.gcp_speech_to_text import gcs_speech_to_text
from fastapi.middleware.cors import CORSMiddleware

from back.vector import *

app = FastAPI()

# Set up CORS
origins = [
    "http://localhost",
    "http://localhost:3000",
    # Add other origins as needed
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

@app.get("/photo/")
async def get_photo_link(user_id: int):
    client, conn = create_connection()
    while conn.begin():
        return get_photo(conn, user_id)
                        
@app.get("/submit")
async def quiz_submit(image_id: int, description: str, user_id: int):
    client, conn = create_connection()
    while conn.begin():
        return check_similarity(client, conn, image_id, description, user_id)

@app.post("/transcribe/")
async def transcribe_audio(audio_data: UploadFile = Form(...)):
    try:
        # Read the audio file content
        audio_content = await audio_data.read()
        # audio_content = await audio_data.read()
        # print(audio_content)

        # # Use the BytesIO to create a file-like object
        # audio_file_like = BytesIO(audio_content)
        # print(audio_file_like)

        # Call your GCP speech-to-text function
        transcription_result = gcs_speech_to_text(audio_data, audio_content)

        # Return the transcription result
        return JSONResponse(content={"transcription": transcription_result})

    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))

```

### TreeHacksX/pages/index.py

```python
"""The index page."""

from TreeHacksX.templates import template
import reflex as rx
from .dashboard import TableState



@template(route="/", title="Index")
def index() -> rx.Component:

    return rx.chakra.Stack(
        direction="column",
        spacing="20",
        children=[
            rx.chakra.Stack(
                direction="column",
                spacing="20",
                children=[
                    rx.chakra.heading("Question  1", font_size="3em"),
                    rx.chakra.text("This is the first question in the quiz."),
                    rx.image(src="/assets/arcade.jpg", alt="An example image"),
                    rx.chakra.text("Here is a caption to go with the image."),
                    rx.chakra.text(
                        "Click the button below to describe when and where this memory is from"
                    ),
                    rx.html('<button id="startRecording">Start Recording</button><button id="stopRecording" disabled>Stop Recording</button><audio id="audioPlayer" controls></audio>'),
                    rx.html('<p id="transcript"></p>'),
                    rx.button("Click to talk", on_click=rx.call_script('myInitCode()')),

                    # rx.alert_dialog.root(
                    #     rx.alert_dialog.trigger(
                    #         rx.button("Click to talk"),
                    #     ),
                    #     rx.alert_dialog.content(
                    #         rx.html('<button id="startRecording">Start Recording</button><button id="stopRecording" disabled>Stop Recording</button><audio id="audioPlayer" controls></audio>'),
                    #         rx.alert_dialog.title("Talk in microphone"),
                    #         rx.button("Click to talk", on_click=rx.call_script('myInitCode()')),
                    #         rx.chakra.Spacer(height="5px"),
                    #         rx.alert_dialog.description(
                    #             "Now just talk out loud",
                    #         ),
                    #         rx.chakra.Spacer(height="20px"),  
                    #         rx.flex(
                    #             rx.alert_dialog.cancel(
                    #                 rx.button("Cancel"),
                    #             ),
                    #             rx.alert_dialog.action(
                    #                 rx.button(
                    #                     "Done"
                    #                 ),
                    #             ),
                    #             spacing="3",
                    #         ),
                    #     ),
                    # ),
                ]
            ),
            rx.chakra.Stack(
                direction="column",
                spacing="20",
                children=[
                    rx.chakra.heading("Question  2", font_size="3em"),
                    rx.chakra.text("This is the second question in the quiz."),
                    rx.image(src="/assets/arcade.jpg", alt="An example image"),
                    rx.chakra.text("Here is a caption to go with the image."),
                    rx.chakra.text(
                        "Click the button below to describe when and where this memory is from"
                    ),
                    rx.alert_dialog.root(
                        rx.alert_dialog.trigger(
                            rx.button("Click to talk"),
                        ),
                        rx.alert_dialog.content(
                            rx.alert_dialog.title("Talk in microphone"),
                            rx.chakra.Spacer(height="5px"),
                            rx.alert_dialog.description(
                                "Now just talk out loud",
                            ),
                            rx.chakra.Spacer(height="20px"),
                            rx.flex(
                                rx.alert_dialog.cancel(
                                    rx.button("Cancel"),
                                ),
                                rx.alert_dialog.action(
                                    rx.button("Done"),
                                ),
                                spacing="3",
                            ),
                        ),
                    ),
                    rx.script(src='/transcription.js')
                ]
            ),
            rx.chakra.Stack(
                direction="column",
                spacing="20",
                children=[
                    rx.chakra.heading("Question  3", font_size="3em"),
                    rx.chakra.text("This is the third question in the quiz."),
                    rx.image(src="/assets/arcade.jpg", alt="An example image"),
                    rx.chakra.text("Here is a caption to go with the image."),
                    rx.chakra.text(
                        "Click the button below to describe when and where this memory is from"
                    ),
                    rx.alert_dialog.root(
                        rx.alert_dialog.trigger(
                            rx.button("Click to talk"),
                        ),
                        rx.alert_dialog.content(
                            rx.alert_dialog.title("Talk in microphone"),
                            rx.chakra.Spacer(height="5px"),
                            rx.alert_dialog.description(
                                "Now just talk out loud",
                            ),
                            rx.chakra.Spacer(height="20px"),
                            rx.flex(
                                rx.alert_dialog.cancel(
                                    rx.button("Cancel"),
                                ),
                                rx.alert_dialog.action(
                                    rx.button("Done"),
                                ),
                                spacing="3",
                            ),
                        ),
                    ),
                ],
   
[truncated — 95 more characters]
```

### dashboard-temp/dashboard/pages/index.py

```python
"""The main index page."""

import reflex as rx
from reflex.components.radix import themes as rdxt

from dashboard.data import (
    line_chart_data,
    lines,
    pie_chart_data,
    mood_lines,
    mood_chart_data,
    stat_card_data,
    bar_chart_data,
    bars,
    tabular_data,
    radar_chart_data,
)
from dashboard.graphs import (
    line_chart,
    pie_chart,
    stat_card,
    bar_chart,
    table,
    radar_chart
)
from dashboard.navigation import dashboard_sidebar, navbar
from dashboard.styles import BACKGROUND_COLOR, FONT_FAMILY


# Content in a grid layout.
def content_grid():
    return rx.chakra.grid(
        
        # Stat cards.
        *[rx.chakra.grid_item(stat_card(*c), col_span=1, row_span=1) for c in stat_card_data],
        
        # Cognitive performance line chart.
        rx.chakra.grid_item(
            rx.chakra.heading("Cognitive Performance Over Time", size="md"),
            line_chart(data=line_chart_data, data_key="name", lines=lines),
            col_span=4,
            row_span=2,
        ),

        # Remember vs dont remember cards Bar chart
        rx.chakra.grid_item(
            rx.chakra.heading("Daily Memory Recall Performance", size="md"),
            bar_chart(data=bar_chart_data, data_key="value", bars=bars),
            col_span=4,
            row_span=2,
        ),
        
        # Mood line chart.
        rx.chakra.grid_item(
            rx.chakra.heading("Mood over time", size="md"),
            line_chart(data=mood_chart_data, data_key="name", lines=mood_lines),
            col_span=4,
            row_span=2,
        ),
        
        # catergory Pie chart.
        rx.chakra.grid_item(
            rx.chakra.heading("Category of Memory Cards", size="md"),
            pie_chart(data=pie_chart_data, data_key="value", name_key="name"),
            col_span=4,
            row_span=3,
        ),

        # Radar chart
        rx.chakra.grid_item(
            rx.chakra.heading("Relative Memory Strengths per Category", size="md"),
            radar_chart(data=radar_chart_data),
            col_span=4,
            row_span=1,
        ),

        # friend table
        rx.chakra.grid_item(
            rx.chakra.heading("Friends", size="md"),
            table(tabular_data=tabular_data), col_span=4, row_span=2
        ),

        # formatting
        rx.chakra.grid_item(col_span=2, bg="lightgreen"),
        rx.chakra.grid_item(col_span=2, bg="yellow"),
        rx.chakra.grid_item(col_span=4, bg="orange"),
        template_columns="repeat(4, 1fr)",
        width="100%",
        gap=4,
        row_gap=8,
    )


def index() -> rx.Component:
    return rdxt.box(
        rx.theme_panel(),
        dashboard_sidebar,
        rx.chakra.box(
            navbar(heading="Dashboard"),
            rx.chakra.box(
                content_grid(),
                margin_top="calc(50px + 2em)",
                padding="2em",
            ),
            padding_left="250px",
        ),
        background_color=BACKGROUND_COLOR,
        font_family=FONT_FAMILY,
        padding_bottom="4em",
    )

```

### rxconfig.py

```python
import reflex as rx

config = rx.Config(
    app_name="TreeHacksX",
)

```

### TreeHacksX/__init__.py

```python
"""Base template for Reflex."""

```

### TreeHacksX/rxconfig.py

```python
import reflex as rx

config = rx.Config(
    app_name="TreeHacksX",
)

```

### dashboard-temp/rxconfig.py

```python
import reflex as rx

config = rx.Config(
    app_name="dashboard",
    tailwind={},
)
```

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