-
Notifications
You must be signed in to change notification settings - Fork 27
Add database models and schema #9
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
base: dev
Are you sure you want to change the base?
Conversation
…ess control- Create Image model with local/GitHub storage support- Create Narrative model for patient stories- Create AuditLog model for HIPAA compliance tracking- Add database initialization script- Add comprehensive model documentationFeatures:- Role-based user management (patient, social_worker, admin)- Support for both local and GitHub storage- File hash-based duplicate detection- Audit trail for all admin actions- Proper foreign key relationships and cascading deletes- Database indexes for query performanceSecurity:- Password hash storage (bcrypt integration in next PR)- IP address logging for audit compliance- User data isolation through relationships
Summary of ChangesHello @yadavchiragg, 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 establishes the fundamental database schema for the Behavioral Health Vault (BHV) application. It introduces essential models for managing users, images, patient narratives, and audit logs, with a strong emphasis on healthcare data management best practices and HIPAA compliance. The changes lay a robust and secure groundwork for subsequent feature development, ensuring data integrity and traceability. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 significantly refactors the project's contributing guidelines, making them more concise and beginner-friendly, while also establishing a new database layer using Flask-SQLAlchemy. Key changes include adding *.db to .gitignore, a complete overhaul of CONTRIBUTING.md to simplify instructions and remove detailed templates, and the introduction of bhv/database.py for SQLAlchemy initialization. New model files (user.py, image.py, narrative.py, audit_log.py) define the core database schema, documented in bhv/models/README.md, and are collectively imported via bhv/models/__init__.py. An init_db.py script is added for database setup, alongside a basic installation.md guide and initial test_basic.py tests. The requirements.txt is updated with Flask-SQLAlchemy and related dependencies, though it contains redundant entries. Review comments highlight several areas for improvement: ensuring database-side timestamp generation using server_default=db.func.now() in model definitions (user.py, narrative.py), using an Enum for the action field in AuditLog for type safety, adding a backref to resolve SQLAlchemy relationship ambiguity in audit_log.py, making file_size non-nullable in image.py, and loading the database URI from environment variables in init_db.py. Additionally, the review points out unused imports (datetime in bhv/database.py, model imports in init_db.py), inconsistent formatting in bhv/models/__init__.py, and issues within CONTRIBUTING.md and installation.md regarding incorrect code block formatting and redundant sections.
|
Hey @pradeeban and @mdxabu! I've implemented the core database models for BHV as discussed. Since the project structure is on hold while you evaluate architecture options, I wanted to contribute something concrete that will be needed regardless of the final directory structure. This PR establishes the foundational data layer with four main models: User Model - Role-based access (patient/social worker/admin) with support for the GitHub repo integration you mentioned Image Model - Handles both local and GitHub storage types, includes SHA-256 hashing for duplicate detection Narrative Model - Links patient stories to images with proper authorship tracking AuditLog Model - HIPAA compliance audit trail that logs all admin actions with IP tracking Coming from a cybersecurity background, I focused on security-first design: proper foreign key constraints, cascading deletes for data integrity, and comprehensive audit logging. The models include indexes on frequently queried fields (email, upload_date, timestamps) for performance. I've also included an initialization script (scripts/init_db.py) that creates all tables with a single command - keeping with BHV's "minimal deployment" philosophy. I tested this locally and all tables create successfully. Ready to adapt if you decide on different architectural patterns, but I believe these models capture the core data requirements from the GSoC description. Looking forward to your feedback! |
|
@yadavchiragg, Thanks for the contribution. And we planned to use MongoDB! And fix those bot comments! |
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>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Overview
Implements core database models for BHV following healthcare data management best practices and HIPAA compliance requirements.
Changes
✅ User Model (
bhv/models/user.py)✅ Image Model (
bhv/models/image.py)✅ Narrative Model (
bhv/models/narrative.py)✅ AuditLog Model (
bhv/models/audit_log.py)✅ Database Configuration (
bhv/database.py)✅ Initialization Script (
scripts/init_db.py)✅ Documentation (
bhv/models/README.md)Design Decisions
1. Enum Types for Safety
UserRoleandStorageTypeto prevent invalid values2. Cascading Deletes
3. Indexing Strategy
4. IPv6 Support
5. Flexible Details Field
Security Considerations
Database Schema
Testing
Local Testing Steps
Test Results
✅ All tables created successfully
✅ Relationships established correctly
✅ No SQLAlchemy errors
Next Steps
This PR establishes the foundation for:
-Authentication system (password hashing, login/logout)