Skip to content

feat(server): system_provider_configs and character_covers#905

Merged
luoling8192 merged 15 commits intomainfrom
dev/optimize-schema
Jan 7, 2026
Merged

feat(server): system_provider_configs and character_covers#905
luoling8192 merged 15 commits intomainfrom
dev/optimize-schema

Conversation

@luoling8192
Copy link
Member

@luoling8192 luoling8192 commented Jan 7, 2026

  • Added new schemas for character covers and user provider configurations to improve data organization.
  • Updated character and provider services to support new CRUD operations for covers and user-specific configurations.
  • Refactored existing routes to accommodate changes in how providers and characters are retrieved and managed.
  • Enhanced tests to validate the new functionality and ensure correct handling of user-specific data.

luoling8192 and others added 11 commits January 6, 2026 03:50
- Created new tables for character bookmarks and likes.
- Updated the characters table to include additional fields: avatar_url, character_avatar_url, cover_background_url, creator_role, price_credit, likes_count, bookmarks_count, interactions_count, and forks_count.
- Enhanced character schema and service to support liking and bookmarking characters.
- Updated API routes to handle like and bookmark actions.
- Modified character store to manage likes and bookmarks in the frontend.
…onality

- Added @electric-sql/pglite as a dependency for in-memory database testing.
- Implemented mock database creation in mock-db.ts to facilitate testing.
- Updated character service and routes tests to utilize the new mock database.
- Removed outdated character tests and replaced them with updated tests using the mock database.
- Enhanced character creation and retrieval tests to validate new schema fields.
- Added a new table for provider configurations in the database.
- Created API routes for managing provider configurations, including CRUD operations.
- Developed a provider service to handle business logic related to provider configurations.
- Implemented validation schemas for provider configuration requests.
- Added tests for provider service and routes to ensure functionality and reliability.
- Updated application structure to integrate provider management into the existing server architecture.
- Added a watcher to reset the provider configuration edit state when the provider configuration changes and is not empty.
…ations

- Introduced new tables for character bookmarks and likes, including necessary foreign key constraints.
- Updated the characters table to include new fields: avatar_url, character_avatar_url, cover_background_url, creator_role, price_credit, likes_count, bookmarks_count, interactions_count, and forks_count.
- Adjusted character schema to reflect changes in data types for likes and bookmarks counts.
- Enhanced character service methods to correctly handle integer values for likes and bookmarks.
- Updated tests to validate the new functionality and ensure correct data handling.
…useAsyncState

- Removed manual loading and error handling logic from character and provider catalog stores.
- Integrated useAsyncState composable to manage asynchronous state and error handling.
- Cleaned up fetch, create, update, and delete methods for better readability and maintainability.
- Removed unused variables related to loading and error states from the stores.
- Renamed the "provider_configs" table to "user_settings_provider_configs" for clarity.
- Dropped the old foreign key constraint and added a new one to ensure referential integrity with the "user" table.
- Introduced a new snapshot file to reflect the updated database schema and configurations.
…ionships and tables

- Added new 'character_covers' table to manage character cover images with necessary fields and relationships.
- Moved 'characterLikes' and 'characterBookmarks' tables to a new 'user-character' schema for better organization.
- Updated 'characters' and 'providers' schemas to reflect changes, including renaming and adding new relationships.
- Improved data integrity by establishing foreign key constraints between new and existing tables.
… and user configuration management

- Added new schemas for character covers and user provider configurations to improve data organization.
- Updated character and provider services to support new CRUD operations for covers and user-specific configurations.
- Refactored existing routes to accommodate changes in how providers and characters are retrieved and managed.
- Enhanced tests to validate the new functionality and ensure correct handling of user-specific data.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @luoling8192, 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 refactors the data models and associated services for characters and providers. It introduces a dedicated schema for character covers, moving cover-related fields out of the main character table. More importantly, it establishes a clear distinction between user-specific and system-wide provider configurations, allowing for more flexible and organized management of external service integrations. These changes improve data organization, enhance modularity, and lay the groundwork for more robust feature development.

Highlights

  • Schema Refactoring for Characters: Character cover images are now managed through a dedicated characterCovers schema and table, separating cover-related fields from the main character entity for better data organization.
  • Separation of Provider Configurations: Introduced distinct schemas and tables for UserProviderConfig and SystemProviderConfig, allowing for clear differentiation and management of user-specific versus system-wide external service configurations.
  • Service and Route Updates: The character and provider services and their corresponding API routes have been updated to support the new schema structures, including new CRUD operations for character covers and separate handling for user and system provider configurations.
  • Enhanced Test Coverage: Existing tests have been modified and new tests added to validate the correct functionality and data handling for character covers and the new user/system provider configuration separation.
  • Schema Relocation: The characterLikes and characterBookmarks schemas have been moved to a new dedicated file, user-character.ts, to further modularize the database schema definitions.
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 and well-executed refactoring to the database schema and services. The introduction of new schemas for character covers and the separation of provider configurations into user-specific and system-wide tables greatly improve data organization and clarity. The corresponding updates to services, routes, and tests are thorough and validate the new functionality effectively. I have one piece of feedback regarding type safety that should be addressed.

Comment on lines +40 to +43
const provider = await providerService.createUserConfig({
...result.output,
ownerId: user.id,
})
} as any)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The use of as any here bypasses TypeScript's type safety and should be avoided. It likely masks a type incompatibility between the object constructed from the request body and the NewUserProviderConfig type expected by the createUserConfig service method. Relying on as any can lead to runtime errors if the underlying types change in the future. Please resolve the type mismatch so that the type cast is no longer necessary.

Suggested change
const provider = await providerService.createUserConfig({
...result.output,
ownerId: user.id,
})
} as any)
const provider = await providerService.createUserConfig({
...result.output,
ownerId: user.id,
})

…bles

- Added a new table for character covers to manage cover images with necessary fields.
- Renamed existing tables for user character bookmarks and likes to improve clarity and organization.
- Dropped outdated foreign key constraints and established new ones to ensure data integrity.
- Updated the characters table by removing unused columns to streamline the schema.
- Introduced a new snapshot file to reflect the latest database schema changes.
Base automatically changed from dev/refactor-async-state to main January 7, 2026 13:42
@luoling8192 luoling8192 changed the title Dev/optimize-schema feat(server): system_provider_configs and character_covers Jan 7, 2026
@luoling8192 luoling8192 marked this pull request as ready for review January 7, 2026 13:43
@luoling8192 luoling8192 merged commit 371a0b1 into main Jan 7, 2026
@luoling8192 luoling8192 deleted the dev/optimize-schema branch January 7, 2026 13:44
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.

1 participant