Skip to content

feat: Setup workspaces, generated schemas, and PoC#859

Merged
CodeWithCJ merged 5 commits intoCodeWithCJ:mainfrom
Sim-sat:zod-validation
Mar 7, 2026
Merged

feat: Setup workspaces, generated schemas, and PoC#859
CodeWithCJ merged 5 commits intoCodeWithCJ:mainfrom
Sim-sat:zod-validation

Conversation

@Sim-sat
Copy link
Contributor

@Sim-sat Sim-sat commented Mar 7, 2026

Description

This PR establishes the shared package architecture and introduces automated Zod schemas generated from the database directly using kanel and ts-to-zod. This means that the types are as accurate as possible. The automatic creation from the database was just a one time thing because I think that would add too much complexity. Writing a new schema if you add a database table is easier and more beginner friendly

A proof of concept has been implemented for the backup feature in the frontend. The types are defined by the schemas so we only have a single source of truth. This only applies to types that are used to communicate with the backend. Other types should not be converted to zod schemas, but can be shared aswell if that's helpful.

Changes

  • Workspaces: Configured workspace setup for @workspace/shared.
  • Schemas: Integrated ts-to-zod to automatically generate Zod schemas and inferred types from existing TypeScript interfaces.
  • Proof of Concept (Backup): Migrated the backup feature to use the newly generated types (BackupSettings, BackupSettingsMutator). This guarantees that any mismatch between the backend data and expected frontend types is caught immediately at runtime, preventing silent data corruption or UI errors.
  • Validation: Added runtime request and response validation using Zod schemas within TanStack Query functions.
  • Cleanup: Removed package-lock.json to strictly enforce pnpm usage.

CI/Docker

  • I adjusted the ci to install the global dependency so the frontend can use the shared types
  • I pinned the recharts and better-auth version to the current version because the next minor versions changes the types
  • I modified the frontend Dockerfile
  • I build the production frontend locally and verified it works on the server

Related Issue

PR type [ ] Issue [ ] New Feature [ ] Documentation
Linked Issue: #

Checklist

Please check all that apply:

  • [MANDATORY for new feature] Alignment: I have raised a GitHub issue and it was reviewed/approved by maintainers
  • Tests: I have included automated tests for my changes.
  • [MANDATORY for UI changes] Screenshots: I have attached "Before" vs "After" screenshots below.
  • [MANDATORY for Frontend changes] Quality: I have run pnpm run validate (especially for Frontend).
  • Translations: I have only updated the English (en) translation file (if applicable).
  • Architecture: My code follows the existing architecture standards.
  • Database Security: I have updated rls_policies.sql for any new user-specific tables.
  • [MANDATORY - ALL] Integrity & License: I certify this is my own work, free of malicious code(phishing, malware, etc.) and I agree to the License terms.

Screenshots (if applicable)

Before

[Insert screenshot/GIF here]

After

[Insert screenshot/GIF here]

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 project's architecture by introducing a monorepo setup with pnpm workspaces. The core improvement is the implementation of automated Zod schema generation from the database, which provides robust type safety and runtime validation for API interactions. This change is demonstrated through a proof of concept on the backup feature, ensuring data consistency between the backend and frontend. The new structure promotes code reusability and maintainability across different parts of the application.

Highlights

  • Workspaces Setup: Configured a monorepo structure using pnpm workspaces, establishing a shared package for common utilities and types.
  • Automated Zod Schema Generation: Integrated ts-to-zod to automatically generate Zod schemas and inferred TypeScript types directly from the database, ensuring a single source of truth for data models.
  • Proof of Concept (Backup Feature): Migrated the frontend's backup feature to utilize the newly generated Zod types (BackupSettings, BackupSettingsMutator), enhancing type safety and runtime validation.
  • Runtime Validation: Implemented runtime request and response validation using Zod schemas within TanStack Query functions, preventing data mismatches and UI errors.
  • Dependency Management Refinement: Adopted pnpm for dependency management across the workspace, with explicit mention of removing package-lock.json to enforce its usage.
Changelog
  • SparkyFitnessFrontend/package.json
    • Added the 'zod' library as a dependency.
  • SparkyFitnessFrontend/pnpm-lock.yaml
    • Updated the pnpm lockfile to reflect the new 'zod' dependency and other package changes.
  • SparkyFitnessFrontend/src/api/Admin/backup.ts
    • Updated imports to use shared Zod schemas for BackupSettings and BackupSettingsMutator.
    • Implemented Zod parsing for fetched backup settings and validation for saved settings.
  • SparkyFitnessFrontend/src/hooks/Admin/useBackups.ts
    • Updated imports to reference shared BackupSettingsMutator type.
    • Modified the useUpdateBackupSettings mutation function to use the new BackupSettingsMutator type.
  • SparkyFitnessFrontend/src/pages/Admin/BackupSettings.tsx
    • Simplified the backupLocation prop assignment, removing a fallback value.
  • SparkyFitnessFrontend/src/pages/Admin/BackupSettingsForm.tsx
    • Updated imports to use shared BackupSettings and BackupSettingsMutator types.
    • Adjusted property names in state initialization and onSave payload to align with snake_case conventions from generated schemas.
    • Modified getStatusText function parameters to accept string | null and Date | null.
  • SparkyFitnessFrontend/src/pages/Diary/DiaryTopControls.tsx
    • Reordered the import statement for the Goals type.
  • SparkyFitnessFrontend/src/types/admin.ts
    • Removed the BackupSettingsResponse interface, as its functionality is now covered by generated Zod schemas.
  • SparkyFitnessFrontend/tsconfig.app.json
    • Configured TypeScript to include the new shared workspace and added a path alias for @workspace/shared.
  • SparkyFitnessFrontend/tsconfig.json
    • Configured TypeScript to include a path alias for @workspace/shared.
  • package-lock.json
    • Added a new package-lock.json at the root level.
  • pnpm-lock.yaml
    • Added a new pnpm-lock.yaml at the root level to manage workspace dependencies.
  • pnpm-workspace.yaml
    • Added a new pnpm workspace configuration file, defining 'frontend', 'mobile', and 'shared' workspaces.
  • shared/package.json
    • Added a new package definition for the shared workspace, including ts-to-zod, typescript, and zod dev dependencies.
    • Included scripts for generating types and building the index file.
  • shared/src/index.ts
    • Added an index file to export all generated Zod schemas from the schemas directory.
  • shared/src/schemas/Account.zod.ts
    • Added auto-generated Zod schemas for the 'Account' entity, including accountIdSchema, accountSchema, accountInitializerSchema, and accountMutatorSchema.
  • shared/src/schemas/AdminActivityLogs.zod.ts
    • Added auto-generated Zod schemas for the 'AdminActivityLogs' entity, including adminActivityLogsIdSchema, adminActivityLogsSchema, adminActivityLogsInitializerSchema, and adminActivityLogsMutatorSchema.
  • shared/src/schemas/AiServiceSettings.zod.ts
    • Added auto-generated Zod schemas for the 'AiServiceSettings' entity, including aiServiceSettingsSchema, aiServiceSettingsInitializerSchema, and aiServiceSettingsMutatorSchema.
  • shared/src/schemas/ApiKey.zod.ts
    • Added auto-generated Zod schemas for the 'ApiKey' entity, including apiKeyIdSchema, apiKeySchema, apiKeyInitializerSchema, and apiKeyMutatorSchema.
  • shared/src/schemas/BackupSettings.zod.ts
    • Added auto-generated Zod schemas for the 'BackupSettings' entity, including backupSettingsIdSchema, backupSettingsSchema, backupSettingsInitializerSchema, and backupSettingsMutatorSchema.
  • shared/src/schemas/CheckInMeasurements.zod.ts
    • Added auto-generated Zod schemas for the 'CheckInMeasurements' entity, including checkInMeasurementsSchema, checkInMeasurementsInitializerSchema, and checkInMeasurementsMutatorSchema.
  • shared/src/schemas/CustomCategories.zod.ts
    • Added auto-generated Zod schemas for the 'CustomCategories' entity, including customCategoriesSchema, customCategoriesInitializerSchema, and customCategoriesMutatorSchema.
  • shared/src/schemas/CustomMeasurements.zod.ts
    • Added auto-generated Zod schemas for the 'CustomMeasurements' entity, including customMeasurementsSchema, customMeasurementsInitializerSchema, and customMeasurementsMutatorSchema.
  • shared/src/schemas/DailySleepNeed.zod.ts
    • Added auto-generated Zod schemas for the 'DailySleepNeed' entity, including dailySleepNeedIdSchema, dailySleepNeedSchema, dailySleepNeedInitializerSchema, and dailySleepNeedMutatorSchema.
  • shared/src/schemas/DayClassificationCache.zod.ts
    • Added auto-generated Zod schemas for the 'DayClassificationCache' entity, including dayClassificationCacheIdSchema, dayClassificationCacheSchema, dayClassificationCacheInitializerSchema, and dayClassificationCacheMutatorSchema.
  • shared/src/schemas/ExerciseEntries.zod.ts
    • Added auto-generated Zod schemas for the 'ExerciseEntries' entity, including exerciseEntriesIdSchema, exerciseEntriesSchema, exerciseEntriesInitializerSchema, and exerciseEntriesMutatorSchema.
  • shared/src/schemas/ExerciseEntryActivityDetails.zod.ts
    • Added auto-generated Zod schemas for the 'ExerciseEntryActivityDetails' entity, including exerciseEntryActivityDetailsIdSchema, exerciseEntryActivityDetailsSchema, exerciseEntryActivityDetailsInitializerSchema, and exerciseEntryActivityDetailsMutatorSchema.
  • shared/src/schemas/ExerciseEntrySets.zod.ts
    • Added auto-generated Zod schemas for the 'ExerciseEntrySets' entity, including exerciseEntrySetsIdSchema, exerciseEntrySetsSchema, exerciseEntrySetsInitializerSchema, and exerciseEntrySetsMutatorSchema.
  • shared/src/schemas/ExercisePresetEntries.zod.ts
    • Added auto-generated Zod schemas for the 'ExercisePresetEntries' entity, including exercisePresetEntriesIdSchema, exercisePresetEntriesSchema, exercisePresetEntriesInitializerSchema, and exercisePresetEntriesMutatorSchema.
  • shared/src/schemas/Exercises.zod.ts
    • Added auto-generated Zod schemas for the 'Exercises' entity, including exercisesIdSchema, exercisesSchema, exercisesInitializerSchema, and exercisesMutatorSchema.
  • shared/src/schemas/ExternalDataProviders.zod.ts
    • Added auto-generated Zod schemas for the 'ExternalDataProviders' entity, including externalDataProvidersIdSchema, externalDataProvidersSchema, externalDataProvidersInitializerSchema, and externalDataProvidersMutatorSchema.
  • shared/src/schemas/ExternalProviderTypes.zod.ts
    • Added auto-generated Zod schemas for the 'ExternalProviderTypes' entity, including externalProviderTypesIdSchema, externalProviderTypesSchema, externalProviderTypesInitializerSchema, and externalProviderTypesMutatorSchema.
  • shared/src/schemas/FamilyAccess.zod.ts
    • Added auto-generated Zod schemas for the 'FamilyAccess' entity, including familyAccessSchema, familyAccessInitializerSchema, and familyAccessMutatorSchema.
  • shared/src/schemas/FastingLogs.zod.ts
    • Added auto-generated Zod schemas for the 'FastingLogs' entity, including fastingLogsIdSchema, fastingLogsSchema, fastingLogsInitializerSchema, and fastingLogsMutatorSchema.
  • shared/src/schemas/FoodEntries.zod.ts
    • Added auto-generated Zod schemas for the 'FoodEntries' entity, including foodEntriesSchema, foodEntriesInitializerSchema, and foodEntriesMutatorSchema.
  • shared/src/schemas/FoodEntryMeals.zod.ts
    • Added auto-generated Zod schemas for the 'FoodEntryMeals' entity, including foodEntryMealsIdSchema, foodEntryMealsSchema, foodEntryMealsInitializerSchema, and foodEntryMealsMutatorSchema.
  • shared/src/schemas/FoodVariants.zod.ts
    • Added auto-generated Zod schemas for the 'FoodVariants' entity, including foodVariantsIdSchema, foodVariantsSchema, foodVariantsInitializerSchema, and foodVariantsMutatorSchema.
  • shared/src/schemas/Foods.zod.ts
    • Added auto-generated Zod schemas for the 'Foods' entity, including foodsIdSchema, foodsSchema, foodsInitializerSchema, and foodsMutatorSchema.
  • shared/src/schemas/GlobalSettings.zod.ts
    • Added auto-generated Zod schemas for the 'GlobalSettings' entity, including globalSettingsIdSchema, globalSettingsSchema, globalSettingsInitializerSchema, and globalSettingsMutatorSchema.
  • shared/src/schemas/GoalPresets.zod.ts
    • Added auto-generated Zod schemas for the 'GoalPresets' entity, including goalPresetsIdSchema, goalPresetsSchema, goalPresetsInitializerSchema, and goalPresetsMutatorSchema.
  • shared/src/schemas/MealFoods.zod.ts
    • Added auto-generated Zod schemas for the 'MealFoods' entity, including mealFoodsIdSchema, mealFoodsSchema, mealFoodsInitializerSchema, and mealFoodsMutatorSchema.
  • shared/src/schemas/MealPlanTemplateAssignments.zod.ts
    • Added auto-generated Zod schemas for the 'MealPlanTemplateAssignments' entity, including mealPlanTemplateAssignmentsIdSchema, mealPlanTemplateAssignmentsSchema, mealPlanTemplateAssignmentsInitializerSchema, and mealPlanTemplateAssignmentsMutatorSchema.
  • shared/src/schemas/MealPlanTemplates.zod.ts
    • Added auto-generated Zod schemas for the 'MealPlanTemplates' entity, including mealPlanTemplatesIdSchema, mealPlanTemplatesSchema, mealPlanTemplatesInitializerSchema, and mealPlanTemplatesMutatorSchema.
  • shared/src/schemas/MealPlans.zod.ts
    • Added auto-generated Zod schemas for the 'MealPlans' entity, including mealPlansIdSchema, mealPlansSchema, mealPlansInitializerSchema, and mealPlansMutatorSchema.
  • shared/src/schemas/MealTypes.zod.ts
    • Added auto-generated Zod schemas for the 'MealTypes' entity, including mealTypesIdSchema, mealTypesSchema, mealTypesInitializerSchema, and mealTypesMutatorSchema.
  • shared/src/schemas/Meals.zod.ts
    • Added auto-generated Zod schemas for the 'Meals' entity, including mealsIdSchema, mealsSchema, mealsInitializerSchema, and mealsMutatorSchema.
  • shared/src/schemas/MoodEntries.zod.ts
    • Added auto-generated Zod schemas for the 'MoodEntries' entity, including moodEntriesIdSchema, moodEntriesSchema, moodEntriesInitializerSchema, and moodEntriesMutatorSchema.
  • shared/src/schemas/OidcProviders.zod.ts
    • Added auto-generated Zod schemas for the 'OidcProviders' entity, including oidcProvidersIdSchema, oidcProvidersSchema, oidcProvidersInitializerSchema, and oidcProvidersMutatorSchema.
  • shared/src/schemas/OnboardingData.zod.ts
    • Added auto-generated Zod schemas for the 'OnboardingData' entity, including onboardingDataIdSchema, onboardingDataSchema, onboardingDataInitializerSchema, and onboardingDataMutatorSchema.
  • shared/src/schemas/OnboardingStatus.zod.ts
    • Added auto-generated Zod schemas for the 'OnboardingStatus' entity, including onboardingStatusIdSchema, onboardingStatusSchema, onboardingStatusInitializerSchema, and onboardingStatusMutatorSchema.
  • shared/src/schemas/Passkey.zod.ts
    • Added auto-generated Zod schemas for the 'Passkey' entity, including passkeyIdSchema, passkeySchema, passkeyInitializerSchema, and passkeyMutatorSchema.
  • shared/src/schemas/Profiles.zod.ts
    • Added auto-generated Zod schemas for the 'Profiles' entity, including profilesSchema, profilesInitializerSchema, and profilesMutatorSchema.
  • shared/src/schemas/Session.zod.ts
    • Added auto-generated Zod schemas for the 'Session' entity, including sessionIdSchema, sessionSchema, sessionInitializerSchema, and sessionMutatorSchema.
  • shared/src/schemas/SleepEntries.zod.ts
    • Added auto-generated Zod schemas for the 'SleepEntries' entity, including sleepEntriesIdSchema, sleepEntriesSchema, sleepEntriesInitializerSchema, and sleepEntriesMutatorSchema.
  • shared/src/schemas/SleepEntryStages.zod.ts
    • Added auto-generated Zod schemas for the 'SleepEntryStages' entity, including sleepEntryStagesIdSchema, sleepEntryStagesSchema, sleepEntryStagesInitializerSchema, and sleepEntryStagesMutatorSchema.
  • shared/src/schemas/SleepNeedCalculations.zod.ts
    • Added auto-generated Zod schemas for the 'SleepNeedCalculations' entity, including sleepNeedCalculationsIdSchema, sleepNeedCalculationsSchema, sleepNeedCalculationsInitializerSchema, and sleepNeedCalculationsMutatorSchema.
  • shared/src/schemas/SparkyChatHistory.zod.ts
    • Added auto-generated Zod schemas for the 'SparkyChatHistory' entity, including sparkyChatHistorySchema, sparkyChatHistoryInitializerSchema, and sparkyChatHistoryMutatorSchema.
  • shared/src/schemas/SsoProvider.zod.ts
    • Added auto-generated Zod schemas for the 'SsoProvider' entity, including ssoProviderIdSchema, ssoProviderSchema, ssoProviderInitializerSchema, and ssoProviderMutatorSchema.
  • shared/src/schemas/TwoFactor.zod.ts
    • Added auto-generated Zod schemas for the 'TwoFactor' entity, including twoFactorIdSchema, twoFactorSchema, twoFactorInitializerSchema, and twoFactorMutatorSchema.
  • shared/src/schemas/User.zod.ts
    • Added auto-generated Zod schemas for the 'User' entity, including userIdSchema, userSchema, userInitializerSchema, and userMutatorSchema.
  • shared/src/schemas/UserCustomNutrients.zod.ts
    • Added auto-generated Zod schemas for the 'UserCustomNutrients' entity, including userCustomNutrientsIdSchema, userCustomNutrientsSchema, userCustomNutrientsInitializerSchema, and userCustomNutrientsMutatorSchema.
  • shared/src/schemas/UserGoals.zod.ts
    • Added auto-generated Zod schemas for the 'UserGoals' entity, including userGoalsSchema, userGoalsInitializerSchema, and userGoalsMutatorSchema.
  • shared/src/schemas/UserIgnoredUpdates.zod.ts
    • Added auto-generated Zod schemas for the 'UserIgnoredUpdates' entity, including userIgnoredUpdatesVariantIdSchema, userIgnoredUpdatesSchema, userIgnoredUpdatesInitializerSchema, and userIgnoredUpdatesMutatorSchema.
  • shared/src/schemas/UserMealVisibilities.zod.ts
    • Added auto-generated Zod schemas for the 'UserMealVisibilities' entity, including userMealVisibilitiesSchema, userMealVisibilitiesInitializerSchema, and userMealVisibilitiesMutatorSchema.
  • shared/src/schemas/UserNutrientDisplayPreferences.zod.ts
    • Added auto-generated Zod schemas for the 'UserNutrientDisplayPreferences' entity, including userNutrientDisplayPreferencesIdSchema, userNutrientDisplayPreferencesSchema, userNutrientDisplayPreferencesInitializerSchema, and userNutrientDisplayPreferencesMutatorSchema.
  • shared/src/schemas/UserOidcLinks.zod.ts
    • Added auto-generated Zod schemas for the 'UserOidcLinks' entity, including userOidcLinksIdSchema, userOidcLinksSchema, userOidcLinksInitializerSchema, and userOidcLinksMutatorSchema.
  • shared/src/schemas/UserPreferences.zod.ts
    • Added auto-generated Zod schemas for the 'UserPreferences' entity, including userPreferencesSchema, userPreferencesInitializerSchema, and userPreferencesMutatorSchema.
  • shared/src/schemas/UserWaterContainers.zod.ts
    • Added auto-generated Zod schemas for the 'UserWaterContainers' entity, including userWaterContainersIdSchema, userWaterContainersSchema, userWaterContainersInitializerSchema, and userWaterContainersMutatorSchema.
  • shared/src/schemas/Users.zod.ts
    • Added auto-generated Zod schemas for the 'Users' entity, including usersIdSchema, usersSchema, usersInitializerSchema, and usersMutatorSchema.
  • shared/src/schemas/VMctqAnalysis.zod.ts
    • Added auto-generated Zod schemas for the 'VMctqAnalysis' entity, including vMctqAnalysisSchema.
  • shared/src/schemas/VMctqStats.zod.ts
    • Added auto-generated Zod schemas for the 'VMctqStats' entity, including vMctqStatsSchema.
  • shared/src/schemas/Verification.zod.ts
    • Added auto-generated Zod schemas for the 'Verification' entity, including verificationIdSchema, verificationSchema, verificationInitializerSchema, and verificationMutatorSchema.
  • shared/src/schemas/WaterIntake.zod.ts
    • Added auto-generated Zod schemas for the 'WaterIntake' entity, including waterIntakeSchema, waterIntakeInitializerSchema, and waterIntakeMutatorSchema.
  • shared/src/schemas/WeeklyGoalPlans.zod.ts
    • Added auto-generated Zod schemas for the 'WeeklyGoalPlans' entity, including weeklyGoalPlansIdSchema, weeklyGoalPlansSchema, weeklyGoalPlansInitializerSchema, and weeklyGoalPlansMutatorSchema.
  • shared/src/schemas/WorkoutPlanAssignmentSets.zod.ts
    • Added auto-generated Zod schemas for the 'WorkoutPlanAssignmentSets' entity, including workoutPlanAssignmentSetsIdSchema, workoutPlanAssignmentSetsSchema, workoutPlanAssignmentSetsInitializerSchema, and workoutPlanAssignmentSetsMutatorSchema.
  • shared/src/schemas/WorkoutPlanTemplateAssignments.zod.ts
    • Added auto-generated Zod schemas for the 'WorkoutPlanTemplateAssignments' entity, including workoutPlanTemplateAssignmentsIdSchema, workoutPlanTemplateAssignmentsSchema, workoutPlanTemplateAssignmentsInitializerSchema, and workoutPlanTemplateAssignmentsMutatorSchema.
  • shared/src/schemas/WorkoutPlanTemplates.zod.ts
    • Added auto-generated Zod schemas for the 'WorkoutPlanTemplates' entity, including workoutPlanTemplatesIdSchema, workoutPlanTemplatesSchema, workoutPlanTemplatesInitializerSchema, and workoutPlanTemplatesMutatorSchema.
  • shared/src/schemas/WorkoutPresetExerciseSets.zod.ts
    • Added auto-generated Zod schemas for the 'WorkoutPresetExerciseSets' entity, including workoutPresetExerciseSetsIdSchema, workoutPresetExerciseSetsSchema, workoutPresetExerciseSetsInitializerSchema, and workoutPresetExerciseSetsMutatorSchema.
  • shared/src/schemas/WorkoutPresetExercises.zod.ts
    • Added auto-generated Zod schemas for the 'WorkoutPresetExercises' entity, including workoutPresetExercisesIdSchema, workoutPresetExercisesSchema, workoutPresetExercisesInitializerSchema, and workoutPresetExercisesMutatorSchema.
  • shared/src/schemas/WorkoutPresets.zod.ts
    • Added auto-generated Zod schemas for the 'WorkoutPresets' entity, including workoutPresetsIdSchema, workoutPresetsSchema, workoutPresetsInitializerSchema, and workoutPresetsMutatorSchema.
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 is a great step forward in improving the project's architecture by introducing a shared workspace and auto-generated Zod schemas for type safety. The migration of the backup feature serves as a good proof of concept.

My review focuses on two main areas to ensure the new setup is robust and maintainable:

  1. The scripts for generating types in shared/package.json have some issues with paths and variable naming that will prevent them from working as intended.
  2. The generated Zod schemas frequently use z.any() for foreign key relationships (like user_id), which significantly reduces the type-safety benefits.

Fixing these issues will solidify the foundation of this new type-safe architecture.

Note: Security Review did not run due to the size of the PR.

}),
);

const userIdSchema = z.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

Using z.any() for userIdSchema undermines the type safety that Zod is meant to provide. This seems to be a recurring pattern across many of the newly generated schema files for foreign key IDs.

The schema for Users (shared/src/schemas/Users.zod.ts) defines a branded type usersIdSchema which seems to be the correct type for this foreign key. It would be much safer to import and use that specific schema here.

I'd recommend replacing const userIdSchema = z.any(); with an import at the top of the file:

import { usersIdSchema } from "./Users.zod";

And then using usersIdSchema for the user_id fields. This should be applied to all other schemas referencing a user ID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not the right time to fine tune 6000 lines of schemes

@Sim-sat Sim-sat force-pushed the zod-validation branch 10 times, most recently from 13ff28c to c0e4570 Compare March 7, 2026 07:53
@Sim-sat Sim-sat marked this pull request as ready for review March 7, 2026 08:37
@CodeWithCJ CodeWithCJ merged commit a22362b into CodeWithCJ:main Mar 7, 2026
6 checks passed
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.

2 participants