Skip to content

Refactor: Improve code structure with shared types and API client#2

Open
adhit-r wants to merge 5 commits intomasterfrom
refactor/remove-genkit
Open

Refactor: Improve code structure with shared types and API client#2
adhit-r wants to merge 5 commits intomasterfrom
refactor/remove-genkit

Conversation

@adhit-r
Copy link
Owner

@adhit-r adhit-r commented Jul 6, 2025

  • Centralized all API-related Zod schemas and TypeScript types into src/lib/types/api-schemas.ts.
  • Updated API routes and client components to use these shared types.
  • Created an API client module src/lib/api-client.ts to encapsulate fetch calls to backend AI API routes.
  • Refactored client components (Analysis page, Dashboard, Training Bot interface) to use the new API client.

These changes improve type safety, reduce code duplication, and make client-side API interactions cleaner and more maintainable.

- Centralized all API-related Zod schemas and TypeScript types into `src/lib/types/api-schemas.ts`.
- Updated API routes and client components to use these shared types.
- Created an API client module `src/lib/api-client.ts` to encapsulate fetch calls to backend AI API routes.
- Refactored client components (Analysis page, Dashboard, Training Bot interface) to use the new API client.

These changes improve type safety, reduce code duplication, and make client-side API interactions cleaner and more maintainable.
@adhit-r adhit-r requested a review from Copilot August 1, 2025 21:49
Copy link

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 chess analysis application to improve code organization and type safety by centralizing API-related schemas and creating a dedicated API client module. The changes eliminate the dependency on Genkit AI flows and implement direct Next.js API routes for all backend functionality.

Key changes:

  • Centralized all Zod schemas and TypeScript types into a shared api-schemas.ts file
  • Created a unified API client module to handle all backend API interactions
  • Converted AI flows to standard Next.js API routes with proper validation and error handling

Reviewed Changes

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

Show a summary per file
File Description
src/lib/types/api-schemas.ts New centralized file containing all API schemas and TypeScript types
src/lib/api-client.ts New API client module with typed methods for all backend endpoints
src/components/train/training-bot-interface.tsx Updated to use new API client instead of direct flow imports
src/app/api/ai/*/route.ts New Next.js API routes replacing Genkit AI flows
src/app/(app)/page.tsx Updated dashboard to use new API client
src/app/(app)/analysis/page.tsx Updated analysis page to use new API client
src/ai/flows/*.ts Removed old Genkit flow files
package.json Removed Genkit dependencies and scripts

adhit-r and others added 4 commits August 2, 2025 14:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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