Skip to content

refactor: clean code and improve readability#8

Open
sonmessia wants to merge 3 commits intomainfrom
feat/database-migration
Open

refactor: clean code and improve readability#8
sonmessia wants to merge 3 commits intomainfrom
feat/database-migration

Conversation

@sonmessia
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings October 21, 2025 17:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the codebase by removing legacy frontend files, migrating from file-based manifest storage to a PostgreSQL database system, and improving code documentation. The changes modernize the application architecture by introducing repository pattern for data access and consolidating demo content management.

Key Changes:

  • Migrated from manifest.json to PostgreSQL database with repository pattern
  • Added comprehensive module-level documentation to app.py explaining system architecture
  • Removed legacy Frontend directory containing outdated HTML/CSS/JS files

Reviewed Changes

Copilot reviewed 6 out of 327 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
docker-compose.yaml Added PostgreSQL configuration for database service
content/manifest.json Migrated from inline SiGML to database-backed storage, improved JSON formatting
app.py Refactored to use repository pattern, added comprehensive documentation, removed hardcoded SiGML function
Frontend/styles.css Removed entire legacy CSS file (1248 lines)
Frontend/script.js Removed entire legacy JavaScript file (333 lines)
Frontend/index.html Removed entire legacy HTML file (340 lines)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +8 to +10
POSTGRES_USER: HiepData
POSTGRES_PASSWORD: 123456
POSTGRES_DB: db_signbridge
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Hardcoded database credentials pose a security risk. Move these credentials to environment variables or a secure secrets management system. Consider using ${POSTGRES_USER:-default_user} syntax to read from .env files.

Suggested change
POSTGRES_USER: HiepData
POSTGRES_PASSWORD: 123456
POSTGRES_DB: db_signbridge
POSTGRES_USER: ${POSTGRES_USER:-HiepData}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-123456}
POSTGRES_DB: ${POSTGRES_DB:-db_signbridge}

Copilot uses AI. Check for mistakes.
# Format: postgresql://username:password@host:port/database
DATABASE_URL = os.getenv(
'DATABASE_URL',
'postgresql://HiepData:123456@localhost:5438/db_signbridge'
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Default database credentials are hardcoded in the fallback connection string. This exposes sensitive credentials in source code. Remove the default value or use a non-sensitive placeholder that forces explicit configuration.

Suggested change
'postgresql://HiepData:123456@localhost:5438/db_signbridge'
'postgresql://USER:PASSWORD@HOST:PORT/DATABASE'

Copilot uses AI. Check for mistakes.
"result.html",
video=None,
video_url=viewing_data.video_url,
video_id=vid, # NEW - Pass video_id to template
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment 'NEW' is vague and will become outdated. Replace with a more descriptive comment explaining why video_id is passed, or remove it if the parameter name is self-explanatory.

Suggested change
video_id=vid, # NEW - Pass video_id to template
video_id=vid,

Copilot uses AI. Check for mistakes.
return render_template(
"result.html",
video=video_data.video_url,
video_id=video_id, # NEW - Pass video_id to template
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

[nitpick] Duplicate 'NEW' comment creates inconsistency and will become outdated. Remove or replace with meaningful documentation explaining the purpose of passing video_id.

Suggested change
video_id=video_id, # NEW - Pass video_id to template
video_id=video_id, # Pass video_id for template logic (e.g., display, actions)

Copilot uses AI. Check for mistakes.
"""Serve output files (transcripts, SiGML, etc.).

DEPRECATED - This endpoint is kept for backward compatibility only.
New code should use /api/sigml/<video_id> instead.
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The deprecation notice should include a version or date when this endpoint will be removed to help users plan migrations. Consider adding: 'Will be removed in version X.X or after YYYY-MM-DD.'

Suggested change
New code should use /api/sigml/<video_id> instead.
New code should use /api/sigml/<video_id> instead.
Will be removed in version 2.0 or after 2024-12-31.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants