Skip to content

Conversation

@safiya2610
Copy link

Overview
This pull request enhances the Behavioral Health Vault (BHV) project by introducing a production-ready CI/CD pipeline and adding support for exporting user data in CSV and JSON formats. These changes align with BHV’s goal of being a minimal, easy-to-install.

Key Changes

  • Added a complete CI/CD pipeline using GitHub Actions:
    • Automated test execution on pull requests and pushes
    • Docker image build and push workflow
    • Structured deployment-ready pipeline for future production use
  • Implemented data export functionality:
    • Export patient/user data in CSV format
    • Export patient/user data in JSON format
    • Enables researchers and administrators to easily analyze and share data
  • Improved project readiness for community clinics and research environments by reducing manual setup and increasing reliability.

Impact

  • Improves developer and contributor experience through automated testing and builds
  • Supports ethical and transparent research workflows via structured data export
  • Moves BHV closer to a one-command, production-ready deployment model

Testing

  • CI pipeline runs automated tests on GitHub Actions
  • Local testing verified for export functionality

safiya2610 and others added 26 commits January 4, 2026 02:42
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
- Add admin router with user management endpoints
- Create admin service for role-based access control
- Add admin dashboard and user gallery templates
- Implement admin authentication checks
- Add unauthorized access template
- Fix JWT configuration and improve token validation
- Update gallery to show metadata JSON properly
- Add admin navigation and styling
- Update tests for new admin functionality
@gemini-code-assist
Copy link
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 significantly upgrades the Behavioral Health Vault (BHV) project by establishing a robust, production-ready CI/CD pipeline and introducing versatile data export capabilities. It also fortifies the application's security posture with new authentication mechanisms and middleware, alongside a new admin interface for content management. These changes aim to streamline development, enhance data utility for researchers, and improve the overall user experience and operational readiness of the platform.

Highlights

  • CI/CD Pipeline Implementation: A comprehensive CI/CD pipeline has been integrated using GitHub Actions, Docker, and Docker Compose. This includes automated test execution, Docker image building and pushing, and a structured deployment-ready setup, significantly improving development workflow and reliability.
  • Data Export Functionality: New features allow users to export their personal image data in both CSV and JSON formats. Additionally, an admin dashboard provides capabilities to export all user and image data, facilitating research and administrative analysis.
  • Enhanced Security and Authentication: The application now includes Google OAuth for user authentication, JWT-based access control, an in-memory rate limiter, and a security headers middleware to protect against common web vulnerabilities. Global exception handlers ensure consistent error responses.
  • Admin Dashboard and Management: An admin dashboard has been introduced, enabling administrators to view and manage user galleries, update image narratives, and delete images. This centralizes administrative control over user-generated content.
  • Fuzzy Emotion Detection for Images: Uploaded images are now processed to detect 'fuzzy emotions' based on their color palettes. This metadata is stored and can be viewed, adding a unique analytical layer to the image gallery.
  • Refactored Application Structure and UI: The application's routing has been modularized with dedicated routers for auth, gallery, admin, and export functionalities. New Jinja2 templates and CSS have been added to provide a more structured and modern user interface.

🧠 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.

Changelog
  • .dockerignore
    • Added a new .dockerignore file to specify files and directories to be excluded when building Docker images, optimizing image size and build times.
  • CONTRIBUTING.md
    • A minor formatting adjustment was made by adding a newline for better readability.
  • Dockerfile
    • Added a new Dockerfile to containerize the application, including Python 3.11 slim base image, system dependencies, non-root user setup, dependency installation with pip-tools, application code copying, port exposure, and a health check.
  • app/dependencies/auth.py
    • Added a new module for JWT-based authentication dependencies, including get_current_user to validate access tokens.
  • app/middleware/ratelimit.py
    • Added an in-memory sliding window rate limiter middleware to prevent abuse and ensure fair resource usage.
  • app/middleware/security.py
    • Added a new middleware to automatically apply common security headers (e.g., X-Content-Type-Options, X-Frame-Options, CSP, HSTS) to all responses. Also includes global exception handlers for FastAPI.
  • app/routers/admin.py
    • Added a new router for admin-specific functionalities, including an admin dashboard, user gallery view, image deletion, narrative updates, and CSV export endpoints for all users and images.
  • app/routers/auth.py
    • Added a new router to handle Google OAuth login and callback processes, and a logout endpoint, integrating with auth_service and admin_service.
  • app/routers/export.py
    • Added a new router for user-specific data export, allowing authenticated users to download their image data in CSV and JSON formats.
  • app/routers/gallery.py
    • Added a new router for the image gallery, including routes for viewing user galleries, uploading images (with fuzzy emotion detection), deleting images, and searching public images from other users.
  • app/routers/images.py
    • Added a new router with a protected API endpoint demonstrating JWT authentication.
  • app/routers/narrative.py
    • Added a new router to handle updates to image narratives.
  • app/routers/pages.py
    • Added a new router for basic web pages such as home, login, signup, and logout.
  • app/services/admin_service.py
    • Added a new service module containing the is_admin function to check if a user has administrative privileges.
  • app/services/auth_service.py
    • Added a new service module to encapsulate Google OAuth logic, including redirect handling, callback processing, and user upsertion into the database.
  • app/services/image_service.py
    • Added a new service module with functions for saving and deleting images, incorporating fuzzy emotion detection, file size tracking, and upload date recording.
  • app/services/jwt_service.py
    • Added a new service module for creating and decoding JSON Web Tokens (JWTs) for access and refresh tokens.
  • auth_google.py
    • Added a new module to configure Authlib for Google OAuth integration, defining client ID, secret, and scope.
  • cleaned_data.json
    • Added a new JSON data file mapping colors to associated emotions, used by the fuzzy emotion detection algorithm.
  • config.py
    • Added a new configuration file to load environment variables for sensitive data (e.g., SECRET_KEY, Google OAuth credentials) and define JWT parameters.
  • db.py
    • Added a new database utility module with functions to get a database connection and initialize the SQLite database schema for users, images, and admins, including a migration script for the users table.
  • docker-compose.yml
    • Added a new Docker Compose file to define and run the BHV application as a Docker service, specifying build context, ports, environment variables, volume mounts, and a health check.
  • fuzzy_emotion.py
    • Added a new module implementing a fuzzy emotion detection algorithm for images. It uses KMeans clustering to extract dominant colors, maps them to emotions based on cleaned_data.json, and calculates visual statistics.
  • main.py
    • Added the main FastAPI application entry point, including middleware setup (SessionMiddleware), static file serving, registration of all new routers, and health check/startup/shutdown event handlers.
  • make_admin.py
    • Added a utility script to programmatically add an email address as an administrator to the database.
  • requirements/base.in
    • Added a new file listing core Python dependencies for the application, including FastAPI, Authlib, JWT libraries, and image processing libraries.
  • requirements/dev.in
    • Added a new file specifying development dependencies, inheriting from base.in and test.in.
  • requirements/lock.txt
    • Added a new file generated by pip-compile, pinning all direct and transitive Python dependencies to specific versions for reproducible builds.
  • requirements/test.in
    • Added a new file listing testing dependencies, specifically pytest.
  • static/css/cards.css
    • Added new CSS for styling card components on the homepage.
  • static/css/gallery.css
    • Added new CSS for styling the image gallery, including grid layout, upload forms, and metadata overlays.
  • static/css/gallery_pg.css
    • Added new CSS for styling the gallery page specific elements.
  • static/css/login.css
    • Added new CSS for styling the login and signup pages.
  • static/css/navbar.css
    • Added new CSS for styling the application's navigation bar.
  • static/js/navbar.js
    • Added new JavaScript for interactive effects on the navigation bar.
  • static/style.css
    • Added a basic stylesheet for general application styling.
  • templates/admin_dashboard.html
    • Added a new Jinja2 template for the admin dashboard, displaying user lists and export options.
  • templates/admin_user_gallery.html
    • Added a new Jinja2 template for viewing and managing a specific user's gallery from the admin perspective.
  • templates/base.html
    • Added a new base Jinja2 template that other templates extend, providing common HTML structure, meta tags, and shared stylesheets/scripts.
  • templates/components/cards.html
    • Added a new Jinja2 component for displaying image cards on the homepage.
  • templates/components/gallery_pg.html
    • Added a new Jinja2 component for a gallery preview on the homepage.
  • templates/components/navbar.html
    • Added a new Jinja2 component for the application's navigation bar, including conditional rendering for admin links and user authentication status.
  • templates/components/parallax.html
    • Added a new Jinja2 component for a parallax scrolling effect on the homepage.
  • templates/gallery.html
    • Added a new Jinja2 template for the main image gallery, including upload forms, search functionality, and image display with metadata and narrative editing.
  • templates/home.html
    • Added a new Jinja2 template for the application's homepage, integrating various components like the navbar, cards, parallax, and gallery preview.
  • templates/login.html
    • Added a new Jinja2 template for the user login page, supporting Google OAuth and traditional email/password login.
  • templates/signup.html
    • Added a new Jinja2 template for the user signup page.
  • templates/unauthorized.html
    • Added a new Jinja2 template for displaying an access denied message.
  • tests/conftest.py
    • Added a new pytest configuration file to define fixtures, specifically a FastAPI test client.
  • tests/test_basic_routes.py
    • Added new basic tests to verify the accessibility and redirection behavior of core application routes without authentication.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/ci-cd.yml
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.

Copy link
Contributor

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

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 significant enhancements, including a CI/CD pipeline via GitHub Actions and data export functionality in CSV/JSON formats. The changes are well-structured and move the project towards better production readiness. My review focuses on improving reproducibility in the Docker build, correcting some bugs in the new admin and export routes, reducing code duplication, and addressing some minor code quality issues. Overall, this is a great contribution that adds valuable features to the project.

)

matching_users = cur.fetchall()
print(f"DEBUG: Search query: {q}, Current user: {current_user_email}, Matching users: {matching_users}")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This print statement appears to be for debugging. It should be removed or replaced with structured logging (e.g., logger.debug(...)) before merging into a production branch.

- ./cleaned_data.json:/app/cleaned_data.json
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/docs"]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The healthcheck in this docker-compose.yml file targets the /docs endpoint. This is inconsistent with the HEALTHCHECK defined in the Dockerfile, which correctly uses the dedicated /health endpoint. The /docs endpoint (Swagger UI) can be disabled in production and is generally heavier than a simple health check. It's better to use the /health endpoint here for consistency and efficiency.

      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]

@safiya2610
Copy link
Author

@mdxabu I intended this PR to target the dev branch, but it was accidentally opened against main.
Could you please change the base branch to dev, or let me know if you’d prefer that I open a new PR?

@mdxabu
Copy link
Member

mdxabu commented Feb 6, 2026

You can change by editing

@safiya2610
Copy link
Author

ok

@mdxabu mdxabu changed the base branch from main to dev February 6, 2026 12:28
@mdxabu
Copy link
Member

mdxabu commented Feb 6, 2026

Done!

@mdxabu mdxabu added the on hold Not merging this PR now. label Feb 6, 2026
safiya2610 and others added 6 commits February 8, 2026 18:22
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Removed closing img tags that are not required in HTML.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Remove initialization of the neutral emotion set.
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