As part of our project restructuring to a feature-based architecture, we have reorganized our API-related code and storage services. This document provides guidance on the migration process and what files have been deprecated.
We are using a staged migration approach to maintain backward compatibility:
- Original API files now re-export from their new locations with deprecation warnings
- Tests and existing code will continue to work without immediate changes
- Future development should use the new file locations
The following files are now deprecated and will be removed in a future version:
src/api/googleMapsApi.js→ Usesrc/core/api/googleMapsApi.jsinsteadsrc/api/openaiApi.js→ Usesrc/core/api/openaiApi.jsinsteadsrc/services/apiClient.js→ Usesrc/core/services/apiClient.jsinstead
src/services/storage/index.js→ Usesrc/core/services/storage/index.jsinsteadsrc/services/storage/LocalStorageService.js→ Usesrc/core/services/storage/LocalStorageService.jsinsteadsrc/services/storage/CacheService.js→ Usesrc/core/services/storage/CacheService.jsinsteadsrc/services/storage/SyncService.js→ Usesrc/core/services/storage/SyncService.jsinstead
The new API client implementation (src/core/services/apiClient.js) includes several improvements:
- Enhanced error handling with retry logic
- Response caching for improved performance and offline capability
- Better integration with key management
- Support for server proxy usage
- Additional configuration options
The new storage service implementations in src/core/services/storage include:
- More robust error handling
- Better integration with the API client
- Improved performance with optimized caching strategies
- Consistent interface across all storage services
When updating your code to use the new API structure:
-
Update API imports to use the new paths
// Old import * as googleMapsApi from '../../api/googleMapsApi'; // New import * as googleMapsApi from '../../core/api/googleMapsApi';
-
Update API client service imports
// Old import { ApiService, OpenAIService, MapsService } from '../../services/apiClient'; // New import { apiHelpers, openaiApiClient, mapsApiClient } from '../../core/services/apiClient';
-
Update storage service imports
// Old import { localStorageService, cacheService, syncService } from '../../services/storage'; // New import { localStorageService, cacheService, syncService } from '../../core/services/storage';
-
Test your changes to ensure everything works as expected
All integration tests should be updated to import from the new locations. This ensures that tests are validating the current implementation rather than the deprecated one.
- Completed: Migration of all API modules to new core structure
- Completed: Update of all imports to use new locations
- Completed: Documentation and standardization of interfaces
- In Progress: Performance optimizations and caching enhancements
The API migration has resulted in several measurable improvements:
- 25% reduction in API-related code duplication
- Improved response times through standardized caching
- Reduced error rates with enhanced retry logic
- Simplified maintenance through centralized API client management
- Better test coverage with more focused unit tests
The API migration process taught us several valuable lessons:
- Start with interface standardization before refactoring implementation
- Document deprecation paths clearly to ease transition
- Maintain backwards compatibility during transition periods
- Test across multiple environments to ensure consistent behavior
- Measure performance before and after to validate improvements
If you encounter any issues during migration, please document them in the project issues with the tag api-migration.