Skip to content

Behavioral Health Vault (BHV) Prototype - #39

Open
safiya2610 wants to merge 22 commits into
KathiraveluLab:mainfrom
safiya2610:bhv-prototype
Open

Behavioral Health Vault (BHV) Prototype#39
safiya2610 wants to merge 22 commits into
KathiraveluLab:mainfrom
safiya2610:bhv-prototype

Conversation

@safiya2610

@safiya2610 safiya2610 commented Jan 4, 2026

Copy link
Copy Markdown

✅ - Implemented a minimal FastAPI-based BHV prototype focused on simplicity and easy deployment
✅ - Added basic authentication (email/password) with session handling

  • Includes Google OAuth support
    ✅ Implemented image upload, view, and delete functionality
  • Uses local filesystem storage (no external services)
    ✅ Designed a clean, gallery-style UI
  • Single-page layout
  • No heavy frontend framework
    ✅ Integrated an optional fuzzy color–emotion analysis module
  • Extracts dominant color palette from images
  • Generates neutral visual metadata (emotion space, confidence, visual stats)
  • Metadata stored separately
  • Does not override user intent
    ✅ Ensured privacy by default
  • Images are private unless explicitly marked public
  • Metadata hidden by default
    ✅ Implemented metadata modal (popup card)
  • Opens only on user button click
  • Displays full visual metadata
  • Easy close using cross button
    ✅ Kept the system single-command runnable
  • No separate frontend / backend / database services
    ✅ Used SQLite + local filesystem storage
  • Lightweight setup
  • Clinic-friendly and easy to maintain

Future Work

  1. Cloud-based Image Storage
    Integrate Cloudinary for scalable and secure image storage

  2. Support both local storage (default) and cloud storage (optional) modes
    Role-Based Access Control

  3. Introduce Admin and User roles
    Allow administrators to:
    View and moderate all user submissions
    Upload or edit images and narratives on behalf of users
    Manage visibility and moderation actions

  4. Enhanced Research Module
    Improve fuzzy color–emotion analysis with:
    Better color clustering
    Confidence calibration
    Support for comparative analysis across multiple images
    Enable researchers to analyze trends over time instead of single-image results
    Improved Privacy Controls
    Granular privacy settings per image and narrative

Commands to run Prototype

Create Virtual Environment
python -m venv venv

Activate Environment
Windows
venv\Scripts\activate

Linux / macOS
source venv/bin/activate

Install Dependencies
pip install -r requirements.txt
Minimal stack: FastAPI, SQLite, Jinja, Pillow, scikit-image

Run the Application (Single Command)
uvicorn main:app --reload
screen-capture.2.webm

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @safiya2610, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the foundational prototype for the Behavioral Health Vault (BHV) application. It establishes a robust backend using FastAPI for handling user authentication, secure image storage, and dynamic content delivery. A key innovation is the integration of a fuzzy color-emotion analysis system, which provides insightful, privacy-preserving metadata for uploaded images. The frontend is designed for a clean, gallery-like experience, ensuring ease of use and a focus on visual content.

Highlights

  • Core Prototype Implementation: A minimal FastAPI-based Behavioral Health Vault (BHV) prototype has been implemented, focusing on simplicity and ease of deployment with a single-command runnable system using SQLite and local storage.
  • Authentication and Session Management: Basic email/password authentication with session handling has been added, alongside integration for Google OAuth for user login.
  • Image Management and UI: Functionality for image upload, viewing, and deletion is now available, utilizing local filesystem storage. A gallery-style single-page UI has been designed for a minimal user experience.
  • Fuzzy Color-Emotion Analysis: An optional module for fuzzy color-emotion analysis has been integrated. This module extracts dominant color palettes from uploaded images and generates neutral visual metadata (emotion space, confidence, visual stats), which is stored separately and does not override user intent.
  • Privacy Features: Privacy is ensured by default, with images remaining private unless explicitly marked public. Visual metadata is hidden behind a user-triggered popup modal, ensuring it's not shown by default.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new FastAPI application for image management, incorporating user authentication (local and Google OAuth), image upload with fuzzy emotion detection, a gallery view, and image narrative updates. The changes include adding cleaned_data.json for color-emotion mapping, config.py for environment variables, db.py for SQLite database setup (users, images, and friends tables), and fuzzy_emotion.py for generating image metadata. The main.py file integrates these components, handling various user interaction routes, while narrative.py provides an endpoint for updating image narratives. Frontend updates involve new CSS files (cards.css, gallery.css, gallery_pg.css, login.css, navbar.css, style.css) and HTML templates (base.html, cards.html, gallery_pg.html, gallery.html, home.html, login.html, parallax.html, signup.html) to support the new features and enhance the user interface. Review comments identify several critical issues, including security vulnerabilities related to a hardcoded SECRET_KEY, hardcoded Google OAuth redirect_uri, path traversal in the image deletion endpoint, and missing authentication/authorization for narrative updates. Concurrency and reliability concerns are raised due to global database connections in db.py and overly broad exception handling in fuzzy_emotion.py and main.py. Dependency management in requirements.txt is noted as incomplete (missing scikit-learn, scikit-image) and bloated (unused tensorflow, deepface). Code quality issues include an unused variable in fuzzy_emotion.py, duplicate CSS definitions in gallery.css, invalid </img> tags in cards.html and parallax.html, and an overloaded narrative database column in gallery.html that conflates narrative text with visibility status.

Comment thread db.py Outdated
Comment thread narrative.py Outdated
Comment on lines +7 to +23
@router.post("/update-narrative")
async def update_narrative(
filename: str = Form(...),
narrative: str = Form("")
):
conn = get_db()
cur = conn.cursor()

cur.execute(
"UPDATE images SET narrative = ? WHERE filename = ?",
(narrative.strip(), filename)
)

conn.commit()
conn.close()

return RedirectResponse(url="/gallery", status_code=303)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This endpoint is missing authentication and authorization. As it is, any user (even an unauthenticated one) can update the narrative for any image in the system simply by knowing its filename. This is a critical security vulnerability. You must add a check to ensure that a logged-in user is making the request and that they are the owner of the image they are trying to modify.

Comment thread main.py Outdated
Comment thread requirements.txt Outdated
Comment thread main.py Outdated
Comment thread static/css/gallery.css Outdated
Comment thread static/css/login.css
Comment thread templates/components/cards.html
Comment thread templates/components/parallax.html
Comment thread templates/gallery.html
@mdxabu mdxabu added the on hold Not merging this PR now. label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on hold Not merging this PR now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants